From 3035239271f53b3998db22f434bd6bf9c0230cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=9C=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D1=84=D0=B5=D0=B5=D0=B2?= Date: Fri, 24 Nov 2023 12:12:46 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B05?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cruiser/Drawing/DrawingCruiser.cs | 14 +- Cruiser/Drawing/DrawingProCruiser.cs | 7 + Cruiser/Entities/EntityCruiser.cs | 4 +- Cruiser/Entities/EntityProCruiser.cs | 4 +- Cruiser/FormCruiserCollection.Designer.cs | 48 +-- Cruiser/FormCruiserCollection.cs | 37 +- Cruiser/FormCruiserConfig.Designer.cs | 379 ++++++++++++++++++ Cruiser/FormCruiserConfig.cs | 160 ++++++++ Cruiser/FormCruiserConfig.resx | 123 ++++++ Cruiser/Generics/CruisersGenericCollection.cs | 2 + 10 files changed, 727 insertions(+), 51 deletions(-) create mode 100644 Cruiser/FormCruiserConfig.Designer.cs create mode 100644 Cruiser/FormCruiserConfig.cs create mode 100644 Cruiser/FormCruiserConfig.resx diff --git a/Cruiser/Drawing/DrawingCruiser.cs b/Cruiser/Drawing/DrawingCruiser.cs index a479a79..fb3a7db 100644 --- a/Cruiser/Drawing/DrawingCruiser.cs +++ b/Cruiser/Drawing/DrawingCruiser.cs @@ -17,11 +17,11 @@ namespace Cruiser.Drawing /// /// Ширина окна /// - private int _pictureWidth; + public int _pictureWidth;// добавил для починки отрисовки на форме коллекций /// /// Высота окна /// - private int _pictureHeight; + public int _pictureHeight;// добавил для починки отрисовки на форме коллекций /// /// Левая координата прорисовки Крейсера /// @@ -118,6 +118,13 @@ namespace Cruiser.Drawing _startPosY = y; } /// + /// Установка цвета + /// + public void setBodyColor(Color color) + { + EntityCruiser.BodyColor = color; + } + /// /// Проверка, что объект может переместится по указанному направлению /// /// Направление @@ -170,9 +177,6 @@ namespace Cruiser.Drawing break; } } - - - /// /// Прорисовка объекта /// diff --git a/Cruiser/Drawing/DrawingProCruiser.cs b/Cruiser/Drawing/DrawingProCruiser.cs index 6ba87f2..6161167 100644 --- a/Cruiser/Drawing/DrawingProCruiser.cs +++ b/Cruiser/Drawing/DrawingProCruiser.cs @@ -9,6 +9,13 @@ namespace Cruiser.Drawing { public class DrawingProCruiser : DrawingCruiser { + /// + /// установка цвета про лайнера + /// + public void setElementColor(Color color) + { + (EntityCruiser as EntityProCruiser).ElementsColor = color; + } public DrawingProCruiser(int speed, double weight, Color bodyColor, Color secColor, Color elemColor, bool rocketMines, bool helipad, int width, int height) : base (speed, weight, bodyColor, secColor, width, height, 150, 60) { diff --git a/Cruiser/Entities/EntityCruiser.cs b/Cruiser/Entities/EntityCruiser.cs index 6e4dbd8..6aa3721 100644 --- a/Cruiser/Entities/EntityCruiser.cs +++ b/Cruiser/Entities/EntityCruiser.cs @@ -22,11 +22,11 @@ namespace Cruiser.Entities /// /// Основной цвет /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Второстепенный цвет /// - public Color SecondColor { get; private set; } + public Color SecondColor { get; set; } /// /// Шаг перемещения Крейсера /// diff --git a/Cruiser/Entities/EntityProCruiser.cs b/Cruiser/Entities/EntityProCruiser.cs index 6cd23d6..6d45247 100644 --- a/Cruiser/Entities/EntityProCruiser.cs +++ b/Cruiser/Entities/EntityProCruiser.cs @@ -11,7 +11,7 @@ namespace Cruiser.Entities /// /// Элементов цвет /// - public Color ElementsColor { get; private set; } + public Color ElementsColor { get; set; } /// /// Признак (опция) наличия ракетных шахт /// @@ -37,5 +37,5 @@ namespace Cruiser.Entities Helipad = helipad; ElementsColor = elemColor; } -} + } } diff --git a/Cruiser/FormCruiserCollection.Designer.cs b/Cruiser/FormCruiserCollection.Designer.cs index 6e1d956..a351f4b 100644 --- a/Cruiser/FormCruiserCollection.Designer.cs +++ b/Cruiser/FormCruiserCollection.Designer.cs @@ -29,10 +29,10 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); - buttonDeleteCruiser = new Button(); + button2 = new Button(); textBoxNumber = new TextBox(); buttonAddCruiser = new Button(); - buttonRefreshCollection = new Button(); + button3 = new Button(); pictureBoxCollection = new PictureBox(); groupBoxStorage = new GroupBox(); listBoxStorages = new ListBox(); @@ -46,7 +46,7 @@ // // groupBoxTools // - groupBoxTools.Controls.Add(buttonDeleteCruiser); + groupBoxTools.Controls.Add(button2); groupBoxTools.Controls.Add(textBoxNumber); groupBoxTools.Controls.Add(buttonAddCruiser); groupBoxTools.Location = new Point(653, 1); @@ -56,15 +56,15 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // - // buttonDeleteCruiser + // button2 // - buttonDeleteCruiser.Location = new Point(15, 95); - buttonDeleteCruiser.Name = "buttonDeleteCruiser"; - buttonDeleteCruiser.Size = new Size(122, 37); - buttonDeleteCruiser.TabIndex = 2; - buttonDeleteCruiser.Text = "Удалить лайнер"; - buttonDeleteCruiser.UseVisualStyleBackColor = true; - buttonDeleteCruiser.Click += ButtonRemoveCar_Click; + button2.Location = new Point(15, 95); + button2.Name = "button2"; + button2.Size = new Size(122, 37); + button2.TabIndex = 2; + button2.Text = "Удалить лайнер"; + button2.UseVisualStyleBackColor = true; + button2.Click += ButtonRemoveCar_Click; // // textBoxNumber // @@ -81,17 +81,17 @@ buttonAddCruiser.TabIndex = 0; buttonAddCruiser.Text = "Добавить лайнер"; buttonAddCruiser.UseVisualStyleBackColor = true; - buttonAddCruiser.Click += buttonAddCruiser_Click; + buttonAddCruiser.Click += ButtonAddCruiser_Click; // - // buttonRefreshCollection + // button3 // - buttonRefreshCollection.Location = new Point(662, 397); - buttonRefreshCollection.Name = "buttonRefreshCollection"; - buttonRefreshCollection.Size = new Size(131, 41); - buttonRefreshCollection.TabIndex = 3; - buttonRefreshCollection.Text = "Обновить коллекцию"; - buttonRefreshCollection.UseVisualStyleBackColor = true; - buttonRefreshCollection.Click += ButtonRefreshCollection_Click; + button3.Location = new Point(662, 397); + button3.Name = "button3"; + button3.Size = new Size(131, 41); + button3.TabIndex = 3; + button3.Text = "Обновить коллекцию"; + button3.UseVisualStyleBackColor = true; + button3.Click += ButtonRefreshCollection_Click; // // pictureBoxCollection // @@ -156,13 +156,12 @@ AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); - Controls.Add(buttonRefreshCollection); + Controls.Add(button3); Controls.Add(groupBoxStorage); Controls.Add(pictureBoxCollection); Controls.Add(groupBoxTools); Name = "FormCruiserCollection"; Text = "Набор Крейсеров"; - Load += FormCruiserCollection_Load; groupBoxTools.ResumeLayout(false); groupBoxTools.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); @@ -176,10 +175,11 @@ private GroupBox groupBoxTools; private TextBox textBoxNumber; private Button buttonAddCruiser; - private Button buttonRefreshCollection; - private Button buttonDeleteCruiser; + private Button button3; + private Button button2; private PictureBox pictureBoxCollection; private GroupBox groupBoxStorage; + private Button button1; private Button buttonDelObject; private TextBox textBoxStorageName; private Button buttonAddObject; diff --git a/Cruiser/FormCruiserCollection.cs b/Cruiser/FormCruiserCollection.cs index cf4bf6a..1dcff14 100644 --- a/Cruiser/FormCruiserCollection.cs +++ b/Cruiser/FormCruiserCollection.cs @@ -101,7 +101,7 @@ namespace Cruiser /// /// /// - private void buttonAddCruiser_Click(object sender, EventArgs e) + private void AddCruiser(DrawingCruiser cruiser) { if (listBoxStorages.SelectedIndex == -1) { @@ -112,18 +112,14 @@ namespace Cruiser { return; } - FormCruiser form = new(); - if (form.ShowDialog() == DialogResult.OK) + if ((obj + cruiser)) { - if (obj + form.SelectedCruiser) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowCruiser(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowCruiser(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } /// @@ -137,7 +133,8 @@ namespace Cruiser { return; } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? + string.Empty]; if (obj == null) { return; @@ -177,12 +174,16 @@ namespace Cruiser } pictureBoxCollection.Image = obj.ShowCruiser(); } - - - - private void FormCruiserCollection_Load(object sender, EventArgs e) + /// + /// Добавление объекта + /// + /// + /// + private void ButtonAddCruiser_Click(object sender, EventArgs e) { - + var formCruiserConfig = new FormCruiserConfig(); + formCruiserConfig.Show(); + formCruiserConfig.AddEvent(AddCruiser); } } } diff --git a/Cruiser/FormCruiserConfig.Designer.cs b/Cruiser/FormCruiserConfig.Designer.cs new file mode 100644 index 0000000..c457a8b --- /dev/null +++ b/Cruiser/FormCruiserConfig.Designer.cs @@ -0,0 +1,379 @@ +namespace Cruiser +{ + partial class FormCruiserConfig + { + /// + /// 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() + { + groupBoxForTools = new GroupBox(); + buttonCancel = new Button(); + buttonAddCruiser = new Button(); + labelDopColor = new Label(); + labelColor = new Label(); + panelToCruiser = new Panel(); + pictureBoxToCruiser = new PictureBox(); + labelProCruiser = new Label(); + labelCruiser = new Label(); + groupBoxColors = new GroupBox(); + panelColorGold = new Panel(); + panelColorCrimson = new Panel(); + panelColorPlum = new Panel(); + panelColorDodgerBlue = new Panel(); + panelColorAquamarine = new Panel(); + panelColorForestGreen = new Panel(); + panelColorSienna = new Panel(); + panelColorRed = new Panel(); + checkBoxHelipad = new CheckBox(); + checkBoxRockMines = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelWeight = new Label(); + labelSpeed = new Label(); + groupBoxForTools.SuspendLayout(); + panelToCruiser.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).BeginInit(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + SuspendLayout(); + // + // groupBoxForTools + // + groupBoxForTools.Controls.Add(buttonCancel); + groupBoxForTools.Controls.Add(buttonAddCruiser); + groupBoxForTools.Controls.Add(labelDopColor); + groupBoxForTools.Controls.Add(labelColor); + groupBoxForTools.Controls.Add(panelToCruiser); + groupBoxForTools.Controls.Add(labelProCruiser); + groupBoxForTools.Controls.Add(labelCruiser); + groupBoxForTools.Controls.Add(groupBoxColors); + groupBoxForTools.Controls.Add(checkBoxHelipad); + groupBoxForTools.Controls.Add(checkBoxRockMines); + groupBoxForTools.Controls.Add(numericUpDownWeight); + groupBoxForTools.Controls.Add(numericUpDownSpeed); + groupBoxForTools.Controls.Add(labelWeight); + groupBoxForTools.Controls.Add(labelSpeed); + groupBoxForTools.Location = new Point(15, 8); + groupBoxForTools.Name = "groupBoxForTools"; + groupBoxForTools.Size = new Size(641, 250); + groupBoxForTools.TabIndex = 0; + groupBoxForTools.TabStop = false; + groupBoxForTools.Text = "Tools"; + // + // buttonCancel + // + buttonCancel.Location = new Point(403, 208); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(206, 26); + buttonCancel.TabIndex = 14; + buttonCancel.Text = "Cancel"; + buttonCancel.UseVisualStyleBackColor = true; + // + // buttonAddCruiser + // + buttonAddCruiser.Location = new Point(403, 176); + buttonAddCruiser.Name = "buttonAddCruiser"; + buttonAddCruiser.Size = new Size(206, 26); + buttonAddCruiser.TabIndex = 13; + buttonAddCruiser.Text = "AddCruiser"; + buttonAddCruiser.UseVisualStyleBackColor = true; + buttonAddCruiser.Click += buttonAdd_Click; + // + // labelDopColor + // + labelDopColor.AllowDrop = true; + labelDopColor.BorderStyle = BorderStyle.FixedSingle; + labelDopColor.Location = new Point(509, 19); + labelDopColor.Name = "labelDopColor"; + labelDopColor.Size = new Size(100, 30); + labelDopColor.TabIndex = 12; + labelDopColor.Text = "DopColor"; + labelDopColor.TextAlign = ContentAlignment.MiddleCenter; + labelDopColor.DragDrop += labelColor_DragDrop; + labelDopColor.DragEnter += labelColor_DragEnter; + labelDopColor.MouseDown += LabelObject_MouseDown; + // + // labelColor + // + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(403, 19); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(100, 30); + labelColor.TabIndex = 11; + labelColor.Text = "Color"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += labelColor_DragDrop; + labelColor.DragEnter += labelColor_DragEnter; + labelColor.MouseDown += LabelObject_MouseDown; + // + // panelToCruiser + // + panelToCruiser.AllowDrop = true; + panelToCruiser.Controls.Add(pictureBoxToCruiser); + panelToCruiser.Location = new Point(403, 52); + panelToCruiser.Name = "panelToCruiser"; + panelToCruiser.Size = new Size(206, 118); + panelToCruiser.TabIndex = 10; + panelToCruiser.DragDrop += PanelObject_DragDrop; + panelToCruiser.DragEnter += PanelObject_DragEnter; + panelToCruiser.MouseDown += LabelObject_MouseDown; + // + // pictureBoxToCruiser + // + pictureBoxToCruiser.Location = new Point(3, 3); + pictureBoxToCruiser.Name = "pictureBoxToCruiser"; + pictureBoxToCruiser.Size = new Size(200, 112); + pictureBoxToCruiser.TabIndex = 9; + pictureBoxToCruiser.TabStop = false; + // + // labelProCruiser + // + labelProCruiser.AllowDrop = true; + labelProCruiser.BorderStyle = BorderStyle.FixedSingle; + labelProCruiser.Location = new Point(270, 155); + labelProCruiser.Name = "labelProCruiser"; + labelProCruiser.Size = new Size(100, 30); + labelProCruiser.TabIndex = 8; + labelProCruiser.Text = "ProCruiser"; + labelProCruiser.TextAlign = ContentAlignment.MiddleCenter; + labelProCruiser.MouseDown += LabelObject_MouseDown; + // + // labelCruiser + // + labelCruiser.AllowDrop = true; + labelCruiser.BorderStyle = BorderStyle.FixedSingle; + labelCruiser.Location = new Point(155, 155); + labelCruiser.Name = "labelCruiser"; + labelCruiser.Size = new Size(100, 30); + labelCruiser.TabIndex = 7; + labelCruiser.Text = "Cruiser"; + labelCruiser.TextAlign = ContentAlignment.MiddleCenter; + labelCruiser.MouseDown += LabelObject_MouseDown; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelColorGold); + groupBoxColors.Controls.Add(panelColorCrimson); + groupBoxColors.Controls.Add(panelColorPlum); + groupBoxColors.Controls.Add(panelColorDodgerBlue); + groupBoxColors.Controls.Add(panelColorAquamarine); + groupBoxColors.Controls.Add(panelColorForestGreen); + groupBoxColors.Controls.Add(panelColorSienna); + groupBoxColors.Controls.Add(panelColorRed); + groupBoxColors.Location = new Point(152, 19); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(224, 126); + groupBoxColors.TabIndex = 6; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Colors"; + // + // panelColorGold + // + panelColorGold.AllowDrop = true; + panelColorGold.BackColor = Color.Gold; + panelColorGold.Location = new Point(173, 76); + panelColorGold.Name = "panelColorGold"; + panelColorGold.Size = new Size(37, 35); + panelColorGold.TabIndex = 6; + panelColorGold.MouseDown += panelColor_MouseDown; + // + // panelColorCrimson + // + panelColorCrimson.AllowDrop = true; + panelColorCrimson.BackColor = Color.Crimson; + panelColorCrimson.Location = new Point(118, 76); + panelColorCrimson.Name = "panelColorCrimson"; + panelColorCrimson.Size = new Size(37, 35); + panelColorCrimson.TabIndex = 4; + panelColorCrimson.MouseDown += panelColor_MouseDown; + // + // panelColorPlum + // + panelColorPlum.AllowDrop = true; + panelColorPlum.BackColor = Color.Plum; + panelColorPlum.Location = new Point(66, 76); + panelColorPlum.Name = "panelColorPlum"; + panelColorPlum.Size = new Size(37, 35); + panelColorPlum.TabIndex = 5; + panelColorPlum.MouseDown += panelColor_MouseDown; + // + // panelColorDodgerBlue + // + panelColorDodgerBlue.AllowDrop = true; + panelColorDodgerBlue.BackColor = Color.DodgerBlue; + panelColorDodgerBlue.Location = new Point(12, 76); + panelColorDodgerBlue.Name = "panelColorDodgerBlue"; + panelColorDodgerBlue.Size = new Size(37, 35); + panelColorDodgerBlue.TabIndex = 3; + panelColorDodgerBlue.MouseDown += panelColor_MouseDown; + // + // panelColorAquamarine + // + panelColorAquamarine.AllowDrop = true; + panelColorAquamarine.BackColor = Color.Aquamarine; + panelColorAquamarine.Location = new Point(173, 23); + panelColorAquamarine.Name = "panelColorAquamarine"; + panelColorAquamarine.Size = new Size(37, 35); + panelColorAquamarine.TabIndex = 2; + panelColorAquamarine.MouseDown += panelColor_MouseDown; + // + // panelColorForestGreen + // + panelColorForestGreen.AllowDrop = true; + panelColorForestGreen.BackColor = Color.ForestGreen; + panelColorForestGreen.Location = new Point(118, 23); + panelColorForestGreen.Name = "panelColorForestGreen"; + panelColorForestGreen.Size = new Size(37, 35); + panelColorForestGreen.TabIndex = 1; + panelColorForestGreen.MouseDown += panelColor_MouseDown; + // + // panelColorSienna + // + panelColorSienna.AllowDrop = true; + panelColorSienna.BackColor = Color.Sienna; + panelColorSienna.Location = new Point(66, 23); + panelColorSienna.Name = "panelColorSienna"; + panelColorSienna.Size = new Size(37, 35); + panelColorSienna.TabIndex = 1; + panelColorSienna.MouseDown += panelColor_MouseDown; + // + // panelColorRed + // + panelColorRed.AllowDrop = true; + panelColorRed.BackColor = Color.Red; + panelColorRed.Location = new Point(12, 23); + panelColorRed.Name = "panelColorRed"; + panelColorRed.Size = new Size(37, 35); + panelColorRed.TabIndex = 0; + panelColorRed.MouseDown += panelColor_MouseDown; + // + // checkBoxHelipad + // + checkBoxHelipad.AutoSize = true; + checkBoxHelipad.Location = new Point(6, 161); + checkBoxHelipad.Name = "checkBoxHelipad"; + checkBoxHelipad.Size = new Size(67, 19); + checkBoxHelipad.TabIndex = 5; + checkBoxHelipad.Text = "Helipad"; + checkBoxHelipad.UseVisualStyleBackColor = true; + // + // checkBoxRockMines + // + checkBoxRockMines.AutoSize = true; + checkBoxRockMines.Location = new Point(6, 136); + checkBoxRockMines.Name = "checkBoxRockMines"; + checkBoxRockMines.Size = new Size(94, 19); + checkBoxRockMines.TabIndex = 4; + checkBoxRockMines.Text = "RocketMines"; + checkBoxRockMines.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(6, 95); + 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(120, 23); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(6, 37); + 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(120, 23); + numericUpDownSpeed.TabIndex = 2; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(6, 77); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(45, 15); + labelWeight.TabIndex = 1; + labelWeight.Text = "Weight"; + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(6, 19); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(39, 15); + labelSpeed.TabIndex = 0; + labelSpeed.Text = "Speed"; + // + // FormCruiserConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(684, 261); + Controls.Add(groupBoxForTools); + Name = "FormCruiserConfig"; + Text = "FormCruiserConfig"; + groupBoxForTools.ResumeLayout(false); + groupBoxForTools.PerformLayout(); + panelToCruiser.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).EndInit(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxForTools; + private Label labelWeight; + private Label labelSpeed; + private CheckBox checkBox3; + private CheckBox checkBox2; + private CheckBox checkBoxRockMines; + private CheckBox checkBoxHelipad; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private GroupBox groupBoxColors; + private Panel panelColorGold; + private Panel panelColorCrimson; + private Panel panelColorPlum; + private Panel panelColorDodgerBlue; + private Panel panelColorAquamarine; + private Panel panelColorForestGreen; + private Panel panelColorSienna; + private Panel panelColorRed; + private PictureBox pictureBoxToCruiser; + private Label labelProCruiser; + private Label labelCruiser; + private Panel panelToCruiser; + private Button buttonCancel; + private Button buttonAddCruiser; + private Label labelDopColor; + private Label labelColor; + } +} \ No newline at end of file diff --git a/Cruiser/FormCruiserConfig.cs b/Cruiser/FormCruiserConfig.cs new file mode 100644 index 0000000..2ba9277 --- /dev/null +++ b/Cruiser/FormCruiserConfig.cs @@ -0,0 +1,160 @@ +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; +using Cruiser.Drawing; + +namespace Cruiser +{ + public partial class FormCruiserConfig : Form + { + /// + /// Переменная-выбранная лайнера + /// + DrawingCruiser? _cruiser = null; + /// + /// Событие + /// + private event Action? EventAddCruiser; + /// + /// Конструктор + /// + public FormCruiserConfig() + { + InitializeComponent(); + panelColorRed.MouseDown += panelColor_MouseDown; + panelColorSienna.MouseDown += panelColor_MouseDown; + panelColorForestGreen.MouseDown += panelColor_MouseDown; + panelColorAquamarine.MouseDown += panelColor_MouseDown; + panelColorCrimson.MouseDown += panelColor_MouseDown; + panelColorDodgerBlue.MouseDown += panelColor_MouseDown; + panelColorGold.MouseDown += panelColor_MouseDown; + panelColorPlum.MouseDown += panelColor_MouseDown; + buttonCancel.Click += (s, e) => Close(); + } + /// + /// Отрисовать лайнер + /// + private void DrawCruiser() + { + Bitmap bmp = new(pictureBoxToCruiser.Width, pictureBoxToCruiser.Height); + Graphics gr = Graphics.FromImage(bmp); + _cruiser?.SetPosition(15, 15); + _cruiser?.DrawTransport(gr); + pictureBoxToCruiser.Image = bmp; + } + /// Добавление события + /// + /// Привязанный метод + public void AddEvent(Action ev) + { + if (EventAddCruiser == null) + { + EventAddCruiser = ev; + } + else + { + EventAddCruiser += ev; + } + } + /// + /// Добавление лайнера + /// + /// + /// + private void buttonAdd_Click(object sender, EventArgs e) + { + EventAddCruiser?.Invoke(_cruiser); + Close(); + } + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + /// + /// Действия при приеме перетаскиваемой информации + /// + /// + /// + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "labelCruiser": + _cruiser = new DrawingCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, + Color.Orchid, Color.Black, + pictureBoxToCruiser.Width, + pictureBoxToCruiser.Height); + break; + case "labelProCruiser": + _cruiser = new DrawingProCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, + Color.Orchid, Color.Black, Color.Aquamarine, + checkBoxRockMines.Checked, checkBoxHelipad.Checked, + pictureBoxToCruiser.Width, + pictureBoxToCruiser.Height); + break; + } + DrawCruiser(); + } + private void panelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void labelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void labelColor_DragDrop(object sender, DragEventArgs e) + { + if (_cruiser == null) + return; + switch (((Label)sender).Name) + { + case "labelColor": + _cruiser.setBodyColor((Color)e.Data.GetData(typeof(Color))); + break; + case "labelDopColor": + if (!(_cruiser is DrawingProCruiser)) + return; + (_cruiser as DrawingProCruiser).setElementColor((Color)e.Data.GetData(typeof(Color))); + break; + } + DrawCruiser(); + } + } +} diff --git a/Cruiser/FormCruiserConfig.resx b/Cruiser/FormCruiserConfig.resx new file mode 100644 index 0000000..39e2ec9 --- /dev/null +++ b/Cruiser/FormCruiserConfig.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + \ No newline at end of file diff --git a/Cruiser/Generics/CruisersGenericCollection.cs b/Cruiser/Generics/CruisersGenericCollection.cs index 945a6d2..9302b31 100644 --- a/Cruiser/Generics/CruisersGenericCollection.cs +++ b/Cruiser/Generics/CruisersGenericCollection.cs @@ -127,6 +127,8 @@ namespace Cruiser.Generics int i = 0; foreach (var cruiser in _collection.GetCruisers()) { + cruiser._pictureHeight = _pictureHeight;// добавил для починки отрисовки на форме коллекций + cruiser._pictureWidth = _pictureWidth;// добавил для починки отрисовки на форме коллекций _collection[i]?.SetPosition(Ix, Iy); _collection[i]?.DrawTransport(g); Ix += _placeSizeWidth;