Готовая 3 лаба
This commit is contained in:
parent
28f3d56a17
commit
e8df20e0eb
@ -79,11 +79,11 @@ namespace Tank.DrawingObjects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _ArmoredcarWidth = 100;
|
protected readonly int _ArmoredcarWidth = 150;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _ArmoredcarHeight = 55;
|
protected readonly int _ArmoredcarHeight = 65;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -203,7 +203,7 @@ namespace Tank.DrawingObjects
|
|||||||
//кузов
|
//кузов
|
||||||
Brush br = new SolidBrush(Tank.BodyColor);
|
Brush br = new SolidBrush(Tank.BodyColor);
|
||||||
g.FillRectangle(br, _startPosX + 5, _startPosY + 17, 110, 18);
|
g.FillRectangle(br, _startPosX + 5, _startPosY + 17, 110, 18);
|
||||||
g.FillRectangle(br, _startPosX + 30, _startPosY, 50, 15);
|
g.FillRectangle(br, _startPosX + 30, _startPosY + 3, 50, 13);
|
||||||
|
|
||||||
// колеса
|
// колеса
|
||||||
Brush brBlack = new SolidBrush(Color.Black);
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
|
22
Tank/Tank/FormArmoredCarCollection.Designer.cs
generated
22
Tank/Tank/FormArmoredCarCollection.Designer.cs
generated
@ -44,25 +44,25 @@
|
|||||||
this.groupBox1.Controls.Add(this.ButtonRefreshCollection);
|
this.groupBox1.Controls.Add(this.ButtonRefreshCollection);
|
||||||
this.groupBox1.Controls.Add(this.ButtonRemoveArmoredCar);
|
this.groupBox1.Controls.Add(this.ButtonRemoveArmoredCar);
|
||||||
this.groupBox1.Controls.Add(this.ButtonAddArmoredCar);
|
this.groupBox1.Controls.Add(this.ButtonAddArmoredCar);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(546, 12);
|
this.groupBox1.Location = new System.Drawing.Point(579, 12);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(242, 383);
|
this.groupBox1.Size = new System.Drawing.Size(200, 426);
|
||||||
this.groupBox1.TabIndex = 0;
|
this.groupBox1.TabIndex = 0;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Инструменты";
|
this.groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(37, 78);
|
this.maskedTextBoxNumber.Location = new System.Drawing.Point(36, 85);
|
||||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(100, 23);
|
this.maskedTextBoxNumber.Size = new System.Drawing.Size(129, 23);
|
||||||
this.maskedTextBoxNumber.TabIndex = 3;
|
this.maskedTextBoxNumber.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// ButtonRefreshCollection
|
// ButtonRefreshCollection
|
||||||
//
|
//
|
||||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(16, 174);
|
this.ButtonRefreshCollection.Location = new System.Drawing.Point(7, 160);
|
||||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(210, 34);
|
this.ButtonRefreshCollection.Size = new System.Drawing.Size(187, 31);
|
||||||
this.ButtonRefreshCollection.TabIndex = 2;
|
this.ButtonRefreshCollection.TabIndex = 2;
|
||||||
this.ButtonRefreshCollection.Text = "Обновить коллекцию";
|
this.ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||||
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
@ -70,9 +70,9 @@
|
|||||||
//
|
//
|
||||||
// ButtonRemoveArmoredCar
|
// ButtonRemoveArmoredCar
|
||||||
//
|
//
|
||||||
this.ButtonRemoveArmoredCar.Location = new System.Drawing.Point(17, 131);
|
this.ButtonRemoveArmoredCar.Location = new System.Drawing.Point(7, 114);
|
||||||
this.ButtonRemoveArmoredCar.Name = "ButtonRemoveArmoredCar";
|
this.ButtonRemoveArmoredCar.Name = "ButtonRemoveArmoredCar";
|
||||||
this.ButtonRemoveArmoredCar.Size = new System.Drawing.Size(210, 34);
|
this.ButtonRemoveArmoredCar.Size = new System.Drawing.Size(187, 40);
|
||||||
this.ButtonRemoveArmoredCar.TabIndex = 1;
|
this.ButtonRemoveArmoredCar.TabIndex = 1;
|
||||||
this.ButtonRemoveArmoredCar.Text = "Удалить бронированную машину";
|
this.ButtonRemoveArmoredCar.Text = "Удалить бронированную машину";
|
||||||
this.ButtonRemoveArmoredCar.UseVisualStyleBackColor = true;
|
this.ButtonRemoveArmoredCar.UseVisualStyleBackColor = true;
|
||||||
@ -80,9 +80,9 @@
|
|||||||
//
|
//
|
||||||
// ButtonAddArmoredCar
|
// ButtonAddArmoredCar
|
||||||
//
|
//
|
||||||
this.ButtonAddArmoredCar.Location = new System.Drawing.Point(17, 22);
|
this.ButtonAddArmoredCar.Location = new System.Drawing.Point(7, 22);
|
||||||
this.ButtonAddArmoredCar.Name = "ButtonAddArmoredCar";
|
this.ButtonAddArmoredCar.Name = "ButtonAddArmoredCar";
|
||||||
this.ButtonAddArmoredCar.Size = new System.Drawing.Size(210, 34);
|
this.ButtonAddArmoredCar.Size = new System.Drawing.Size(187, 42);
|
||||||
this.ButtonAddArmoredCar.TabIndex = 0;
|
this.ButtonAddArmoredCar.TabIndex = 0;
|
||||||
this.ButtonAddArmoredCar.Text = "Добавить бронированную машину";
|
this.ButtonAddArmoredCar.Text = "Добавить бронированную машину";
|
||||||
this.ButtonAddArmoredCar.UseVisualStyleBackColor = true;
|
this.ButtonAddArmoredCar.UseVisualStyleBackColor = true;
|
||||||
@ -92,7 +92,7 @@
|
|||||||
//
|
//
|
||||||
this.pictureBoxCollection.Location = new System.Drawing.Point(1, 0);
|
this.pictureBoxCollection.Location = new System.Drawing.Point(1, 0);
|
||||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
this.pictureBoxCollection.Size = new System.Drawing.Size(539, 395);
|
this.pictureBoxCollection.Size = new System.Drawing.Size(572, 438);
|
||||||
this.pictureBoxCollection.TabIndex = 1;
|
this.pictureBoxCollection.TabIndex = 1;
|
||||||
this.pictureBoxCollection.TabStop = false;
|
this.pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
|
@ -20,8 +20,8 @@ namespace Tank
|
|||||||
public FormArmoredCarCollection()
|
public FormArmoredCarCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_tanks = new TanksGenericCollection<DrawingArmoredCar,
|
_tanks = new TanksGenericCollection<DrawingArmoredCar, DrawingObjectArmoredCar>
|
||||||
DrawingObjectArmoredCar>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
||||||
@ -29,7 +29,7 @@ DrawingObjectArmoredCar>(pictureBoxCollection.Width, pictureBoxCollection.Height
|
|||||||
FormTank form = new();
|
FormTank form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (_tanks + form.SelectedTank)
|
if (_tanks + form.SelectedTank != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollection.Image = _tanks.ShowTanks();
|
pictureBoxCollection.Image = _tanks.ShowTanks();
|
||||||
@ -39,7 +39,6 @@ DrawingObjectArmoredCar>(pictureBoxCollection.Width, pictureBoxCollection.Height
|
|||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e)
|
private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e)
|
||||||
|
14
Tank/Tank/FormTank.Designer.cs
generated
14
Tank/Tank/FormTank.Designer.cs
generated
@ -37,6 +37,7 @@
|
|||||||
this.buttonCreateArmoredCar = new System.Windows.Forms.Button();
|
this.buttonCreateArmoredCar = new System.Windows.Forms.Button();
|
||||||
this.buttonStep = new System.Windows.Forms.Button();
|
this.buttonStep = new System.Windows.Forms.Button();
|
||||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||||
|
this.ButtonSelectTank = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTank)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTank)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -136,11 +137,22 @@
|
|||||||
this.comboBoxStrategy.Size = new System.Drawing.Size(121, 23);
|
this.comboBoxStrategy.Size = new System.Drawing.Size(121, 23);
|
||||||
this.comboBoxStrategy.TabIndex = 10;
|
this.comboBoxStrategy.TabIndex = 10;
|
||||||
//
|
//
|
||||||
|
// ButtonSelectTank
|
||||||
|
//
|
||||||
|
this.ButtonSelectTank.Location = new System.Drawing.Point(737, 113);
|
||||||
|
this.ButtonSelectTank.Name = "ButtonSelectTank";
|
||||||
|
this.ButtonSelectTank.Size = new System.Drawing.Size(117, 23);
|
||||||
|
this.ButtonSelectTank.TabIndex = 11;
|
||||||
|
this.ButtonSelectTank.Text = "Выбор машины";
|
||||||
|
this.ButtonSelectTank.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonSelectTank.Click += new System.EventHandler(this.ButtonSelectTank_Click);
|
||||||
|
//
|
||||||
// FormTank
|
// FormTank
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(884, 461);
|
this.ClientSize = new System.Drawing.Size(884, 461);
|
||||||
|
this.Controls.Add(this.ButtonSelectTank);
|
||||||
this.Controls.Add(this.comboBoxStrategy);
|
this.Controls.Add(this.comboBoxStrategy);
|
||||||
this.Controls.Add(this.buttonStep);
|
this.Controls.Add(this.buttonStep);
|
||||||
this.Controls.Add(this.buttonCreateArmoredCar);
|
this.Controls.Add(this.buttonCreateArmoredCar);
|
||||||
@ -153,7 +165,6 @@
|
|||||||
this.Name = "FormTank";
|
this.Name = "FormTank";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Tank";
|
this.Text = "Tank";
|
||||||
|
|
||||||
this.Load += new System.EventHandler(this.FormTank_Load);
|
this.Load += new System.EventHandler(this.FormTank_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTank)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTank)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
@ -172,5 +183,6 @@
|
|||||||
private Button buttonCreateArmoredCar;
|
private Button buttonCreateArmoredCar;
|
||||||
private Button buttonStep;
|
private Button buttonStep;
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
|
private Button ButtonSelectTank;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,10 +9,10 @@ namespace Tank
|
|||||||
public partial class FormTank : Form
|
public partial class FormTank : Form
|
||||||
{
|
{
|
||||||
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
||||||
private DrawingArmoredCar? _Tank;
|
private DrawingArmoredCar? _Tank; // DrawingArmoredCar DrawingTank
|
||||||
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
||||||
private AbstractStrategy? _abstractStrategy;
|
private AbstractStrategy? _abstractStrategy;
|
||||||
public DrawingArmoredCar? SelectedTank { get; private set; }
|
public DrawingArmoredCar? SelectedTank { get; private set; } // DrawingArmoredCar DrawingTank
|
||||||
public FormTank()
|
public FormTank()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -46,12 +46,22 @@ namespace Tank
|
|||||||
Color color = Color.FromArgb(random.Next(0, 256),
|
Color color = Color.FromArgb(random.Next(0, 256),
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
random.Next(0, 256), random.Next(0, 256));
|
||||||
|
|
||||||
//TODO âûáîð îñíîâíîãî öâåòà
|
// âûáîð îñíîâíîãî öâåòà
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
Color dopColor = Color.FromArgb(random.Next(0, 256),
|
Color dopColor = Color.FromArgb(random.Next(0, 256),
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
random.Next(0, 256), random.Next(0, 256));
|
||||||
|
|
||||||
//TODO âûáîð äîïîëíèòåëüíîãî öâåòà
|
// âûáîð äîïîëíèòåëüíîãî öâåòà
|
||||||
|
ColorDialog dialog2 = new();
|
||||||
|
if (dialog2.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialog2.Color;
|
||||||
|
}
|
||||||
|
|
||||||
_Tank = new DrawingTank(random.Next(100, 300),
|
_Tank = new DrawingTank(random.Next(100, 300),
|
||||||
random.Next(1000, 3000), color,
|
random.Next(1000, 3000), color,
|
||||||
@ -145,16 +155,17 @@ namespace Tank
|
|||||||
comboBoxStrategy.Enabled = true;
|
comboBoxStrategy.Enabled = true;
|
||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormTank_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSelectTank_Click(object sender, EventArgs e)
|
private void ButtonSelectTank_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectedTank = _Tank;
|
SelectedTank = _Tank;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
private void FormTank_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,11 +33,28 @@ namespace Tank.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="car">Добавляемый автомобиль</param>
|
/// <param name="car">Добавляемый автомобиль</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T tank)
|
public int Insert(T tank)
|
||||||
{
|
{
|
||||||
// вставка в начало набора
|
// вставка в начало набора
|
||||||
|
int index = -1;
|
||||||
return true;
|
for (int i = 0; i < _places.Length; i++)
|
||||||
|
{
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (int i = index; i > 0; i--)
|
||||||
|
{
|
||||||
|
_places[i] = _places[i - 1];
|
||||||
|
}
|
||||||
|
_places[0] = tank;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
@ -45,7 +62,7 @@ namespace Tank.Generics
|
|||||||
/// <param name="car">Добавляемый автомобиль</param>
|
/// <param name="car">Добавляемый автомобиль</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T tank, int position)
|
public int Insert(T tank, int position)
|
||||||
{
|
{
|
||||||
// проверка позиции
|
// проверка позиции
|
||||||
|
|
||||||
@ -54,9 +71,29 @@ namespace Tank.Generics
|
|||||||
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
||||||
|
|
||||||
// TODO вставка по позиции
|
// TODO вставка по позиции
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return -1;
|
||||||
|
if (_places[position] == null)
|
||||||
|
{
|
||||||
_places[position] = tank;
|
_places[position] = tank;
|
||||||
return true;
|
return position;
|
||||||
|
}
|
||||||
|
int index = -1;
|
||||||
|
for (int i = position; i < Count; i++)
|
||||||
|
{
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
index = i; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index < 0)
|
||||||
|
return -1;
|
||||||
|
for (int i = index; index > position; i--)
|
||||||
|
{
|
||||||
|
_places[i] = _places[i - 1];
|
||||||
|
}
|
||||||
|
_places[position] = tank;
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
@ -65,9 +102,12 @@ namespace Tank.Generics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
// проверка позиции
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_places[position] = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -29,11 +29,11 @@ namespace Tank.Generics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер занимаемого объектом места (ширина)
|
/// Размер занимаемого объектом места (ширина)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _placeSizeWidth = 100;
|
private readonly int _placeSizeWidth = 160;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер занимаемого объектом места (высота)
|
/// Размер занимаемого объектом места (высота)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _placeSizeHeight = 55;
|
private readonly int _placeSizeHeight = 65;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,15 +57,14 @@ namespace Tank.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator +(TanksGenericCollection<T, U> collect, T?
|
public static int operator +(TanksGenericCollection<T, U> collect, T?
|
||||||
obj)
|
obj)
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
return collect?._collection.Insert(obj) ?? false;
|
return collect._collection.Insert(obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
@ -73,15 +72,15 @@ namespace Tank.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? operator -(TanksGenericCollection<T, U> collect, int
|
public static bool operator -(TanksGenericCollection<T, U> collect, int
|
||||||
pos)
|
pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection.Get(pos);
|
T? obj = collect._collection.Get(pos);
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
collect._collection.Remove(pos);
|
return collect._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return obj;
|
return false;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject
|
/// Получение объекта IMoveableObject
|
||||||
@ -113,12 +112,11 @@ namespace Tank.Generics
|
|||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||||
1; ++j)
|
{ //разметка
|
||||||
{ //линия рамзетки места
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 40, j * _placeSizeHeight);
|
||||||
_placeSizeHeight);
|
|
||||||
}
|
}
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
@ -134,17 +132,13 @@ namespace Tank.Generics
|
|||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
for (int i = 0; i < _collection.Count; i++)
|
||||||
{
|
{
|
||||||
// получение объекта
|
|
||||||
DrawingArmoredCar? tank = _collection.Get(i);
|
DrawingArmoredCar? tank = _collection.Get(i);
|
||||||
if (tank == null)
|
if (tank != null)
|
||||||
{
|
{
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// установка позиции
|
|
||||||
tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
||||||
// прорисовка объекта
|
|
||||||
tank.DrawTransport(g);
|
tank.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user