diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs index dc81bc1..4a772c4 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs @@ -10,12 +10,12 @@ public class ListGenericObjects : ICollectionGenericObjects /// /// Список объектов, которые храним /// - private readonly List _collection; + private readonly Dictionary _collection; /// /// Максимально допустимое число объектов в списке /// private int _maxCount; - public int Count => _collection.Count; + public int Count => _collection.Keys.Count; public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } /// /// Конструктор @@ -31,22 +31,21 @@ public class ListGenericObjects : ICollectionGenericObjects } public int Insert(T obj) { - if (Count + 1 > _maxCount) return -1; - _collection.Add(obj); + if (Count > _maxCount) return -1; + _collection[Count-1] = obj; return Count; } public int Insert(T obj, int position) { - if (Count + 1 > _maxCount) return -1; - if (position < 0 || position > Count) return -1; - _collection.Insert(position, obj); + if (Count > _maxCount) return -1; + _collection[position] = obj; return 1; } public T? Remove(int position) { - if (position < 0 || position > Count) return null; + if (_collection.ContainsKey(position)) return null; T? temp = _collection[position]; - _collection.RemoveAt(position); + _collection.Remove(position); return temp; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CommonLinerDelegate.cs b/ProjectLiner/ProjectLiner/CommonLinerDelegate.cs new file mode 100644 index 0000000..96998f9 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CommonLinerDelegate.cs @@ -0,0 +1,13 @@ +using ProjectLiner.Drawnings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner; +/// +/// Делегат передачи объекта класса-прорисовки +/// +/// +public delegate void CommonLinerDelegate(DrawningCommonLiner liner); diff --git a/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs index bb99401..d246314 100644 --- a/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs +++ b/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs @@ -46,5 +46,14 @@ namespace ProjectLiner.Entities BodyColor = bodyColor; } + + /// + /// Метод передачи основного цвета + /// + /// + public void SetBodyColor(Color bodyColor) + { + BodyColor = bodyColor; + } } } diff --git a/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs index 18a65d3..b2308db 100644 --- a/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs +++ b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs @@ -42,4 +42,13 @@ public class EntityLiner: EntityCommonLiner Boats = boats; Pipe = pipe; } + + /// + /// Метод передачи дополнительного цвета + /// + /// + public void SetAdditionalColor(Color additionalColor) + { + AdditionalColor = additionalColor; + } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs index 50e79a9..ed95089 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs @@ -41,12 +41,11 @@ comboBoxSelectorCompany = new ComboBox(); pictureBox = new PictureBox(); panelCompanyTools = new Panel(); - button1 = new Button(); - button2 = new Button(); + buttonAddLiner = new Button(); maskedTextBox1 = new MaskedTextBox(); + button5 = new Button(); button3 = new Button(); button4 = new Button(); - button5 = new Button(); groupBoxTools.SuspendLayout(); panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); @@ -59,11 +58,9 @@ groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(681, 0); - groupBoxTools.Margin = new Padding(2); + groupBoxTools.Location = new Point(1052, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Padding = new Padding(2); - groupBoxTools.Size = new Size(176, 648); + groupBoxTools.Size = new Size(272, 1063); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -71,9 +68,10 @@ // buttonCreateCompany // buttonCreateCompany.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); - buttonCreateCompany.Location = new Point(5, 317); + buttonCreateCompany.Location = new Point(8, 520); + buttonCreateCompany.Margin = new Padding(5); buttonCreateCompany.Name = "buttonCreateCompany"; - buttonCreateCompany.Size = new Size(166, 23); + buttonCreateCompany.Size = new Size(257, 38); buttonCreateCompany.TabIndex = 8; buttonCreateCompany.Text = "Создать компанию"; buttonCreateCompany.UseVisualStyleBackColor = true; @@ -89,18 +87,18 @@ panelStorage.Controls.Add(textBoxCollectionName); panelStorage.Controls.Add(labelCollectionName); panelStorage.Dock = DockStyle.Top; - panelStorage.Location = new Point(2, 28); - panelStorage.Margin = new Padding(2); + panelStorage.Location = new Point(3, 43); panelStorage.Name = "panelStorage"; - panelStorage.Size = new Size(172, 247); + panelStorage.Size = new Size(266, 405); panelStorage.TabIndex = 7; // // buttonCollectionDel // buttonCollectionDel.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); - buttonCollectionDel.Location = new Point(3, 212); + buttonCollectionDel.Location = new Point(5, 348); + buttonCollectionDel.Margin = new Padding(5); buttonCollectionDel.Name = "buttonCollectionDel"; - buttonCollectionDel.Size = new Size(166, 23); + buttonCollectionDel.Size = new Size(257, 38); buttonCollectionDel.TabIndex = 6; buttonCollectionDel.Text = "Удалить Коллекцию"; buttonCollectionDel.UseVisualStyleBackColor = true; @@ -110,19 +108,19 @@ // listBoxCollection.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); listBoxCollection.FormattingEnabled = true; - listBoxCollection.ItemHeight = 17; - listBoxCollection.Location = new Point(3, 110); + listBoxCollection.ItemHeight = 30; + listBoxCollection.Location = new Point(5, 180); + listBoxCollection.Margin = new Padding(5); listBoxCollection.Name = "listBoxCollection"; - listBoxCollection.Size = new Size(166, 89); + listBoxCollection.Size = new Size(254, 124); listBoxCollection.TabIndex = 5; // // buttonCollectionAdd // buttonCollectionAdd.Font = new Font("Segoe UI", 7.948052F, FontStyle.Regular, GraphicsUnit.Point); - buttonCollectionAdd.Location = new Point(2, 82); - buttonCollectionAdd.Margin = new Padding(2); + buttonCollectionAdd.Location = new Point(3, 134); buttonCollectionAdd.Name = "buttonCollectionAdd"; - buttonCollectionAdd.Size = new Size(170, 23); + buttonCollectionAdd.Size = new Size(263, 38); buttonCollectionAdd.TabIndex = 4; buttonCollectionAdd.Text = "Добавить коллекцию"; buttonCollectionAdd.UseVisualStyleBackColor = true; @@ -132,10 +130,9 @@ // radioButtonList.AutoSize = true; radioButtonList.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); - radioButtonList.Location = new Point(89, 58); - radioButtonList.Margin = new Padding(2); + radioButtonList.Location = new Point(138, 95); radioButtonList.Name = "radioButtonList"; - radioButtonList.Size = new Size(73, 23); + radioButtonList.Size = new Size(107, 34); radioButtonList.TabIndex = 3; radioButtonList.TabStop = true; radioButtonList.Text = "Список"; @@ -145,10 +142,9 @@ // radioButtonMassive.AutoSize = true; radioButtonMassive.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); - radioButtonMassive.Location = new Point(2, 58); - radioButtonMassive.Margin = new Padding(2); + radioButtonMassive.Location = new Point(3, 95); radioButtonMassive.Name = "radioButtonMassive"; - radioButtonMassive.Size = new Size(71, 23); + radioButtonMassive.Size = new Size(107, 34); radioButtonMassive.TabIndex = 2; radioButtonMassive.TabStop = true; radioButtonMassive.Text = "массив"; @@ -156,20 +152,18 @@ // // textBoxCollectionName // - textBoxCollectionName.Location = new Point(0, 26); - textBoxCollectionName.Margin = new Padding(2); + textBoxCollectionName.Location = new Point(0, 43); textBoxCollectionName.Name = "textBoxCollectionName"; - textBoxCollectionName.Size = new Size(172, 33); + textBoxCollectionName.Size = new Size(264, 47); textBoxCollectionName.TabIndex = 1; // // labelCollectionName // labelCollectionName.AutoSize = true; labelCollectionName.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); - labelCollectionName.Location = new Point(14, 5); - labelCollectionName.Margin = new Padding(2, 0, 2, 0); + labelCollectionName.Location = new Point(22, 8); labelCollectionName.Name = "labelCollectionName"; - labelCollectionName.Size = new Size(140, 19); + labelCollectionName.Size = new Size(213, 30); labelCollectionName.TabIndex = 0; labelCollectionName.Text = "Название коллекции"; // @@ -179,10 +173,9 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(13, 279); - comboBoxSelectorCompany.Margin = new Padding(2); + comboBoxSelectorCompany.Location = new Point(20, 458); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(158, 33); + comboBoxSelectorCompany.Size = new Size(242, 49); comboBoxSelectorCompany.TabIndex = 0; comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; // @@ -191,67 +184,61 @@ pictureBox.Dock = DockStyle.Bottom; pictureBox.Enabled = false; pictureBox.Location = new Point(0, 0); - pictureBox.Margin = new Padding(2); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(681, 648); + pictureBox.Size = new Size(1052, 1063); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // // panelCompanyTools // panelCompanyTools.BackColor = SystemColors.Window; - panelCompanyTools.Controls.Add(button1); - panelCompanyTools.Controls.Add(button2); + panelCompanyTools.Controls.Add(buttonAddLiner); panelCompanyTools.Controls.Add(maskedTextBox1); panelCompanyTools.Controls.Add(button5); panelCompanyTools.Controls.Add(button3); panelCompanyTools.Controls.Add(button4); - panelCompanyTools.Location = new Point(681, 346); + panelCompanyTools.Location = new Point(1052, 567); + panelCompanyTools.Margin = new Padding(5); panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(176, 302); + panelCompanyTools.Size = new Size(272, 495); panelCompanyTools.TabIndex = 9; // - // button1 + // buttonAddLiner // - button1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - button1.Location = new Point(4, 2); - button1.Margin = new Padding(2); - button1.Name = "button1"; - button1.Size = new Size(140, 46); - button1.TabIndex = 1; - button1.Text = "Добавление Лайнера"; - button1.UseVisualStyleBackColor = true; - button1.Click += ButtonAddLiner_Click; - // - // button2 - // - button2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - button2.Location = new Point(2, 52); - button2.Margin = new Padding(2); - button2.Name = "button2"; - button2.Size = new Size(140, 46); - button2.TabIndex = 2; - button2.Text = "Добавление Обычного Лайнера"; - button2.UseVisualStyleBackColor = true; - button2.Click += ButtonAddCommonLiner_Click; + buttonAddLiner.Location = new Point(6, 54); + buttonAddLiner.Name = "buttonAddLiner"; + buttonAddLiner.Size = new Size(214, 75); + buttonAddLiner.TabIndex = 7; + buttonAddLiner.Text = "Добавить"; + buttonAddLiner.UseVisualStyleBackColor = true; + buttonAddLiner.Click += ButtonAddCommonLiner_Click; // // maskedTextBox1 // - maskedTextBox1.Location = new Point(2, 102); - maskedTextBox1.Margin = new Padding(2); + maskedTextBox1.Location = new Point(3, 167); maskedTextBox1.Mask = "00"; maskedTextBox1.Name = "maskedTextBox1"; - maskedTextBox1.Size = new Size(142, 33); + maskedTextBox1.Size = new Size(217, 47); maskedTextBox1.TabIndex = 3; maskedTextBox1.ValidatingType = typeof(int); // + // button5 + // + button5.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button5.Location = new Point(3, 384); + button5.Name = "button5"; + button5.Size = new Size(216, 75); + button5.TabIndex = 6; + button5.Text = "Обновить"; + button5.UseVisualStyleBackColor = true; + button5.Click += ButtonRefresh_Click; + // // button3 // button3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - button3.Location = new Point(2, 134); - button3.Margin = new Padding(2); + button3.Location = new Point(3, 220); button3.Name = "button3"; - button3.Size = new Size(140, 46); + button3.Size = new Size(216, 75); button3.TabIndex = 4; button3.Text = "Удаление Лайнера"; button3.UseVisualStyleBackColor = true; @@ -260,36 +247,22 @@ // button4 // button4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - button4.Location = new Point(2, 184); - button4.Margin = new Padding(2); + button4.Location = new Point(3, 302); button4.Name = "button4"; - button4.Size = new Size(140, 46); + button4.Size = new Size(216, 75); button4.TabIndex = 5; button4.Text = "Передать на тесты"; button4.UseVisualStyleBackColor = true; button4.Click += ButtonGoToCheck_Click; // - // button5 - // - button5.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - button5.Location = new Point(2, 234); - button5.Margin = new Padding(2); - button5.Name = "button5"; - button5.Size = new Size(140, 46); - button5.TabIndex = 6; - button5.Text = "Обновить"; - button5.UseVisualStyleBackColor = true; - button5.Click += ButtonRefresh_Click; - // // FormLinerCollection // - AutoScaleDimensions = new SizeF(11F, 25F); + AutoScaleDimensions = new SizeF(17F, 41F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(857, 648); + ClientSize = new Size(1324, 1063); Controls.Add(panelCompanyTools); Controls.Add(pictureBox); Controls.Add(groupBoxTools); - Margin = new Padding(2); Name = "FormLinerCollection"; Text = "Коллекция автомобилей"; groupBoxTools.ResumeLayout(false); @@ -304,9 +277,7 @@ #endregion private GroupBox groupBoxTools; - private Button buttonAddLiner; private ComboBox comboBoxSelectorCompany; - private Button buttonAddCommonLiner; private PictureBox pictureBox; private Button buttonGoToCheck; private Button buttonRemoveLiner; @@ -322,11 +293,10 @@ private ListBox listBoxCollection; private Button buttonCreateCompany; private Panel panelCompanyTools; - private Button button1; - private Button button2; private MaskedTextBox maskedTextBox1; private Button button5; private Button button3; private Button button4; + private Button buttonAddLiner; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index 67b99b3..cd5b2c0 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -34,45 +34,29 @@ public partial class FormLinerCollection : Form panelCompanyTools.Enabled = false; } /// - /// Добавление грузовика + /// Добавление лайнера /// /// /// - private void ButtonAddCommonLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCommonLiner)); - /// - /// Добавление подметательно-уборочной машины - /// - /// - /// - private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); - /// - /// Создание объекта класса-перемещенияв - /// - /// - private void CreateObject(string type) + private void ButtonAddCommonLiner_Click(object sender, EventArgs e) { - if (_company == null) + FormLinerConfig form = new(); + form.Show(); + form.AddEvent(SetLiner); + } + + /// + /// Добавление Лайнера в коллекцию + /// + /// + private void SetLiner(DrawningCommonLiner liner) + { + if (_company == null || liner == null) { return; } - Random random = new(); - DrawningCommonLiner drawningCommonLiner; - switch (type) - { - case nameof(DrawningCommonLiner): - drawningCommonLiner = new DrawningCommonLiner(random.Next(100, 300), - random.Next(1000, 3000), GetColor(random)); - break; - case nameof(DrawningLiner): - drawningCommonLiner = new DrawningLiner(random.Next(100, 300), random.Next(1000, 3000), - GetColor(random), GetColor(random), - Convert.ToBoolean(random.Next(0, 2)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - } - if (_company + drawningCommonLiner != -1) + + if (_company + liner != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -82,22 +66,7 @@ public partial class FormLinerCollection : Form 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; - } + /// /// Удаление объекта /// @@ -105,7 +74,7 @@ public partial class FormLinerCollection : Form /// private void ButtonRemoveLiner_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null) + if (string.IsNullOrEmpty(maskedTextBoxPosition?.Text) || _company == null) { return; } diff --git a/ProjectLiner/ProjectLiner/FormLinerConfig.Designer.cs b/ProjectLiner/ProjectLiner/FormLinerConfig.Designer.cs new file mode 100644 index 0000000..4a3d91f --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerConfig.Designer.cs @@ -0,0 +1,382 @@ +namespace ProjectLiner +{ + partial class FormLinerConfig + { + /// + /// 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() + { + Label labelSimpleObject; + Label labelModifiedObject; + Label labelBodyColor; + Label labelAdditionslColor; + groupBoxConfig = new GroupBox(); + groupBoxColors = new GroupBox(); + panelDarkOliveGreen = new Panel(); + panelAqua = new Panel(); + panelSeaGreen = new Panel(); + panelPaleGreen = new Panel(); + panelCrimson = new Panel(); + panelMediumBlue = new Panel(); + panelDeepPink = new Panel(); + panelBlueViolet = new Panel(); + checkBoxPipe = new CheckBox(); + checkBoxBoats = new CheckBox(); + checkBoxAnchor = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + labelWeight = new Label(); + numericUpDownSpeed = new NumericUpDown(); + labelSpeed = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + panelObject = new Panel(); + labelSimpleObject = new Label(); + labelModifiedObject = new Label(); + labelBodyColor = new Label(); + labelAdditionslColor = new Label(); + groupBoxConfig.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + panelObject.SuspendLayout(); + SuspendLayout(); + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(537, 292); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(224, 93); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += labelObject_MouseDown; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(779, 292); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(224, 93); + labelModifiedObject.TabIndex = 1; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += labelObject_MouseDown; + // + // labelBodyColor + // + labelBodyColor.AllowDrop = true; + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); + labelBodyColor.Location = new Point(20, 14); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(120, 56); + labelBodyColor.TabIndex = 10; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragDrop += labelBodyColor_DragDrop; + labelBodyColor.DragEnter += labelBodyColor_DragEnter; + // + // labelAdditionslColor + // + labelAdditionslColor.AllowDrop = true; + labelAdditionslColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionslColor.Location = new Point(146, 14); + labelAdditionslColor.Name = "labelAdditionslColor"; + labelAdditionslColor.Size = new Size(120, 56); + labelAdditionslColor.TabIndex = 11; + labelAdditionslColor.Text = "Доп. цвет"; + labelAdditionslColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionslColor.DragDrop += labelAdditionalColor_DragDrop; + labelAdditionslColor.DragEnter += labelAdditionalColor_DragEnter; + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColors); + groupBoxConfig.Controls.Add(checkBoxPipe); + groupBoxConfig.Controls.Add(checkBoxBoats); + groupBoxConfig.Controls.Add(checkBoxAnchor); + groupBoxConfig.Controls.Add(numericUpDownWeight); + groupBoxConfig.Controls.Add(labelWeight); + groupBoxConfig.Controls.Add(numericUpDownSpeed); + 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(1079, 406); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelDarkOliveGreen); + groupBoxColors.Controls.Add(panelAqua); + groupBoxColors.Controls.Add(panelSeaGreen); + groupBoxColors.Controls.Add(panelPaleGreen); + groupBoxColors.Controls.Add(panelCrimson); + groupBoxColors.Controls.Add(panelMediumBlue); + groupBoxColors.Controls.Add(panelDeepPink); + groupBoxColors.Controls.Add(panelBlueViolet); + groupBoxColors.Location = new Point(537, 46); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(466, 215); + groupBoxColors.TabIndex = 9; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelDarkOliveGreen + // + panelDarkOliveGreen.BackColor = Color.DarkOliveGreen; + panelDarkOliveGreen.BackgroundImageLayout = ImageLayout.None; + panelDarkOliveGreen.Location = new Point(287, 137); + panelDarkOliveGreen.Name = "panelDarkOliveGreen"; + panelDarkOliveGreen.Size = new Size(56, 54); + panelDarkOliveGreen.TabIndex = 4; + panelDarkOliveGreen.MouseDown += Panel_MouseDown; + // + // panelAqua + // + panelAqua.BackColor = Color.Aqua; + panelAqua.Location = new Point(125, 137); + panelAqua.Name = "panelAqua"; + panelAqua.Size = new Size(56, 54); + panelAqua.TabIndex = 6; + panelAqua.MouseDown += Panel_MouseDown; + // + // panelSeaGreen + // + panelSeaGreen.BackColor = Color.SeaGreen; + panelSeaGreen.Location = new Point(207, 137); + panelSeaGreen.Name = "panelSeaGreen"; + panelSeaGreen.Size = new Size(56, 54); + panelSeaGreen.TabIndex = 5; + panelSeaGreen.MouseDown += Panel_MouseDown; + // + // panelPaleGreen + // + panelPaleGreen.BackColor = Color.PaleGreen; + panelPaleGreen.Location = new Point(38, 137); + panelPaleGreen.Name = "panelPaleGreen"; + panelPaleGreen.Size = new Size(56, 54); + panelPaleGreen.TabIndex = 3; + panelPaleGreen.MouseDown += Panel_MouseDown; + // + // panelCrimson + // + panelCrimson.BackColor = Color.Crimson; + panelCrimson.Location = new Point(287, 62); + panelCrimson.Name = "panelCrimson"; + panelCrimson.Size = new Size(56, 54); + panelCrimson.TabIndex = 1; + panelCrimson.MouseDown += Panel_MouseDown; + // + // panelMediumBlue + // + panelMediumBlue.BackColor = Color.MediumBlue; + panelMediumBlue.Location = new Point(125, 62); + panelMediumBlue.Name = "panelMediumBlue"; + panelMediumBlue.Size = new Size(56, 54); + panelMediumBlue.TabIndex = 2; + panelMediumBlue.MouseDown += Panel_MouseDown; + // + // panelDeepPink + // + panelDeepPink.BackColor = Color.DeepPink; + panelDeepPink.Location = new Point(207, 62); + panelDeepPink.Name = "panelDeepPink"; + panelDeepPink.Size = new Size(56, 54); + panelDeepPink.TabIndex = 1; + panelDeepPink.MouseDown += Panel_MouseDown; + // + // panelBlueViolet + // + panelBlueViolet.BackColor = Color.BlueViolet; + panelBlueViolet.Location = new Point(38, 62); + panelBlueViolet.Name = "panelBlueViolet"; + panelBlueViolet.Size = new Size(56, 54); + panelBlueViolet.TabIndex = 0; + panelBlueViolet.MouseDown += Panel_MouseDown; + // + // checkBoxPipe + // + checkBoxPipe.AutoSize = true; + checkBoxPipe.Location = new Point(35, 340); + checkBoxPipe.Name = "checkBoxPipe"; + checkBoxPipe.Size = new Size(373, 45); + checkBoxPipe.TabIndex = 8; + checkBoxPipe.Text = "Признак наличия трубы"; + checkBoxPipe.UseVisualStyleBackColor = true; + // + // checkBoxBoats + // + checkBoxBoats.AutoSize = true; + checkBoxBoats.Location = new Point(35, 256); + checkBoxBoats.Name = "checkBoxBoats"; + checkBoxBoats.Size = new Size(404, 45); + checkBoxBoats.TabIndex = 7; + checkBoxBoats.Text = "Признак наличия шлюпок"; + checkBoxBoats.UseVisualStyleBackColor = true; + // + // checkBoxAnchor + // + checkBoxAnchor.AutoSize = true; + checkBoxAnchor.Location = new Point(35, 183); + checkBoxAnchor.Name = "checkBoxAnchor"; + checkBoxAnchor.Size = new Size(371, 45); + checkBoxAnchor.TabIndex = 6; + checkBoxAnchor.Text = "Признак наличия якоря"; + checkBoxAnchor.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(195, 112); + 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(192, 47); + numericUpDownWeight.TabIndex = 5; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(35, 118); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(72, 41); + labelWeight.TabIndex = 4; + labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(195, 59); + 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(192, 47); + numericUpDownSpeed.TabIndex = 3; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(35, 59); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(154, 41); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость:"; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(20, 96); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(246, 172); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Font = new Font("Segoe UI", 8.883117F, FontStyle.Regular, GraphicsUnit.Point); + buttonAdd.Location = new Point(1105, 320); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(120, 53); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 8.883117F, FontStyle.Regular, GraphicsUnit.Point); + buttonCancel.Location = new Point(1256, 320); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(120, 53); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAdditionslColor); + panelObject.Controls.Add(labelBodyColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(1085, 12); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(291, 289); + panelObject.TabIndex = 4; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // FormLinerConfig + // + AutoScaleDimensions = new SizeF(17F, 41F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1388, 406); + Controls.Add(panelObject); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(groupBoxConfig); + Name = "FormLinerConfig"; + Text = "Создание объекта"; + groupBoxConfig.ResumeLayout(false); + groupBoxConfig.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + panelObject.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxConfig; + private NumericUpDown numericUpDownWeight; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelSpeed; + private CheckBox checkBoxPipe; + private CheckBox checkBoxBoats; + private CheckBox checkBoxAnchor; + private GroupBox groupBoxColors; + private Panel panelDarkOliveGreen; + private Panel panelAqua; + private Panel panelSeaGreen; + private Panel panelPaleGreen; + private Panel panelCrimson; + private Panel panelMediumBlue; + private Panel panelDeepPink; + private Panel panelBlueViolet; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + private Panel panelObject; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerConfig.cs b/ProjectLiner/ProjectLiner/FormLinerConfig.cs new file mode 100644 index 0000000..c09b8b8 --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerConfig.cs @@ -0,0 +1,189 @@ + +using ProjectLiner.Drawnings; +using ProjectLiner.Entities; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; + +namespace ProjectLiner; + +/// +/// Форма конфигурации объекта +/// +public partial class FormLinerConfig : Form +{ + + /// + /// Объект - прорисовка самолета + /// + private DrawningCommonLiner? _commonLiner; + + /// + /// Событие для передачи объекта + /// + private event Action? linerDelegate; + + public FormLinerConfig() + { + + InitializeComponent(); + + panelBlueViolet.MouseDown += Panel_MouseDown; + panelMediumBlue.MouseDown += Panel_MouseDown; + panelAqua.MouseDown += Panel_MouseDown; + panelCrimson.MouseDown += Panel_MouseDown; + panelDarkOliveGreen.MouseDown += Panel_MouseDown; + panelPaleGreen.MouseDown += Panel_MouseDown; + panelSeaGreen.MouseDown += Panel_MouseDown; + panelDeepPink.MouseDown += Panel_MouseDown; + + buttonCancel.Click += (sender, e) => Close(); + } + + /// + /// Привязка внешнего метода к событию + /// + /// + public void AddEvent(Action commonlinerDelegate) + { + linerDelegate += commonlinerDelegate; + } + + /// + /// Прорисовка объекта + /// + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _commonLiner?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + _commonLiner?.SetPosition(5, 5); + _commonLiner?.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": + _commonLiner = new DrawningCommonLiner((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _commonLiner = new DrawningLiner((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, + Color.Black, checkBoxAnchor.Checked, checkBoxBoats.Checked, checkBoxPipe.Checked); + break; + } + + DrawObject(); + } + + /// + /// Передаем информацию при нажатии на Panel + /// + /// + /// + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + (sender as Control)?.DoDragDrop((sender as Control)?.BackColor!, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (_commonLiner != null) + { + linerDelegate?.Invoke(_commonLiner); + Close(); + } + } + + + /// + /// Передача основного цвета + /// + /// + /// + 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 (_commonLiner != null) + { + _commonLiner.EntityCommonLiner?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + + /// + /// Прорисовка дополнительным цветом + /// + /// + /// + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_commonLiner?.EntityCommonLiner is EntityLiner _liner) + { + _liner.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + } + + /// + /// Передача дополнительного цвета + /// + /// + /// + private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_commonLiner is DrawningLiner) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } +} diff --git a/ProjectLiner/ProjectLiner/FormLinerConfig.resx b/ProjectLiner/ProjectLiner/FormLinerConfig.resx new file mode 100644 index 0000000..22f0db5 --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerConfig.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + False + + + False + + + False + + + False + + \ No newline at end of file