diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..be9be73
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs
@@ -0,0 +1,90 @@
+using HoistingCrane.Drawning;
+using System;
+namespace HoistingCrane.CollectionGenericObjects
+{
+ public abstract class AbstractCompany
+ {
+ ///
+ /// Ширина ячейки гаража
+ ///
+ protected readonly int _placeSizeWidth = 150;
+ ///
+ /// Высота ячейки гаража
+ ///
+ protected readonly int _placeSizeHeight = 90;
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ protected readonly int pictureHeight;
+ ///
+ /// Коллекция автомобилей
+ ///
+ protected ICollectionGenericObjects? arr = null;
+ ///
+ /// Максимальное количество гаражей
+ ///
+ private int GetMaxCount
+ {
+ get
+ {
+ return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth);
+ }
+ }
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects array)
+ {
+ pictureWidth = picWidth;
+ pictureHeight = picHeight;
+ arr = array;
+ arr.SetMaxCount = GetMaxCount;
+ }
+
+ public static bool operator +(AbstractCompany company, DrawningTrackedVehicle car)
+ {
+ return company.arr?.Insert(car) ?? false;
+ }
+ public static bool operator -(AbstractCompany company, int position)
+ {
+ return company.arr?.Remove(position) ?? false;
+ }
+
+ public DrawningTrackedVehicle? GetRandomObject()
+ {
+ Random rnd = new();
+ return arr?.Get(rnd.Next(GetMaxCount));
+ }
+
+ ///
+ /// Вывод всей коллекции
+ ///
+ ///
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(pictureWidth, pictureHeight);
+ Graphics graphics = Graphics.FromImage(bitmap);
+ DrawBackgound(graphics);
+
+ SetObjectsPosition();
+ for (int i = 0; i < (arr?.Count ?? 0); i++)
+ {
+ DrawningTrackedVehicle? obj = arr?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/CarSharingService.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/CarSharingService.cs
new file mode 100644
index 0000000..44f0e37
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/CarSharingService.cs
@@ -0,0 +1,59 @@
+using HoistingCrane.Drawning;
+using System;
+
+namespace HoistingCrane.CollectionGenericObjects
+{
+ public class CarSharingService : AbstractCompany
+ {
+ public CarSharingService(int picWidth, int picHeight, ICollectionGenericObjects array) : base(picWidth, picHeight, array)
+ {
+ }
+
+
+ protected override void DrawBackgound(Graphics g)
+ {
+ int width = pictureWidth / _placeSizeWidth;
+ int height = pictureHeight / _placeSizeHeight;
+ Pen pen = new(Color.Black, 3);
+ for (int i = 0; i < width; i++)
+ {
+ for (int j = 0; j < height + 1; ++j)
+ {
+ g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15 + _placeSizeWidth - 55, j * _placeSizeHeight);
+ g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15, j * _placeSizeHeight - _placeSizeHeight);
+ }
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int countWidth = pictureWidth / _placeSizeWidth;
+ int countHeight = pictureHeight / _placeSizeHeight;
+
+ int currentPosWidth = 0;
+ int currentPosHeight = 0;
+
+ for (int i = 0; i < (arr?.Count ?? 0); i++)
+ {
+ if (arr?.Get(i) != null)
+ {
+ arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight);
+ arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, currentPosHeight * _placeSizeHeight + 15);
+ }
+
+ if (currentPosWidth < countWidth-1)
+ currentPosWidth++;
+ else
+ {
+ currentPosWidth = 0;
+ currentPosHeight++;
+ }
+ if (currentPosHeight > countHeight - 1)
+ {
+ break;
+ }
+
+ }
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
index 8930946..6187862 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -1,51 +1,36 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace HoistingCrane.CollectionGenericObjects
{
- internal interface ICollectionGenericObjects
- where T : class
+ public interface ICollectionGenericObjects
+ where T: class
{
///
- /// Колличество объектов в коллекции
+ /// Кол-во объектов в коллекции
///
int Count { get; }
-
///
- /// Максимальная вместимость коллекции("гаража")
+ /// Максимальное количество элементов
///
int SetMaxCount { set; }
-
///
- /// Добавление элемента в коллекцию на свободную позицию
+ /// Добавление элемента в коллекцию
///
- /// Добавляемый объект
+ ///
///
bool Insert(T obj);
-
///
- /// Добавление элемента в коллекцию на конкретное место
+ /// Добавление элемента в коллекцию на определенную позицию
///
- /// Добовляемый объект
- /// Позиция объекта
+ ///
+ ///
///
- bool Insert(T obj, int pos);
-
+ bool Insert(T obj, int position);
///
- /// Удаление конкретного элемента коллекции
+ /// Удаление элемента из коллекции по его позиции
///
- /// Номер позиции
+ ///
///
- bool Remove(int pos);
-
- ///
- /// Получение элемента коллекции по индексу
- ///
- /// Индекс элемента
- ///
- T? Get(int pos);
+ bool Remove(int position);
+ T? Get(int position);
}
}
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
index 36373be..81b86a9 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
@@ -1,101 +1,94 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace HoistingCrane.CollectionGenericObjects
{
- internal class MassivGenericObjects : ICollectionGenericObjects
- where T : class
+ public class MassivGenericObjects : ICollectionGenericObjects where T : class
{
- ///
- /// Создание массива типа
- ///
- private T[] array;
-
- ///
- /// Конструктор класса
- ///
+ private T?[] arr;
public MassivGenericObjects()
{
- array = Array.Empty();
+ arr = Array.Empty();
}
-
- ///
- /// Кол-во элементов массива
- ///
- public int Count => array.Length;
-
- public int SetMaxCount { set { if (value > 0) array = new T[value]; } }
-
- public T? Get(int pos)
+ public int Count
{
- return array[pos];
+ get { return arr.Length; }
+ }
+ public int SetMaxCount
+ {
+ set
+ {
+ if (value > 0)
+ {
+ arr = new T?[value];
+ }
+ }
+ }
+ public T? Get(int position)
+ {
+ if(position >= 0 && position < arr.Length)
+ {
+ return arr[position];
+ }
+ return null;
}
- ///
- /// Вставка элемента в свободную позицию(с начала)
- ///
- ///
- ///
public bool Insert(T obj)
{
for(int i = 0; i < Count; i++)
{
- if (array[i] == null) return true;
- }
- return false;
- }
- ///
- /// Вставка элемента в конкретную позицию
- ///
- ///
- ///
- ///
- ///
- public bool Insert(T obj, int pos)
- {
- bool flag = false;
- if (array[pos] == null)
- {
- array[pos] = obj;
- return true;
- }
- if (array[pos] != null)
- {
- for(int i = pos; i < Count; i++)
- {
- if (array[i] == null)
- {
- flag = true;
- array[i] = obj;
- return true;
- }
- }
- if(flag == false)
- {
- for(int i = pos; i > 0; i--)
- {
- if (array[i] == null)
- {
- array[i] = obj;
- return true;
- }
- }
+ if (arr[i] == null) {
+ arr[i] = obj;
+ return true;
}
}
return false;
}
- public bool Remove(int pos)
+ public bool Insert(T obj, int position)
{
- if (array[pos] != null)
+ // Проверка позиции
+ if (position < Count && position >= 0)
{
- return true;
+ if (arr[position] == null)
+ {
+ arr[position] = obj;
+ }
+ else
+ {
+ int flag = -1;
+ for (int i = position + 1; i < arr.Length; i++)
+ {
+ if (arr[i] == null)
+ {
+ flag = 1;
+ arr[i] = obj;
+ break;
+ }
+ }
+ if (flag == -1 && position != 0)
+ {
+ for (int i = position - 1; i >= 0; i--)
+ {
+ if (arr[i] == null)
+ {
+ arr[i] = obj;
+ break;
+ }
+ }
+ }
+ }
}
- return false;
+ return false;
+ }
+
+ public bool Remove(int position)
+ {
+ if(position < 0 || position >= arr.Length || arr[position] == null)
+ {
+ return false;
+ }
+ arr[position] = null;
+ return true;
}
}
}
diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs
new file mode 100644
index 0000000..60eb2d0
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs
@@ -0,0 +1,173 @@
+namespace HoistingCrane
+{
+ partial class FormCarCollection
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ groupBoxTools = new GroupBox();
+ buttonGoToChek = new Button();
+ buttonRefresh = new Button();
+ buttonDeleteCar = new Button();
+ maskedTextBox = new MaskedTextBox();
+ comboBoxSelectorCompany = new ComboBox();
+ buttonCreateTrackedVehicle = new Button();
+ buttonCreateHoistingCrane = new Button();
+ pictureBox = new PictureBox();
+ groupBoxTools.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ groupBoxTools.Controls.Add(buttonGoToChek);
+ groupBoxTools.Controls.Add(buttonRefresh);
+ groupBoxTools.Controls.Add(buttonDeleteCar);
+ groupBoxTools.Controls.Add(maskedTextBox);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Controls.Add(buttonCreateTrackedVehicle);
+ groupBoxTools.Controls.Add(buttonCreateHoistingCrane);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(716, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(210, 450);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonGoToChek
+ //
+ buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToChek.Location = new Point(12, 298);
+ buttonGoToChek.Name = "buttonGoToChek";
+ buttonGoToChek.Size = new Size(192, 34);
+ buttonGoToChek.TabIndex = 6;
+ buttonGoToChek.Text = "Передать на тесты";
+ buttonGoToChek.UseVisualStyleBackColor = true;
+ buttonGoToChek.Click += buttonGoToChek_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(12, 375);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(192, 34);
+ buttonRefresh.TabIndex = 5;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += buttonRefresh_Click;
+ //
+ // buttonDeleteCar
+ //
+ buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonDeleteCar.Location = new Point(12, 233);
+ buttonDeleteCar.Name = "buttonDeleteCar";
+ buttonDeleteCar.Size = new Size(192, 34);
+ buttonDeleteCar.TabIndex = 4;
+ buttonDeleteCar.Text = "Удалить автомобиль";
+ buttonDeleteCar.UseVisualStyleBackColor = true;
+ buttonDeleteCar.Click += buttonDeleteCar_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBox.Location = new Point(12, 204);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(192, 23);
+ maskedTextBox.TabIndex = 3;
+ //
+ // comboBoxSelectorCompany
+ //
+ comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSelectorCompany.FormattingEnabled = true;
+ comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
+ comboBoxSelectorCompany.Location = new Point(12, 28);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(192, 23);
+ comboBoxSelectorCompany.TabIndex = 2;
+ comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
+ //
+ // buttonCreateTrackedVehicle
+ //
+ buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonCreateTrackedVehicle.Location = new Point(12, 129);
+ buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
+ buttonCreateTrackedVehicle.Size = new Size(192, 34);
+ buttonCreateTrackedVehicle.TabIndex = 1;
+ buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину";
+ buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
+ buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
+ //
+ // buttonCreateHoistingCrane
+ //
+ buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonCreateHoistingCrane.Location = new Point(12, 89);
+ buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
+ buttonCreateHoistingCrane.Size = new Size(192, 34);
+ buttonCreateHoistingCrane.TabIndex = 0;
+ buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
+ buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
+ buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
+ //
+ // pictureBox
+ //
+ pictureBox.Dock = DockStyle.Fill;
+ pictureBox.Location = new Point(0, 0);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(716, 450);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormCarCollection
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(926, 450);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormCarCollection";
+ Text = "FormCarCollections";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonCreateHoistingCrane;
+ private Button buttonCreateTrackedVehicle;
+ private ComboBox comboBoxSelectorCompany;
+ private Button buttonRefresh;
+ private Button buttonDeleteCar;
+ private MaskedTextBox maskedTextBox;
+ private PictureBox pictureBox;
+ private Button buttonGoToChek;
+ }
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs
new file mode 100644
index 0000000..5c6c1ad
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs
@@ -0,0 +1,131 @@
+using HoistingCrane.CollectionGenericObjects;
+using HoistingCrane.Drawning;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HoistingCrane
+{
+ public partial class FormCarCollection : Form
+ {
+ private AbstractCompany? _company;
+ public FormCarCollection()
+ {
+ InitializeComponent();
+ }
+
+ private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new CarSharingService(pictureBox.Width, pictureBox.Height, new MassivGenericObjects());
+ break;
+ }
+ }
+
+
+ private void CreateObject(string type)
+ {
+ DrawningTrackedVehicle drawning;
+ if (_company == null) return;
+ Random rand = new();
+ switch (type)
+ {
+
+ case nameof(DrawningHoistingCrane):
+ drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true);
+ break;
+
+ case nameof(DrawningTrackedVehicle):
+ drawning = new DrawningTrackedVehicle(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand));
+ break;
+ default:
+ return;
+ }
+ if (_company + drawning)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+
+ private static Color GetColor(Random random)
+ {
+ 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;
+ }
+ return color;
+ }
+
+
+
+ private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane));
+
+
+ private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
+
+
+ private void buttonDeleteCar_Click(object sender, EventArgs e)
+ {
+
+ if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBox.Text);
+ if (_company - pos)
+ {
+ MessageBox.Show("Объект удален!");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void buttonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null) return;
+ pictureBox.Image = _company.Show();
+ }
+
+ private void buttonGoToChek_Click(object sender, EventArgs e)
+ {
+ if (_company == null) return;
+ DrawningTrackedVehicle? car = null;
+ int count = 100;
+ while (car == null)
+ {
+ car = _company.GetRandomObject();
+ count--;
+ if (count <= 0) break;
+ }
+ if (car == null) return;
+ FormHoistingCrane form = new()
+ {
+ SetCar = car
+ };
+ form.ShowDialog();
+
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.resx b/HoistingCrane/HoistingCrane/FormCarCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCarCollection.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
index a809bd5..e62154f 100644
--- a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
@@ -21,12 +21,10 @@ namespace HoistingCrane
private void InitializeComponent()
{
pictureBoxHoistingCrane = new PictureBox();
- buttonCreateHoistingCrane = new Button();
ButtonLeft = new Button();
ButtonRight = new Button();
ButtonUp = new Button();
ButtonDown = new Button();
- buttonCreateTrackedVehicle = new Button();
comboStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxHoistingCrane).BeginInit();
@@ -41,17 +39,6 @@ namespace HoistingCrane
pictureBoxHoistingCrane.TabIndex = 0;
pictureBoxHoistingCrane.TabStop = false;
//
- // buttonCreateHoistingCrane
- //
- buttonCreateHoistingCrane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateHoistingCrane.Location = new Point(0, 492);
- buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
- buttonCreateHoistingCrane.Size = new Size(188, 23);
- buttonCreateHoistingCrane.TabIndex = 1;
- buttonCreateHoistingCrane.Text = "Создать подъемный кран";
- buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
- buttonCreateHoistingCrane.Click += ButtonCreateHoistingCrane_Click;
- //
// ButtonLeft
//
ButtonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
@@ -100,17 +87,6 @@ namespace HoistingCrane
ButtonDown.UseVisualStyleBackColor = true;
ButtonDown.Click += ButtonMove_Click;
//
- // buttonCreateTrackedVehicle
- //
- buttonCreateTrackedVehicle.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateTrackedVehicle.Location = new Point(203, 492);
- buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
- buttonCreateTrackedVehicle.Size = new Size(194, 23);
- buttonCreateTrackedVehicle.TabIndex = 6;
- buttonCreateTrackedVehicle.Text = "Создать гусеничную машину";
- buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
- buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
- //
// comboStrategy
//
comboStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -138,12 +114,10 @@ namespace HoistingCrane
ClientSize = new Size(818, 515);
Controls.Add(buttonStrategyStep);
Controls.Add(comboStrategy);
- Controls.Add(buttonCreateTrackedVehicle);
Controls.Add(ButtonDown);
Controls.Add(ButtonUp);
Controls.Add(ButtonRight);
Controls.Add(ButtonLeft);
- Controls.Add(buttonCreateHoistingCrane);
Controls.Add(pictureBoxHoistingCrane);
Name = "FormHoistingCrane";
Text = "Подъемный кран";
@@ -154,12 +128,10 @@ namespace HoistingCrane
// #endregion
private PictureBox pictureBoxHoistingCrane;
- private Button buttonCreateHoistingCrane;
private Button ButtonLeft;
private Button ButtonRight;
private Button ButtonUp;
private Button ButtonDown;
- private Button buttonCreateTrackedVehicle;
private ComboBox comboStrategy;
private Button buttonStrategyStep;
}
diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
index a0f03af..540a335 100644
--- a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
@@ -13,6 +13,17 @@ namespace HoistingCrane
InitializeComponent();
_abstractStrategy = null;
}
+
+ public DrawningTrackedVehicle? SetCar
+ {
+ set
+ {
+ _drawning = value;
+ _drawning?.SetPictureSize(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ comboStrategy.Enabled = true;
+ Draw();
+ }
+ }
private void Draw()
{
@@ -22,55 +33,6 @@ namespace HoistingCrane
pictureBoxHoistingCrane.Image = bmp;
}
-
- ///
- /// Создать подъемный кран
- ///
- ///
- ///
- private void ButtonCreateHoistingCrane_Click(object sender, EventArgs e)
- {
- CreateObject(nameof(DrawningHoistingCrane));
- }
-
-
- ///
- /// Создать бронебойную машину
- ///
- ///
- ///
- private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e)
- {
- CreateObject(nameof(DrawningTrackedVehicle));
- }
-
-
- private void CreateObject(string type)
- {
- Random rand = new();
- switch (type)
- {
-
- case nameof(DrawningHoistingCrane):
- _drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)),
- Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)), true, true);
- break;
-
- case nameof(DrawningTrackedVehicle):
- _drawning = new DrawningTrackedVehicle(rand.Next(100, 300), rand.Next(1000, 3000), Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)));
- break;
- default:
- return;
-
- }
- _drawning.SetPictureSize(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
- _drawning.SetPosition(rand.Next(0, 100), rand.Next(0, 100));
-
- comboStrategy.Enabled = true;
- Draw();
- }
-
-
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawning == null) { return; }
diff --git a/HoistingCrane/HoistingCrane/HoistingCrane.csproj b/HoistingCrane/HoistingCrane/HoistingCrane.csproj
index 244387d..69ac652 100644
--- a/HoistingCrane/HoistingCrane/HoistingCrane.csproj
+++ b/HoistingCrane/HoistingCrane/HoistingCrane.csproj
@@ -8,6 +8,10 @@
enable
+
+
+
+
True
diff --git a/HoistingCrane/HoistingCrane/Program.cs b/HoistingCrane/HoistingCrane/Program.cs
index fbb985e..79d96ff 100644
--- a/HoistingCrane/HoistingCrane/Program.cs
+++ b/HoistingCrane/HoistingCrane/Program.cs
@@ -11,7 +11,8 @@ namespace HoistingCrane
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormHoistingCrane());
+ Application.Run(new FormCarCollection());
+
}
}
}
\ No newline at end of file
diff --git a/Безымянный.png b/Безымянный.png
new file mode 100644
index 0000000..148b1a6
Binary files /dev/null and b/Безымянный.png differ