Morozov V.S. LabWork3 #3
@ -30,14 +30,14 @@
|
||||
{
|
||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonRemoveCar = new System.Windows.Forms.Button();
|
||||
this.buttonRemovePlain = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonAddCar = new System.Windows.Forms.Button();
|
||||
this.buttonAddPlain = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxTools.SuspendLayout();
|
||||
@ -47,14 +47,14 @@
|
||||
// groupBoxTools
|
||||
//
|
||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBoxTools.Controls.Add(this.buttonRemoveCar);
|
||||
this.groupBoxTools.Controls.Add(this.buttonRemovePlain);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||
this.groupBoxTools.Controls.Add(this.buttonRight);
|
||||
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBoxTools.Controls.Add(this.buttonAddCar);
|
||||
this.groupBoxTools.Controls.Add(this.buttonAddPlain);
|
||||
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(1057, 0);
|
||||
@ -73,15 +73,15 @@
|
||||
this.maskedTextBoxPosition.TabIndex = 2;
|
||||
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonRemoveCar
|
||||
// buttonRemovePlain
|
||||
//
|
||||
this.buttonRemoveCar.Location = new System.Drawing.Point(17, 195);
|
||||
this.buttonRemoveCar.Name = "buttonRemoveCar";
|
||||
this.buttonRemoveCar.Size = new System.Drawing.Size(175, 35);
|
||||
this.buttonRemoveCar.TabIndex = 3;
|
||||
this.buttonRemoveCar.Text = "Удалить автомобиль";
|
||||
this.buttonRemoveCar.UseVisualStyleBackColor = true;
|
||||
this.buttonRemoveCar.Click += new System.EventHandler(this.ButtonRemoveCar_Click);
|
||||
this.buttonRemovePlain.Location = new System.Drawing.Point(17, 195);
|
||||
this.buttonRemovePlain.Name = "buttonRemovePlain";
|
||||
this.buttonRemovePlain.Size = new System.Drawing.Size(175, 35);
|
||||
this.buttonRemovePlain.TabIndex = 3;
|
||||
this.buttonRemovePlain.Text = "Удалить самолет";
|
||||
this.buttonRemovePlain.UseVisualStyleBackColor = true;
|
||||
this.buttonRemovePlain.Click += new System.EventHandler(this.ButtonRemovePlain_Click);
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
@ -103,6 +103,7 @@
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 10;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
@ -114,6 +115,7 @@
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 9;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
@ -125,6 +127,7 @@
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 8;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
@ -136,6 +139,7 @@
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 7;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
@ -147,15 +151,15 @@
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// buttonAddCar
|
||||
// buttonAddPlain
|
||||
//
|
||||
this.buttonAddCar.Location = new System.Drawing.Point(17, 106);
|
||||
this.buttonAddCar.Name = "buttonAddCar";
|
||||
this.buttonAddCar.Size = new System.Drawing.Size(175, 35);
|
||||
this.buttonAddCar.TabIndex = 1;
|
||||
this.buttonAddCar.Text = "Добавить автомобиль";
|
||||
this.buttonAddCar.UseVisualStyleBackColor = true;
|
||||
this.buttonAddCar.Click += new System.EventHandler(this.ButtonAddCar_Click);
|
||||
this.buttonAddPlain.Location = new System.Drawing.Point(17, 106);
|
||||
this.buttonAddPlain.Name = "buttonAddPlain";
|
||||
this.buttonAddPlain.Size = new System.Drawing.Size(175, 35);
|
||||
this.buttonAddPlain.TabIndex = 1;
|
||||
this.buttonAddPlain.Text = "Добавить самолет";
|
||||
this.buttonAddPlain.UseVisualStyleBackColor = true;
|
||||
this.buttonAddPlain.Click += new System.EventHandler(this.ButtonAddPlain_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
@ -201,13 +205,13 @@
|
||||
private PictureBox pictureBox;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private Button buttonShowOnMap;
|
||||
private Button buttonAddCar;
|
||||
private Button buttonAddPlain;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonShowStorage;
|
||||
private Button buttonRemoveCar;
|
||||
private Button buttonRemovePlain;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
@ -42,17 +43,20 @@ namespace AirPlaneWithRadar
|
||||
_mapPlainsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
private void ButtonAddCar_Click(object sender, EventArgs e)
|
||||
private void ButtonAddPlain_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (_mapPlainsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormPlain form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawingObjectPlane car = new(form.SelectedPlain);
|
||||
if (_mapPlainsCollectionGeneric + car)
|
||||
DrawingObjectPlane plain = new(form.SelectedPlain);
|
||||
|
||||
if ((_mapPlainsCollectionGeneric + plain)>=0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapPlainsCollectionGeneric.ShowSet();
|
||||
@ -63,7 +67,7 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRemoveCar_Click(object sender, EventArgs e)
|
||||
private void ButtonRemovePlain_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
@ -74,7 +78,7 @@ namespace AirPlaneWithRadar
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapPlainsCollectionGeneric - pos)
|
||||
if ((_mapPlainsCollectionGeneric - (pos-1)) != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapPlainsCollectionGeneric.ShowSet();
|
||||
@ -106,7 +110,7 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
|
@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
@ -16,7 +16,7 @@ namespace AirPlaneWithRadar
|
||||
|
||||
private readonly int _placeSizeWidth = 180;
|
||||
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
private readonly int _placeSizeHeight = 120;
|
||||
|
||||
private readonly SetPlaneGeneric<T> _setPlains;
|
||||
|
||||
@ -31,13 +31,13 @@ namespace AirPlaneWithRadar
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
|
||||
public static bool operator +(MapWithSetPlainGeneric<T, U> map, T car)
|
||||
|
||||
public static int operator +(MapWithSetPlainGeneric<T, U> map, T plain)
|
||||
{
|
||||
return map._setPlains.Insert(car);
|
||||
return map._setPlains.Insert(plain);
|
||||
}
|
||||
|
||||
public static bool operator -(MapWithSetPlainGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetPlainGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setPlains.Remove(position);
|
||||
}
|
||||
@ -56,10 +56,10 @@ namespace AirPlaneWithRadar
|
||||
Shaking();
|
||||
for (int i = 0; i < _setPlains.Count; i++)
|
||||
{
|
||||
var car = _setPlains.Get(i);
|
||||
if (car != null)
|
||||
var plain = _setPlains.Get(i);
|
||||
if (plain != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, plain);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
@ -83,10 +83,10 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var car = _setPlains.Get(j);
|
||||
if (car != null)
|
||||
var plain = _setPlains.Get(j);
|
||||
if (plain != null)
|
||||
{
|
||||
_setPlains.Insert(car, i);
|
||||
_setPlains.Insert(plain, i);
|
||||
_setPlains.Remove(j);
|
||||
break;
|
||||
}
|
||||
@ -101,7 +101,8 @@ namespace AirPlaneWithRadar
|
||||
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
|
||||
Brush BrushRazmetka = new SolidBrush(Color.DarkGray);
|
||||
g.FillRectangle(BrushRazmetka, 0, 0, _pictureWidth, _pictureHeight);
|
||||
Pen pen = new(Color.White, 5);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
@ -115,12 +116,43 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
private void DrawPlains(Graphics g)
|
||||
{
|
||||
|
||||
for (int i = 0; i < _setPlains.Count; i++)
|
||||
{
|
||||
int CountWidth = _pictureWidth / _placeSizeWidth;
|
||||
|
||||
_setPlains.Get(i)?.DrawningObject(g);
|
||||
int x = _pictureWidth - _placeSizeWidth - _placeSizeWidth/2 - _placeSizeWidth / 4;
|
||||
int y = (_pictureHeight - _placeSizeHeight)- _placeSizeHeight/2;
|
||||
|
||||
for (int k = 0; k < _setPlains.Count; k++)
|
||||
{
|
||||
if (_setPlains.Get(k) != null)
|
||||
{
|
||||
if ((k+1) % CountWidth != 0 || k ==0)
|
||||
{
|
||||
_setPlains.Get(k)?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
||||
_setPlains.Get(k)?.DrawningObject(g);
|
||||
x -= _placeSizeWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_setPlains.Get(k)?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
||||
_setPlains.Get(k)?.DrawningObject(g);
|
||||
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
|
||||
y -= _placeSizeHeight ;
|
||||
|
||||
}
|
||||
}
|
||||
if (_setPlains.Get(k) == null)
|
||||
{
|
||||
if ((k + 1) % CountWidth != 0 || k ==0)
|
||||
x -= _placeSizeWidth;
|
||||
else
|
||||
{
|
||||
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
|
||||
y -= _placeSizeHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,22 +15,63 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
_places = new T[count];
|
||||
}
|
||||
public bool Insert(T plain)
|
||||
public int Insert(T plain)
|
||||
{
|
||||
|
||||
|
||||
return true;
|
||||
int i;
|
||||
for (i = 0; i < Count; i++)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
for (int j = i; j >= 1; j--)
|
||||
{
|
||||
_places[j] = _places[j - 1];
|
||||
}
|
||||
_places[0] = plain;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
public bool Insert(T plain, int position)
|
||||
{
|
||||
|
||||
return true;
|
||||
if (position > Count || position < 0)
|
||||
return false;
|
||||
if (_places[position] == null)
|
||||
{
|
||||
_places[position] = plain;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = position; i < Count; i++)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
for (int j = i; j >= position + 1; j--)
|
||||
{
|
||||
_places[j] = _places[j - 1];
|
||||
}
|
||||
_places[position] = plain;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
|
||||
return false;
|
||||
T mid;
|
||||
if (_places[position] != null)
|
||||
{
|
||||
mid = _places[position];
|
||||
_places[position] = null;
|
||||
return mid;
|
||||
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
public T Get(int position)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user