diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CarDelegate.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CarDelegate.cs new file mode 100644 index 0000000..9b1a931 --- /dev/null +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CarDelegate.cs @@ -0,0 +1,8 @@ +using ProjectGasolineTanker.Drawnings; + +namespace ProjectGasolineTanker; +/// +/// Делегат передачи объекта класса-прорисовки +/// +/// +public delegate void TankerDelegate(DrawningTanker car); \ No newline at end of file diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs index 9e6b80c..44667d8 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs @@ -9,6 +9,8 @@ public class EntityGasolineTanker : EntityTanker /// Дополниетльный цвет /// public Color AdditionalColor { get; private set; } + + public void SetAdditionalColor(Color color) => AdditionalColor = color; /// /// Наличие безнобака /// diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTanker.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTanker.cs index f607ac1..cd43dea 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTanker.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTanker.cs @@ -16,6 +16,8 @@ public class EntityTanker /// Основной цвет /// public Color BodyColor { get; private set; } + + public void SetBodyColor(Color color) => BodyColor = color; /// /// Перемещение бензовоза /// diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs index 5ad2f22..2857956 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs @@ -30,94 +30,52 @@ namespace ProjectGasolineTanker /// private void InitializeComponent() { - Инструменты = new GroupBox(); - panelCompanyTools = new Panel(); - buttonAddTanker = new Button(); - buttonAddGasolineTanker = new Button(); - maskedTextBoxPosition = new MaskedTextBox(); + groupBoxTools = new GroupBox(); + buttonRefresh = new Button(); buttonGoToCheck = new Button(); buttonRemoveTanker = new Button(); - buttonRefresh = new Button(); - buttonCreateCompany = new Button(); - panelStorage = new Panel(); - buttonCollectionDel = new Button(); - listBoxCollection = new ListBox(); - buttonCollectionAdd = new Button(); - radioButtonList = new RadioButton(); - radioButtonMassive = new RadioButton(); - textBoxCollectionName = new TextBox(); - labelCollectionName = new Label(); + maskedTextBoxPosition = new MaskedTextBox(); + buttonAddGasolineTanker = new Button(); + buttonAddTanker = new Button(); comboBoxSelectorCompany = new ComboBox(); pictureBox = new PictureBox(); - Инструменты.SuspendLayout(); - panelCompanyTools.SuspendLayout(); - panelStorage.SuspendLayout(); + groupBoxTools.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + panelCompanyTools.SuspendLayout(); SuspendLayout(); // // Инструменты // - Инструменты.Controls.Add(panelCompanyTools); - Инструменты.Controls.Add(buttonCreateCompany); - Инструменты.Controls.Add(panelStorage); - Инструменты.Controls.Add(comboBoxSelectorCompany); - Инструменты.Dock = DockStyle.Right; - Инструменты.Location = new Point(861, 0); - Инструменты.Name = "Инструменты"; - Инструменты.Size = new Size(225, 651); - Инструменты.TabIndex = 0; - Инструменты.TabStop = false; - Инструменты.Text = "Инструменты"; - // - // panelCompanyTools - // - panelCompanyTools.Controls.Add(buttonAddTanker); - panelCompanyTools.Controls.Add(buttonAddGasolineTanker); - panelCompanyTools.Controls.Add(maskedTextBoxPosition); - panelCompanyTools.Controls.Add(buttonGoToCheck); - panelCompanyTools.Controls.Add(buttonRemoveTanker); - panelCompanyTools.Controls.Add(buttonRefresh); - panelCompanyTools.Dock = DockStyle.Bottom; - panelCompanyTools.Location = new Point(3, 383); - panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(219, 265); - panelCompanyTools.TabIndex = 8; - // - // buttonAddTanker - // - buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddTanker.Location = new Point(3, 3); - buttonAddTanker.Name = "buttonAddTanker"; - buttonAddTanker.Size = new Size(213, 37); - buttonAddTanker.TabIndex = 1; - buttonAddTanker.Text = "Добавление грузовика"; - buttonAddTanker.UseVisualStyleBackColor = true; - buttonAddTanker.Click += buttonAddTanker_Click; + groupBoxTools.Controls.Add(buttonRefresh); + groupBoxTools.Controls.Add(buttonGoToCheck); + groupBoxTools.Controls.Add(buttonRemoveTanker); + groupBoxTools.Controls.Add(maskedTextBoxPosition); + groupBoxTools.Controls.Add(buttonAddGasolineTanker); + groupBoxTools.Controls.Add(buttonAddTanker); + groupBoxTools.Controls.Add(comboBoxSelectorCompany); + groupBoxTools.Dock = DockStyle.Right; + groupBoxTools.Location = new Point(783, 0); + groupBoxTools.Name = "groupBoxTools"; + groupBoxTools.Size = new Size(179, 616); + groupBoxTools.TabIndex = 0; + groupBoxTools.TabStop = false; + groupBoxTools.Text = "Инструменты"; // // buttonAddGasolineTanker // - buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddGasolineTanker.Location = new Point(3, 43); - buttonAddGasolineTanker.Name = "buttonAddGasolineTanker"; - buttonAddGasolineTanker.Size = new Size(213, 37); - buttonAddGasolineTanker.TabIndex = 2; - buttonAddGasolineTanker.Text = "Добавление бензовоза\r\n"; - buttonAddGasolineTanker.UseVisualStyleBackColor = true; - buttonAddGasolineTanker.Click += buttonAddGasolineTanker_Click; - // - // maskedTextBoxPosition - // - maskedTextBoxPosition.Location = new Point(3, 86); - maskedTextBoxPosition.Mask = "00"; - maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - maskedTextBoxPosition.Size = new Size(213, 23); - maskedTextBoxPosition.TabIndex = 3; - maskedTextBoxPosition.ValidatingType = typeof(int); + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(6, 499); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(167, 40); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; // // buttonGoToCheck // buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(3, 161); + buttonGoToCheck.Location = new Point(6, 361); buttonGoToCheck.Name = "buttonGoToCheck"; buttonGoToCheck.Size = new Size(213, 40); buttonGoToCheck.TabIndex = 6; @@ -128,116 +86,45 @@ namespace ProjectGasolineTanker // buttonRemoveTanker // buttonRemoveTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemoveTanker.Location = new Point(3, 115); + buttonRemoveTanker.Location = new Point(6, 251); buttonRemoveTanker.Name = "buttonRemoveTanker"; buttonRemoveTanker.Size = new Size(213, 40); buttonRemoveTanker.TabIndex = 4; buttonRemoveTanker.Text = "Удаление машины"; buttonRemoveTanker.UseVisualStyleBackColor = true; buttonRemoveTanker.Click += ButtonRemoveTanker_Click; + // // buttonRefresh // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(3, 207); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(213, 40); - buttonRefresh.TabIndex = 5; - buttonRefresh.Text = "Обновить"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += ButtonRefresh_Click; + maskedTextBoxPosition.Location = new Point(6, 222); + maskedTextBoxPosition.Mask = "00"; + maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + maskedTextBoxPosition.Size = new Size(167, 23); + maskedTextBoxPosition.TabIndex = 3; + maskedTextBoxPosition.ValidatingType = typeof(int); // - // buttonCreateCompany + // buttonAddGaslineTanker // - buttonCreateCompany.Location = new Point(6, 350); - buttonCreateCompany.Name = "buttonCreateCompany"; - buttonCreateCompany.Size = new Size(213, 24); - buttonCreateCompany.TabIndex = 7; - buttonCreateCompany.Text = "Создать компанию"; - buttonCreateCompany.UseVisualStyleBackColor = true; - buttonCreateCompany.Click += ButtonCreateCompany_Click; + buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddGasolineTanker.Location = new Point(6, 137); + buttonAddGasolineTanker.Name = "buttonAddGasolineTanker"; + buttonAddGasolineTanker.Size = new Size(167, 40); + buttonAddGasolineTanker.TabIndex = 2; + buttonAddGasolineTanker.Text = "Добавление бензовоза"; + buttonAddGasolineTanker.UseVisualStyleBackColor = true; + buttonAddGasolineTanker.Click += ButtonAddGasolineTanker_Click; // - // panelStorage + // buttonAddTanker // - panelStorage.Controls.Add(buttonCollectionDel); - panelStorage.Controls.Add(listBoxCollection); - panelStorage.Controls.Add(buttonCollectionAdd); - panelStorage.Controls.Add(radioButtonList); - panelStorage.Controls.Add(radioButtonMassive); - panelStorage.Controls.Add(textBoxCollectionName); - panelStorage.Controls.Add(labelCollectionName); - panelStorage.Dock = DockStyle.Top; - panelStorage.Location = new Point(3, 19); - panelStorage.Name = "panelStorage"; - panelStorage.Size = new Size(219, 296); - panelStorage.TabIndex = 7; - // - // buttonCollectionDel - // - buttonCollectionDel.Location = new Point(3, 267); - buttonCollectionDel.Name = "buttonCollectionDel"; - buttonCollectionDel.Size = new Size(213, 24); - buttonCollectionDel.TabIndex = 6; - buttonCollectionDel.Text = "Удалить коллекцию"; - buttonCollectionDel.UseVisualStyleBackColor = true; - buttonCollectionDel.Click += ButtonCollectionDel_Click; - // - // listBoxCollection - // - listBoxCollection.FormattingEnabled = true; - listBoxCollection.ItemHeight = 15; - listBoxCollection.Location = new Point(3, 122); - listBoxCollection.Name = "listBoxCollection"; - listBoxCollection.Size = new Size(213, 139); - listBoxCollection.TabIndex = 5; - // - // buttonCollectionAdd - // - buttonCollectionAdd.Location = new Point(3, 85); - buttonCollectionAdd.Name = "buttonCollectionAdd"; - buttonCollectionAdd.Size = new Size(213, 24); - buttonCollectionAdd.TabIndex = 4; - buttonCollectionAdd.Text = "Добавить коллекцию"; - buttonCollectionAdd.UseVisualStyleBackColor = true; - buttonCollectionAdd.Click += ButtonCollectionAdd_Click; - // - // radioButtonList - // - radioButtonList.AutoSize = true; - radioButtonList.Location = new Point(139, 60); - radioButtonList.Name = "radioButtonList"; - radioButtonList.Size = new Size(66, 19); - radioButtonList.TabIndex = 3; - radioButtonList.TabStop = true; - radioButtonList.Text = "Список"; - radioButtonList.UseVisualStyleBackColor = true; - // - // radioButtonMassive - // - radioButtonMassive.AutoSize = true; - radioButtonMassive.Location = new Point(19, 60); - radioButtonMassive.Name = "radioButtonMassive"; - radioButtonMassive.Size = new Size(67, 19); - radioButtonMassive.TabIndex = 2; - radioButtonMassive.TabStop = true; - radioButtonMassive.Text = "Массив"; - radioButtonMassive.UseVisualStyleBackColor = true; - // - // textBoxCollectionName - // - textBoxCollectionName.Location = new Point(3, 31); - textBoxCollectionName.Name = "textBoxCollectionName"; - textBoxCollectionName.Size = new Size(213, 23); - textBoxCollectionName.TabIndex = 1; - // - // labelCollectionName - // - labelCollectionName.AutoSize = true; - labelCollectionName.Location = new Point(47, 13); - labelCollectionName.Name = "labelCollectionName"; - labelCollectionName.Size = new Size(125, 15); - labelCollectionName.TabIndex = 0; - labelCollectionName.Text = "Название коллекции:"; + buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddTanker.Location = new Point(6, 91); + buttonAddTanker.Name = "buttonAddTanker"; + buttonAddTanker.Size = new Size(167, 40); + buttonAddTanker.TabIndex = 1; + buttonAddTanker.Text = "Добавление грузовика"; + buttonAddTanker.UseVisualStyleBackColor = true; + buttonAddTanker.Click += ButtonAddTanker_Click; // // comboBoxSelectorCompany // @@ -245,7 +132,7 @@ namespace ProjectGasolineTanker comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(6, 321); + comboBoxSelectorCompany.Location = new Point(6, 22); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(213, 23); comboBoxSelectorCompany.TabIndex = 0; @@ -260,6 +147,20 @@ namespace ProjectGasolineTanker pictureBox.TabIndex = 1; pictureBox.TabStop = false; // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(buttonAddTanker); + panelCompanyTools.Controls.Add(maskedTextBoxPosition); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(buttonRemoveTanker); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 360); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(173, 253); + panelCompanyTools.TabIndex = 9; + // // FormTankerCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -268,13 +169,13 @@ namespace ProjectGasolineTanker Controls.Add(pictureBox); Controls.Add(Инструменты); Name = "FormTankerCollection"; - Text = "Коллекция лодок"; - Инструменты.ResumeLayout(false); - panelCompanyTools.ResumeLayout(false); - panelCompanyTools.PerformLayout(); + Text = "Коллекция автомобилей"; + groupBoxTools.ResumeLayout(false); panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); ResumeLayout(false); } @@ -284,20 +185,13 @@ namespace ProjectGasolineTanker private Button buttonAddTanker; private ComboBox comboBoxSelectorCompany; private Button buttonAddGasolineTanker; + private Button buttonAddTanker; + private Button buttonRemoveTanker; private MaskedTextBox maskedTextBoxPosition; private PictureBox pictureBox; private Button buttonRefresh; private Button buttonRemoveTanker; private Button buttonGoToCheck; - private Panel panelStorage; - private Label labelCollectionName; - private RadioButton radioButtonMassive; - private TextBox textBoxCollectionName; - private Button buttonCollectionDel; - private ListBox listBoxCollection; - private Button buttonCollectionAdd; - private RadioButton radioButtonList; - private Button buttonCreateCompany; - private Panel panelCompanyTools; + private Button buttonRefresh; } } \ No newline at end of file diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs index 8c87c44..0ce7fa6 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs @@ -43,31 +43,32 @@ public partial class FormTankerCollection : Form } } + /// + /// Добавление обычного автомобиля + /// + /// + /// + private void ButtonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker)); + + /// + /// Добавление спортивного автомобиля + /// + /// + /// + private void ButtonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker)); + + /// + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта private void CreateObject(string type) { - if (_company == null) + if (_company == null || tank == null) { return; } - DrawningTanker _drawningTanker; - Random random = new(); - switch (type) - { - case nameof(DrawningTanker): - _drawningTanker = new DrawningTanker(random.Next(30, 70), random.Next(100, 500), - GetColor(random)); - break; - case nameof(DrawningGasolineTanker): - _drawningTanker = new DrawningGasolineTanker(random.Next(30, 70), random.Next(100, 500), - GetColor(random), GetColor(random), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - } - - if (_company + _drawningTanker != -1) + if (_company + tank != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -79,25 +80,11 @@ public partial class FormTankerCollection : Form } /// - /// Добавление обычного автомобиля - /// - /// - /// - private void buttonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker)); - - /// - /// Добавление спортивного автомобиля + /// Получение цвета /// - /// - /// - private void buttonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker)); - - /// - /// Получение цвета - /// - /// Генератор случайных чисел - /// - private static Color GetColor(Random random) + /// Генератор случайных чисел + /// + 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(); diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.Designer.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.Designer.cs new file mode 100644 index 0000000..83a84c0 --- /dev/null +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.Designer.cs @@ -0,0 +1,357 @@ +namespace ProjectGasolineTanker +{ + partial class FormTankerConfig + { + /// + /// 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(); + checkBoxSignalbeacon = new CheckBox(); + checkBoxTanker = 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(checkBoxSignalbeacon); + groupBoxConfig.Controls.Add(checkBoxTanker); + 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; + // + // checkBoxSignalbeacon + // + checkBoxSignalbeacon.AutoSize = true; + checkBoxSignalbeacon.Location = new Point(12, 168); + checkBoxSignalbeacon.Name = "checkBoxSignalbeacon"; + checkBoxSignalbeacon.Size = new Size(232, 34); + checkBoxSignalbeacon.TabIndex = 9; + checkBoxSignalbeacon.Text = "Признак наличия сигнального маяка\r\n\r\n"; + checkBoxSignalbeacon.UseVisualStyleBackColor = true; + // + // checkBoxTanker + // + checkBoxTanker.AutoSize = true; + checkBoxTanker.Location = new Point(12, 125); + checkBoxTanker.Name = "checkBoxTanker"; + checkBoxTanker.Size = new Size(154, 19); + checkBoxTanker.TabIndex = 8; + checkBoxTanker.Text = "Признак наличия бака \r\n"; + checkBoxTanker.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; + // + // FormTankerConfig + // + 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 = "FormTankerConfig"; + 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 checkBoxTanker; + private CheckBox checkBoxSignalbeacon; + 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/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.cs new file mode 100644 index 0000000..2776e7c --- /dev/null +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.cs @@ -0,0 +1,160 @@ +using ProjectGasolineTanker.Drawnings; +using ProjectGasolineTanker.Entities; +namespace ProjectGasolineTanker; + +public partial class FormTankerConfig : Form +{ + private DrawningTanker? _tanker = null; + + private event Action? _TankerDelegate; + public FormTankerConfig() + { + 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 TankerDelegate) + { + _TankerDelegate += TankerDelegate; + } + + /// + /// Прорисовка объекта + /// + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _tanker?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + _tanker?.SetPosition(15, 15); + _tanker?.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": + _tanker = new DrawningTanker((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _tanker = new DrawningGasolineTanker((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, + Color.Black, checkBoxTanker.Checked, checkBoxSignalbeacon.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 (_tanker != null) + { + _tanker.EntityTanker.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + + private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_tanker is DrawningGasolineTanker) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } + + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_tanker?.EntityTanker is EntityGasolineTanker _gasolinetanker) + { + _gasolinetanker.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + + } + /// + /// Передача объекта + /// + /// + /// + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (_tanker != null) + { + _TankerDelegate?.Invoke(_tanker); + Close(); + } + } +} diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.resx b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerConfig.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