From 89fa02c63f29a47f1628e968b098c14c4afea2ff Mon Sep 17 00:00:00 2001 From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com> Date: Sun, 19 May 2024 19:38:24 +0400 Subject: [PATCH 1/4] LabWork_2 # Conflicts: # ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs # ProjectTank/ProjectTank/Entities/EntityTank.cs # ProjectTank/ProjectTank/FormBattleTank.cs # ProjectTank/ProjectTank/MovementStrategy/MoveableTank.cs --- .../Drawning/DrawningBattleTank.cs | 9 +++++++ ProjectTank/ProjectTank/FormBattleTank.cs | 25 ++----------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs index 289bdec..48e29ba 100644 --- a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs +++ b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs @@ -1,3 +1,8 @@ +<<<<<<< HEAD +======= +using ProjectTank.Entities; + +>>>>>>> 6b2dbf2 (LabWork_2) namespace ProjectTank.Drawning; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -8,7 +13,11 @@ public class DrawningBattleTank :DrawningTank /// Конструктор /// /// Скорость +<<<<<<< HEAD /// Вес +======= + /// Вес автомобиля +>>>>>>> 6b2dbf2 (LabWork_2) /// Основной цвет /// Дополнительный цвет /// Признак наличия пушки diff --git a/ProjectTank/ProjectTank/FormBattleTank.cs b/ProjectTank/ProjectTank/FormBattleTank.cs index dbc70e9..be2a6aa 100644 --- a/ProjectTank/ProjectTank/FormBattleTank.cs +++ b/ProjectTank/ProjectTank/FormBattleTank.cs @@ -1,9 +1,7 @@ using ProjectTank.Drawning; - +using ProjectTank.Entities; using ProjectTank.MovementStrategy; - - namespace ProjectTank { /// @@ -15,25 +13,11 @@ namespace ProjectTank /// Поле-объект для прорисовки объекта /// private DrawningTank? _drawningTank; - /// /// Стратегия перемещения /// private AbstractStrategy? _strategy; - - - public DrawningTank SetTank - { - set - { - _drawningTank = value; - _drawningTank.SetPictureSize(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height); - СomboBoxStrategy.Enabled = true; - _strategy = null; - Draw(); - } - } /// /// Конструктор формы /// @@ -41,11 +25,9 @@ namespace ProjectTank { InitializeComponent(); _strategy = null; - _strategy = null; } /// /// Метод прорисовки танка - /// Метод прорисовки танка /// private void Draw() { @@ -58,7 +40,6 @@ namespace ProjectTank _drawningTank.DrawTransport(gr); pictureBoxBattleTank.Image = bmp; } - /// /// Создание объекта класса-перемещения /// @@ -93,6 +74,7 @@ namespace ProjectTank /// /// /// + private void ButtonCreateButtleTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningBattleTank)); private void ButtonCreateTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningTank)); @@ -169,8 +151,5 @@ namespace ProjectTank } } - - - } } -- 2.25.1 From 9855506d43913342216319f7a2b90991362ed216 Mon Sep 17 00:00:00 2001 From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com> Date: Sun, 19 May 2024 19:39:07 +0400 Subject: [PATCH 2/4] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=E2=84=964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Conflicts: # ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs # ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs --- .../ProjectTank/CollectionGenericObjects/CollectionType.cs | 2 +- .../ProjectTank/CollectionGenericObjects/StorageCollection.cs | 2 +- ProjectTank/ProjectTank/FormBattleTankCollection.cs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs index f4bf31f..35061b2 100644 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs +++ b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs @@ -1,4 +1,4 @@ -namespace ProjectTank.CollectionGenericObjects; +namespace ProjectTank.CollectionGenericObjects; public enum CollectionType { diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs index 6b0bc15..e172f1b 100644 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs @@ -1,4 +1,4 @@ - + namespace ProjectTank.CollectionGenericObjects { public class StorageCollection diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.cs index 7bb8eaf..07e5a4e 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.cs @@ -1,4 +1,5 @@ -using ProjectTank.CollectionGenericObjects; +using ProjectLinkor.CollectionGenericObjects; +using ProjectTank.CollectionGenericObjects; using ProjectTank.Drawning; namespace ProjectTank -- 2.25.1 From 40e23830ff3ca21e7e632d3956d4e393928551f0 Mon Sep 17 00:00:00 2001 From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com> Date: Sun, 21 Apr 2024 00:12:09 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=204=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassiveGenericObjects.cs | 17 ++++++++++++++++- .../FormBattleTankCollection.Designer.cs | 2 +- .../ProjectTank/FormBattleTankCollection.cs | 17 +++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/MassiveGenericObjects.cs index f4fef06..022bd14 100644 --- a/ProjectTank/ProjectTank/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectTank/ProjectTank/CollectionGenericObjects/MassiveGenericObjects.cs @@ -13,7 +13,22 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + public int SetMaxCount { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } /// /// Конструктор diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs index 073fc60..82025f1 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs @@ -153,7 +153,7 @@ buttonCreateCompany.TabIndex = 7; buttonCreateCompany.Text = "Создать компанию"; buttonCreateCompany.UseVisualStyleBackColor = true; - buttonCreateCompany.Click += buttonCreateCompany_Click; + buttonCreateCompany.Click += ButtonCreateCompany_Click; // // panelStorage // diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.cs index 07e5a4e..c2a18ab 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.cs @@ -156,10 +156,10 @@ namespace ProjectTank { if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) { - MessageBox.Show("Не все данные заполнены", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + CollectionType collectionType = CollectionType.None; if (radioButtonMassive.Checked) { @@ -169,6 +169,7 @@ namespace ProjectTank { collectionType = CollectionType.List; } + _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); RerfreshListBoxItems(); } @@ -206,37 +207,37 @@ namespace ProjectTank listBoxСollection.Items.Add(colName); } } + } /// /// Создание компании /// /// /// - private void buttonCreateCompany_Click(object sender, EventArgs e) + private void ButtonCreateCompany_Click(object sender, EventArgs e) { - if (listBoxСollection.SelectedIndex < 0 || listBoxСollection.SelectedItems == null) + if (listBoxСollection.SelectedIndex < 0 || listBoxСollection.SelectedItem == null) { MessageBox.Show("Коллекция не выбрана"); return; } ICollectionGenericObjects? collection = _storageCollection[listBoxСollection.SelectedItem.ToString() ?? string.Empty]; - if (collection == null) { MessageBox.Show("Коллекция не проинициализирована"); return; } + switch (comboBoxSelectorCompany.Text) { case "Хранилище": - _company = new TankBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + _company = new TankBase(pictureBox.Width, pictureBox.Height, collection); break; } + panelCompanyTools.Enabled = true; RerfreshListBoxItems(); } - - } } -- 2.25.1 From c055849b1214c7e33a459ece712e6e10c59b526e Mon Sep 17 00:00:00 2001 From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:27:28 +0400 Subject: [PATCH 4/4] =?UTF-8?q?labWork=5F5=20=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawning/DrawningBattleTank.cs | 8 - .../ProjectTank/Entities/EntityTank.cs | 4 + .../ProjectTank/Entities/EntiyBattleTank.cs | 5 + ProjectTank/ProjectTank/FormBattleTank.cs | 12 + .../FormBattleTankCollection.Designer.cs | 14 - .../ProjectTank/FormBattleTankCollection.cs | 78 ++-- .../ProjectTank/FormTankConfig.Designer.cs | 357 ++++++++++++++++++ ProjectTank/ProjectTank/FormTankConfig.cs | 170 +++++++++ ProjectTank/ProjectTank/FormTankConfig.resx | 120 ++++++ ProjectTank/ProjectTank/TankDelegate.cs | 5 + git | 0 11 files changed, 704 insertions(+), 69 deletions(-) create mode 100644 ProjectTank/ProjectTank/FormTankConfig.Designer.cs create mode 100644 ProjectTank/ProjectTank/FormTankConfig.cs create mode 100644 ProjectTank/ProjectTank/FormTankConfig.resx create mode 100644 ProjectTank/ProjectTank/TankDelegate.cs create mode 100644 git diff --git a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs index 48e29ba..b7525e7 100644 --- a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs +++ b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs @@ -1,8 +1,4 @@ -<<<<<<< HEAD -======= -using ProjectTank.Entities; ->>>>>>> 6b2dbf2 (LabWork_2) namespace ProjectTank.Drawning; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -13,11 +9,7 @@ public class DrawningBattleTank :DrawningTank /// Конструктор /// /// Скорость -<<<<<<< HEAD /// Вес -======= - /// Вес автомобиля ->>>>>>> 6b2dbf2 (LabWork_2) /// Основной цвет /// Дополнительный цвет /// Признак наличия пушки diff --git a/ProjectTank/ProjectTank/Entities/EntityTank.cs b/ProjectTank/ProjectTank/Entities/EntityTank.cs index e7d86c5..a1b9484 100644 --- a/ProjectTank/ProjectTank/Entities/EntityTank.cs +++ b/ProjectTank/ProjectTank/Entities/EntityTank.cs @@ -22,6 +22,10 @@ namespace ProjectTank.Entities /// Шаг перемещения танка /// public double Step => Speed * 100 / Weight; + public void SetBodyColor(Color color) + { + BodyColor = color; + } /// /// Конструктор сущности diff --git a/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs b/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs index 0a39d87..9b82b31 100644 --- a/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs +++ b/ProjectTank/ProjectTank/Entities/EntiyBattleTank.cs @@ -24,6 +24,11 @@ namespace ProjectTank /// /// public bool MachinGun { get; private set; } + public void SetAdditionalColor(Color addColor) + { + AdditionalColor = addColor; + } + /// /// Конструктор объекта-класса Боевого Танка /// diff --git a/ProjectTank/ProjectTank/FormBattleTank.cs b/ProjectTank/ProjectTank/FormBattleTank.cs index be2a6aa..b14c0b1 100644 --- a/ProjectTank/ProjectTank/FormBattleTank.cs +++ b/ProjectTank/ProjectTank/FormBattleTank.cs @@ -21,6 +21,18 @@ namespace ProjectTank /// /// Конструктор формы /// + + public DrawningTank SetTank + { + set + { + _drawningTank = value; + _drawningTank.SetPictureSize(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height); + СomboBoxStrategy.Enabled = true; + _strategy = null; + Draw(); + } + } public FormBattleTank() { InitializeComponent(); diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs index 82025f1..67ca06b 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs @@ -31,7 +31,6 @@ groupBoxTools = new GroupBox(); panelCompanyTools = new Panel(); buttonAddTank = new Button(); - buttonAddBattleTank = new Button(); maskedTextBox = new MaskedTextBox(); buttonRefresh = new Button(); buttonRemoveTank = new Button(); @@ -70,7 +69,6 @@ // panelCompanyTools // panelCompanyTools.Controls.Add(buttonAddTank); - panelCompanyTools.Controls.Add(buttonAddBattleTank); panelCompanyTools.Controls.Add(maskedTextBox); panelCompanyTools.Controls.Add(buttonRefresh); panelCompanyTools.Controls.Add(buttonRemoveTank); @@ -92,17 +90,6 @@ buttonAddTank.UseVisualStyleBackColor = true; buttonAddTank.Click += ButtonAddTank_Click; // - // buttonAddBattleTank - // - buttonAddBattleTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddBattleTank.Location = new Point(6, 44); - buttonAddBattleTank.Name = "buttonAddBattleTank"; - buttonAddBattleTank.Size = new Size(169, 35); - buttonAddBattleTank.TabIndex = 2; - buttonAddBattleTank.Text = "Добавление боевого танка"; - buttonAddBattleTank.UseVisualStyleBackColor = true; - buttonAddBattleTank.Click += ButtonAddBattleTank_Click; - // // maskedTextBox // maskedTextBox.Location = new Point(6, 85); @@ -280,7 +267,6 @@ private GroupBox groupBoxTools; private ComboBox comboBoxSelectorCompany; - private Button buttonAddBattleTank; private Button buttonAddTank; private MaskedTextBox maskedTextBox; private PictureBox pictureBox; diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.cs index c2a18ab..265cbfe 100644 --- a/ProjectTank/ProjectTank/FormBattleTankCollection.cs +++ b/ProjectTank/ProjectTank/FormBattleTankCollection.cs @@ -1,5 +1,4 @@ -using ProjectLinkor.CollectionGenericObjects; -using ProjectTank.CollectionGenericObjects; +using ProjectTank.CollectionGenericObjects; using ProjectTank.Drawning; namespace ProjectTank @@ -41,27 +40,12 @@ namespace ProjectTank /// Создание объекта класса-перемещения /// /// Тип создоваемого объекта - private void CreateObject(string type) + private void SetTank(DrawningTank tank) { - if (_company == null) return; + if (_company == null || tank == null) + return; - Random random = new(); - DrawningTank drawningTank; - switch (type) - { - case nameof(DrawningTank): - drawningTank = new DrawningTank(random.Next(100, 300), random.Next(1000, 3000), - GetColor(random)); - break; - case nameof(DrawningBattleTank): - bool randomTrack = Convert.ToBoolean(random.Next(0, 2)); - drawningTank = new DrawningBattleTank(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), randomTrack, (randomTrack ? Convert.ToBoolean(random.Next(0, 2)) : true)); - break; - default: - return; - } - - if (_company + drawningTank != -1) + if (_company + tank != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -73,33 +57,25 @@ namespace ProjectTank } /// - /// Получение цвета + /// добавление танка /// - /// Генератор случайных чесел - /// - 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 ColorDialog(); - - if (dialog.ShowDialog() == DialogResult.OK) - { - color = dialog.Color; - } - - return color; - } - + /// + /// private void ButtonAddTank_Click(object sender, EventArgs e) { - CreateObject(nameof(DrawningTank)); + if (_company == null) + { + return; + } + FormTankConfig form = new(); + form.AddEvent(SetTank); + form.Show(); } - - private void ButtonAddBattleTank_Click(object sender, EventArgs e) - { - CreateObject(nameof(DrawningBattleTank)); - } - + /// + /// Удаление танка + /// + /// + /// private void buttonRemoveTank_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) return; @@ -118,7 +94,11 @@ namespace ProjectTank MessageBox.Show("Не удалось удалить объект"); } } - + /// + /// передать на тесты + /// + /// + /// private void ButtonGoToCheck_Click(object sender, EventArgs e) { if (_company == null) return; @@ -141,7 +121,11 @@ namespace ProjectTank }; form.ShowDialog(); } - + /// + /// обновление + /// + /// + /// private void ButtonRefresh_Click(object sender, EventArgs e) { if (_company == null) return; @@ -175,7 +159,7 @@ namespace ProjectTank } /// - /// + /// Удвление коллекции /// /// /// diff --git a/ProjectTank/ProjectTank/FormTankConfig.Designer.cs b/ProjectTank/ProjectTank/FormTankConfig.Designer.cs new file mode 100644 index 0000000..2972f6b --- /dev/null +++ b/ProjectTank/ProjectTank/FormTankConfig.Designer.cs @@ -0,0 +1,357 @@ +namespace ProjectTank +{ + partial class FormTankConfig + { + /// + /// 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() + { + groupBoxConfig = new GroupBox(); + groupBoxColors = new GroupBox(); + panelPurple = new Panel(); + panelYellow = new Panel(); + panelBlack = new Panel(); + panelGray = new Panel(); + panelBlue = new Panel(); + panelWhite = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxMachineGun = new CheckBox(); + checkBoxGun = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelWeight = new Label(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + panelObject = new Panel(); + labelAdditionalColor = new Label(); + labelBodyColor = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + groupBoxConfig.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + panelObject.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + SuspendLayout(); + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColors); + groupBoxConfig.Controls.Add(checkBoxMachineGun); + groupBoxConfig.Controls.Add(checkBoxGun); + groupBoxConfig.Controls.Add(numericUpDownWeight); + groupBoxConfig.Controls.Add(numericUpDownSpeed); + groupBoxConfig.Controls.Add(labelWeight); + groupBoxConfig.Controls.Add(labelSpeed); + groupBoxConfig.Controls.Add(labelModifiedObject); + groupBoxConfig.Controls.Add(labelSimpleObject); + groupBoxConfig.Dock = DockStyle.Left; + groupBoxConfig.Location = new Point(0, 0); + groupBoxConfig.Name = "groupBoxConfig"; + groupBoxConfig.Size = new Size(574, 219); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelBlack); + groupBoxColors.Controls.Add(panelGray); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelWhite); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Location = new Point(315, 12); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(227, 112); + groupBoxColors.TabIndex = 10; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(176, 66); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(34, 34); + panelPurple.TabIndex = 3; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(176, 22); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(34, 34); + panelYellow.TabIndex = 1; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(120, 66); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(34, 34); + panelBlack.TabIndex = 4; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(67, 66); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(34, 34); + panelGray.TabIndex = 5; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(120, 22); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(34, 34); + panelBlue.TabIndex = 1; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(15, 66); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(34, 34); + panelWhite.TabIndex = 2; + // + // panelGreen + // + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(67, 22); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(34, 34); + panelGreen.TabIndex = 1; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(15, 22); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(34, 34); + panelRed.TabIndex = 0; + // + // checkBoxMachineGun + // + checkBoxMachineGun.AutoSize = true; + checkBoxMachineGun.Location = new Point(12, 168); + checkBoxMachineGun.Name = "checkBoxMachineGun"; + checkBoxMachineGun.Size = new Size(178, 19); + checkBoxMachineGun.TabIndex = 9; + checkBoxMachineGun.Text = "Признак наличия пулемета"; + checkBoxMachineGun.UseVisualStyleBackColor = true; + // + // checkBoxGun + // + checkBoxGun.AutoSize = true; + checkBoxGun.Location = new Point(12, 125); + checkBoxGun.Name = "checkBoxGun"; + checkBoxGun.Size = new Size(163, 19); + checkBoxGun.TabIndex = 8; + checkBoxGun.Text = "Признак наличия пушки"; + checkBoxGun.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(80, 65); + numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownWeight.Name = "numericUpDownWeight"; + numericUpDownWeight.Size = new Size(96, 23); + numericUpDownWeight.TabIndex = 7; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(80, 36); + numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownSpeed.Name = "numericUpDownSpeed"; + numericUpDownSpeed.Size = new Size(96, 23); + numericUpDownSpeed.TabIndex = 6; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(12, 73); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(29, 15); + labelWeight.TabIndex = 5; + labelWeight.Text = "Вес:"; + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(12, 38); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(62, 15); + labelSpeed.TabIndex = 3; + labelSpeed.Text = "Скорость:"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(442, 160); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(100, 33); + labelModifiedObject.TabIndex = 2; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += LabelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(315, 160); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(100, 33); + labelSimpleObject.TabIndex = 1; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAdditionalColor); + panelObject.Controls.Add(labelBodyColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(594, 0); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(194, 164); + panelObject.TabIndex = 5; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(108, 9); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(75, 33); + labelAdditionalColor.TabIndex = 3; + labelAdditionalColor.Text = "Доп. цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter; + // + // labelBodyColor + // + labelBodyColor.AllowDrop = true; + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Location = new Point(13, 9); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(75, 33); + labelBodyColor.TabIndex = 2; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragDrop += labelBodyColor_DragDrop; + labelBodyColor.DragEnter += labelBodyColor_DragEnter; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(13, 52); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(170, 99); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(607, 184); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 23); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(702, 184); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormTankConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 219); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(panelObject); + Controls.Add(groupBoxConfig); + Name = "FormTankConfig"; + Text = "Создание объекта"; + groupBoxConfig.ResumeLayout(false); + groupBoxConfig.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + panelObject.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxConfig; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelWeight; + private Label labelSpeed; + private Label labelModifiedObject; + private Label labelSimpleObject; + private CheckBox checkBoxGun; + private CheckBox checkBoxMachineGun; + private GroupBox groupBoxColors; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlack; + private Panel panelGray; + private Panel panelBlue; + private Panel panelWhite; + private Panel panelGreen; + private Panel panelRed; + private Panel panelObject; + private Label labelAdditionalColor; + private Label labelBodyColor; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectTank/ProjectTank/FormTankConfig.cs b/ProjectTank/ProjectTank/FormTankConfig.cs new file mode 100644 index 0000000..33f94ea --- /dev/null +++ b/ProjectTank/ProjectTank/FormTankConfig.cs @@ -0,0 +1,170 @@ +using ProjectTank.Drawning; + +namespace ProjectTank; + +public partial class FormTankConfig : Form +{ + /// + /// Объект - прорисовка автомобиля + /// + private DrawningTank? _tank = null; + + /// + /// Событие для передачи объекта + /// + private event Action? _TankDelegate; + + /// + /// Конструктор + /// + public FormTankConfig() + { + InitializeComponent(); + + panelRed.MouseDown += Panel_MouseDown; + panelGreen.MouseDown += Panel_MouseDown; + panelBlue.MouseDown += Panel_MouseDown; + panelYellow.MouseDown += Panel_MouseDown; + panelWhite.MouseDown += Panel_MouseDown; + panelGray.MouseDown += Panel_MouseDown; + panelBlack.MouseDown += Panel_MouseDown; + panelPurple.MouseDown += Panel_MouseDown; + + buttonCancel.Click += (sender, e) => Close(); + } + + /// + /// Привязка внешнего метода к событию + /// + /// + public void AddEvent(Action TankDelegate) + { + _TankDelegate += TankDelegate; + } + + /// + /// Прорисовка объекта + /// + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _tank?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + _tank?.SetPosition(15, 15); + _tank?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy); + } + + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None; + } + + /// + /// Действия при приеме перетаскиваемой информации + /// + /// + /// + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "labelSimpleObject": + _tank = new DrawningTank((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _tank = new DrawningBattleTank((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, + Color.Black, checkBoxGun.Checked, checkBoxMachineGun.Checked); + break; + } + labelBodyColor.BackColor = Color.Empty; + labelAdditionalColor.BackColor = Color.Empty; + DrawObject(); + } + + /// + /// Передаем информацию при нажатии на Panel + /// + /// + /// + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + + (sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy); + } + + + private void labelBodyColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void labelBodyColor_DragDrop(object sender, DragEventArgs e) + { + if (_tank != null) + { + _tank.EntityTank.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + + private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_tank is DrawningBattleTank) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } + + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_tank?.EntityTank is EntityBattleTank _battletank) + { + _battletank.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + + } + /// + /// Передача объекта + /// + /// + /// + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (_tank != null) + { + _TankDelegate?.Invoke(_tank); + Close(); + } + } +} diff --git a/ProjectTank/ProjectTank/FormTankConfig.resx b/ProjectTank/ProjectTank/FormTankConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTank/ProjectTank/FormTankConfig.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/ProjectTank/ProjectTank/TankDelegate.cs b/ProjectTank/ProjectTank/TankDelegate.cs new file mode 100644 index 0000000..51d9f2e --- /dev/null +++ b/ProjectTank/ProjectTank/TankDelegate.cs @@ -0,0 +1,5 @@ +using ProjectTank.Drawning; + +namespace ProjectTank; + +public delegate void TankDelegate(DrawningTank tank); diff --git a/git b/git new file mode 100644 index 0000000..e69de29 -- 2.25.1