вроде все
This commit is contained in:
parent
d9cadbabc4
commit
7cb5d815f7
@ -0,0 +1,84 @@
|
|||||||
|
using ProjectAirplaneWithRadar.Generics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using ProjectAirplaneWithRadar.DrawningObjects;
|
||||||
|
using ProjectAirplaneWithRadar.MovementStrategy;
|
||||||
|
namespace ProjectAirplaneWithRadar.Generics
|
||||||
|
{
|
||||||
|
internal class AirplanesGenericCollection<T, U>
|
||||||
|
where T : DrawningAirplane
|
||||||
|
where U : IMoveableObject
|
||||||
|
{
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
private readonly int _placeSizeWidth = 215;
|
||||||
|
private readonly int _placeSizeHeight = 90;
|
||||||
|
private readonly SetGeneric<T> _collection;
|
||||||
|
public AirplanesGenericCollection(int picWidth, int picHeight)
|
||||||
|
{
|
||||||
|
int width = picWidth / _placeSizeWidth;
|
||||||
|
int height = picHeight / _placeSizeHeight;
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_collection = new SetGeneric<T>(width * height);
|
||||||
|
}
|
||||||
|
public static int operator +(AirplanesGenericCollection<T, U> collect, T? obj)
|
||||||
|
{
|
||||||
|
if (obj == null || collect == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
return collect._collection.Insert(obj);
|
||||||
|
}
|
||||||
|
public static T? operator -(AirplanesGenericCollection<T, U> collect, int pos)
|
||||||
|
{
|
||||||
|
T? obj = collect._collection.Get(pos);
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
collect._collection.Remove(pos);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
public U? GetU(int pos)
|
||||||
|
{
|
||||||
|
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||||
|
}
|
||||||
|
public Bitmap ShowAirplanes()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
DrawBackground(gr);
|
||||||
|
DrawObjects(gr);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
private void DrawBackground(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black, 3);
|
||||||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||||
|
1; ++j)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||||
|
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||||
|
_placeSizeHeight);
|
||||||
|
}
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||||
|
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DrawObjects(Graphics g)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _collection.Count; i++)
|
||||||
|
{
|
||||||
|
DrawningAirplane? airplane = _collection.Get(i);
|
||||||
|
if (airplane != null)
|
||||||
|
{
|
||||||
|
int inRow = _pictureWidth / _placeSizeWidth;
|
||||||
|
airplane.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth), i / inRow * _placeSizeHeight) ;
|
||||||
|
airplane.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ProjectAirplaneWithRadar.Entities;
|
using ProjectAirplaneWithRadar.Entities;
|
||||||
|
using ProjectAirplaneWithRadar.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectAirplaneWithRadar.DrawningObjects
|
namespace ProjectAirplaneWithRadar.DrawningObjects
|
||||||
{
|
{
|
||||||
@ -21,6 +22,7 @@ namespace ProjectAirplaneWithRadar.DrawningObjects
|
|||||||
public int GetPosY => _startPosY;
|
public int GetPosY => _startPosY;
|
||||||
public int GetWidth => _airplaneWidth;
|
public int GetWidth => _airplaneWidth;
|
||||||
public int GetHeight => _airplaneHeight;
|
public int GetHeight => _airplaneHeight;
|
||||||
|
public IMoveableObject GetMoveableObject => new DrawningObjectAirplane(this);
|
||||||
public DrawningAirplane(int speed, double weight, Color bodyColor, int
|
public DrawningAirplane(int speed, double weight, Color bodyColor, int
|
||||||
width, int height)
|
width, int height)
|
||||||
{
|
{
|
||||||
@ -115,8 +117,8 @@ namespace ProjectAirplaneWithRadar.DrawningObjects
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new Pen(Color.Black, 3);
|
|
||||||
|
Pen pen = new Pen(Color.Black, 3);
|
||||||
// корпус
|
// корпус
|
||||||
Brush br = new SolidBrush(EntityAirplane.BodyColor);
|
Brush br = new SolidBrush(EntityAirplane.BodyColor);
|
||||||
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 180, 30);
|
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 180, 30);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
buttonCreateAirplane = new Button();
|
buttonCreateAirplane = new Button();
|
||||||
comboBoxAirplane = new ComboBox();
|
comboBoxAirplane = new ComboBox();
|
||||||
buttonStep = new Button();
|
buttonStep = new Button();
|
||||||
|
buttonSelectAirplane = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -118,6 +119,7 @@
|
|||||||
//
|
//
|
||||||
// comboBoxAirplane
|
// comboBoxAirplane
|
||||||
//
|
//
|
||||||
|
comboBoxAirplane.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
comboBoxAirplane.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxAirplane.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxAirplane.FormattingEnabled = true;
|
comboBoxAirplane.FormattingEnabled = true;
|
||||||
comboBoxAirplane.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
|
comboBoxAirplane.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
|
||||||
@ -128,6 +130,7 @@
|
|||||||
//
|
//
|
||||||
// buttonStep
|
// buttonStep
|
||||||
//
|
//
|
||||||
|
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonStep.Location = new Point(724, 46);
|
buttonStep.Location = new Point(724, 46);
|
||||||
buttonStep.Name = "buttonStep";
|
buttonStep.Name = "buttonStep";
|
||||||
buttonStep.Size = new Size(151, 29);
|
buttonStep.Size = new Size(151, 29);
|
||||||
@ -136,11 +139,22 @@
|
|||||||
buttonStep.UseVisualStyleBackColor = true;
|
buttonStep.UseVisualStyleBackColor = true;
|
||||||
buttonStep.Click += buttonStep_Click;
|
buttonStep.Click += buttonStep_Click;
|
||||||
//
|
//
|
||||||
|
// buttonSelectAirplane
|
||||||
|
//
|
||||||
|
buttonSelectAirplane.Location = new Point(724, 81);
|
||||||
|
buttonSelectAirplane.Name = "buttonSelectAirplane";
|
||||||
|
buttonSelectAirplane.Size = new Size(151, 29);
|
||||||
|
buttonSelectAirplane.TabIndex = 9;
|
||||||
|
buttonSelectAirplane.Text = "Select Airplane";
|
||||||
|
buttonSelectAirplane.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectAirplane.Click += buttonSelectAirplane_Click;
|
||||||
|
//
|
||||||
// FormAirplaneWithRadar
|
// FormAirplaneWithRadar
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(887, 454);
|
ClientSize = new Size(887, 454);
|
||||||
|
Controls.Add(buttonSelectAirplane);
|
||||||
Controls.Add(buttonStep);
|
Controls.Add(buttonStep);
|
||||||
Controls.Add(comboBoxAirplane);
|
Controls.Add(comboBoxAirplane);
|
||||||
Controls.Add(buttonCreateAirplane);
|
Controls.Add(buttonCreateAirplane);
|
||||||
@ -168,5 +182,6 @@
|
|||||||
private Button buttonCreateAirplane;
|
private Button buttonCreateAirplane;
|
||||||
private ComboBox comboBoxAirplane;
|
private ComboBox comboBoxAirplane;
|
||||||
private Button buttonStep;
|
private Button buttonStep;
|
||||||
|
private Button buttonSelectAirplane;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ namespace ProjectAirplaneWithRadar
|
|||||||
{
|
{
|
||||||
private DrawningAirplane _drawningAirplane;
|
private DrawningAirplane _drawningAirplane;
|
||||||
private AbstractStrategy _abstractStrategy;
|
private AbstractStrategy _abstractStrategy;
|
||||||
|
public DrawningAirplane? SelectedAirplane { get; private set; }
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
if (_drawningAirplane == null)
|
if (_drawningAirplane == null)
|
||||||
@ -48,25 +49,32 @@ namespace ProjectAirplaneWithRadar
|
|||||||
}
|
}
|
||||||
private void buttonCreateAirplaneWithRadar_Click(object sender, EventArgs e)
|
private void buttonCreateAirplaneWithRadar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new();
|
||||||
_drawningAirplane = new DrawningAirplaneWithRadar(random.Next(100, 300), // speed
|
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
random.Next(1000, 3000),// weight
|
Color additionalColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),// bodycolor
|
ColorDialog dialog = new();
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), //additionalColor
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
Convert.ToBoolean(random.Next(0, 2)), // radar
|
bodyColor = dialog.Color;
|
||||||
Convert.ToBoolean(random.Next(0, 2)), //dopbak
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
additionalColor = dialog.Color;
|
||||||
|
|
||||||
_drawningAirplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningAirplane = new DrawningAirplaneWithRadar(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
bodyColor, additionalColor, true, true,
|
||||||
|
pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void buttonCreateAirplane_Click(object sender, EventArgs e)
|
private void buttonCreateAirplane_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new();
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256),
|
||||||
|
random.Next(0, 256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
_drawningAirplane = new DrawningAirplane(random.Next(100, 300),
|
_drawningAirplane = new DrawningAirplane(random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000), color,
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
|
||||||
random.Next(0, 256)),
|
|
||||||
pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
||||||
_drawningAirplane.SetPosition(random.Next(10, 100), random.Next(10,
|
_drawningAirplane.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
100));
|
100));
|
||||||
@ -113,5 +121,10 @@ namespace ProjectAirplaneWithRadar
|
|||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void buttonSelectAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedAirplane = _drawningAirplane;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
126
ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs
generated
Normal file
126
ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
namespace ProjectAirplaneWithRadar
|
||||||
|
{
|
||||||
|
partial class FormAirplanesCollection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
pictureBoxAirplaneWithRadar = new PictureBox();
|
||||||
|
groupBoxAirplaneWithRadar = new GroupBox();
|
||||||
|
buttonUpdateCollection = new Button();
|
||||||
|
buttonDeleteAirplane = new Button();
|
||||||
|
buttonAddAirplane = new Button();
|
||||||
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).BeginInit();
|
||||||
|
groupBoxAirplaneWithRadar.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAirplaneWithRadar
|
||||||
|
//
|
||||||
|
pictureBoxAirplaneWithRadar.Location = new Point(-9, 0);
|
||||||
|
pictureBoxAirplaneWithRadar.Name = "pictureBoxAirplaneWithRadar";
|
||||||
|
pictureBoxAirplaneWithRadar.Size = new Size(650, 454);
|
||||||
|
pictureBoxAirplaneWithRadar.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBoxAirplaneWithRadar.TabIndex = 0;
|
||||||
|
pictureBoxAirplaneWithRadar.TabStop = false;
|
||||||
|
//
|
||||||
|
// groupBoxAirplaneWithRadar
|
||||||
|
//
|
||||||
|
groupBoxAirplaneWithRadar.Controls.Add(buttonUpdateCollection);
|
||||||
|
groupBoxAirplaneWithRadar.Controls.Add(buttonDeleteAirplane);
|
||||||
|
groupBoxAirplaneWithRadar.Controls.Add(buttonAddAirplane);
|
||||||
|
groupBoxAirplaneWithRadar.Controls.Add(maskedTextBoxNumber);
|
||||||
|
groupBoxAirplaneWithRadar.Dock = DockStyle.Right;
|
||||||
|
groupBoxAirplaneWithRadar.Location = new Point(637, 0);
|
||||||
|
groupBoxAirplaneWithRadar.Name = "groupBoxAirplaneWithRadar";
|
||||||
|
groupBoxAirplaneWithRadar.Size = new Size(250, 454);
|
||||||
|
groupBoxAirplaneWithRadar.TabIndex = 1;
|
||||||
|
groupBoxAirplaneWithRadar.TabStop = false;
|
||||||
|
groupBoxAirplaneWithRadar.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonUpdateCollection
|
||||||
|
//
|
||||||
|
buttonUpdateCollection.Location = new Point(6, 275);
|
||||||
|
buttonUpdateCollection.Name = "buttonUpdateCollection";
|
||||||
|
buttonUpdateCollection.Size = new Size(238, 29);
|
||||||
|
buttonUpdateCollection.TabIndex = 3;
|
||||||
|
buttonUpdateCollection.Text = "Обновить коллекцию";
|
||||||
|
buttonUpdateCollection.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdateCollection.Click += buttonUpdateCollection_Click;
|
||||||
|
//
|
||||||
|
// buttonDeleteAirplane
|
||||||
|
//
|
||||||
|
buttonDeleteAirplane.Location = new Point(6, 208);
|
||||||
|
buttonDeleteAirplane.Name = "buttonDeleteAirplane";
|
||||||
|
buttonDeleteAirplane.Size = new Size(238, 29);
|
||||||
|
buttonDeleteAirplane.TabIndex = 2;
|
||||||
|
buttonDeleteAirplane.Text = "Удалить самолет";
|
||||||
|
buttonDeleteAirplane.UseVisualStyleBackColor = true;
|
||||||
|
buttonDeleteAirplane.Click += buttonDeleteAirplane_Click;
|
||||||
|
//
|
||||||
|
// buttonAddAirplane
|
||||||
|
//
|
||||||
|
buttonAddAirplane.Location = new Point(6, 26);
|
||||||
|
buttonAddAirplane.Name = "buttonAddAirplane";
|
||||||
|
buttonAddAirplane.Size = new Size(238, 29);
|
||||||
|
buttonAddAirplane.TabIndex = 1;
|
||||||
|
buttonAddAirplane.Text = "Добавить самолет";
|
||||||
|
buttonAddAirplane.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddAirplane.Click += buttonAddAirplane_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
maskedTextBoxNumber.Location = new Point(67, 92);
|
||||||
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
maskedTextBoxNumber.Size = new Size(125, 27);
|
||||||
|
maskedTextBoxNumber.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// FormAirplanesCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(887, 454);
|
||||||
|
Controls.Add(groupBoxAirplaneWithRadar);
|
||||||
|
Controls.Add(pictureBoxAirplaneWithRadar);
|
||||||
|
Name = "FormAirplanesCollection";
|
||||||
|
Text = "FormAirplaneWithRadar";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).EndInit();
|
||||||
|
groupBoxAirplaneWithRadar.ResumeLayout(false);
|
||||||
|
groupBoxAirplaneWithRadar.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAirplaneWithRadar;
|
||||||
|
private GroupBox groupBoxAirplaneWithRadar;
|
||||||
|
private Button buttonDeleteAirplane;
|
||||||
|
private Button buttonAddAirplane;
|
||||||
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private Button buttonUpdateCollection;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
using ProjectAirplaneWithRadar.DrawningObjects;
|
||||||
|
using ProjectAirplaneWithRadar.MovementStrategy;
|
||||||
|
using ProjectAirplaneWithRadar.Generics;
|
||||||
|
|
||||||
|
namespace ProjectAirplaneWithRadar
|
||||||
|
{
|
||||||
|
public partial class FormAirplanesCollection : System.Windows.Forms.Form
|
||||||
|
{
|
||||||
|
private readonly AirplanesGenericCollection<DrawningAirplane, DrawningObjectAirplane> _Airplanes;
|
||||||
|
public FormAirplanesCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_Airplanes = new AirplanesGenericCollection<DrawningAirplane,
|
||||||
|
DrawningObjectAirplane>(pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
||||||
|
}
|
||||||
|
private void buttonAddAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FormAirplaneWithRadar form = new();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_Airplanes + form.SelectedAirplane != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Îáúåêò äîáàâëåí");
|
||||||
|
pictureBoxAirplaneWithRadar.Image = _Airplanes.ShowAirplanes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Íå óäàëîñü äîáàâèòü îáúåêò");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonDeleteAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Óäàëèòü îáúåêò?", "Óäàëåíèå", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
|
if (_Airplanes - pos != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Îáúåêò óäàëåí");
|
||||||
|
pictureBoxAirplaneWithRadar.Image = _Airplanes.ShowAirplanes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Íå óäàëîñü óäàëèòü îáúåêò");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void buttonUpdateCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxAirplaneWithRadar.Image = _Airplanes.ShowAirplanes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -11,7 +11,7 @@ namespace ProjectAirplaneWithRadar
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormAirplaneWithRadar());
|
Application.Run(new FormAirplanesCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
using System.CodeDom;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
|
namespace ProjectAirplaneWithRadar.Generics
|
||||||
|
{
|
||||||
|
internal class SetGeneric<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
private readonly T?[] _places;
|
||||||
|
public int Count => _places.Length;
|
||||||
|
public SetGeneric(int count)
|
||||||
|
{
|
||||||
|
_places = new T?[count];
|
||||||
|
}
|
||||||
|
public int Insert(T airplane)
|
||||||
|
{
|
||||||
|
if (_places[Count - 1] != null)
|
||||||
|
return -1;
|
||||||
|
return Insert(airplane, 0);
|
||||||
|
}
|
||||||
|
public int Insert(T airplane, int position)
|
||||||
|
{
|
||||||
|
if (!(position >= 0 && position < Count))
|
||||||
|
return -1;
|
||||||
|
if (_places[position] != null)
|
||||||
|
{
|
||||||
|
int ind = position;
|
||||||
|
while (ind < Count && _places[ind] != null)
|
||||||
|
ind++;
|
||||||
|
if (ind == Count)
|
||||||
|
return -1;
|
||||||
|
for (int i = ind - 1; i >= position; i--)
|
||||||
|
_places[i + 1] = _places[i];
|
||||||
|
}
|
||||||
|
_places[position] = airplane;
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if (!(position >= 0 && position < Count) || _places[position] == null)
|
||||||
|
return false;
|
||||||
|
_places[position] = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
if (!(position >= 0 && position < Count))
|
||||||
|
return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user