From af521c360cc07449ec10688bd2d48ff3bd8448ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=9F=D0=B5=D1=80=D0=BC=D1=8F?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2?= Date: Fri, 5 Apr 2024 16:17:45 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=965?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AccordionBus/AccordionBus/BusDelegate.cs | 11 + .../Drawnings/DrawningAccordionBus.cs | 3 + .../AccordionBus/Drawnings/DrawningBus.cs | 3 + .../Entities/EntityAccordionBus.cs | 6 + .../AccordionBus/Entities/EntityBus.cs | 12 +- .../FormBusCollection.Designer.cs | 61 ++- .../AccordionBus/FormBusCollection.cs | 48 +-- .../AccordionBus/FormBusConfig.Designer.cs | 368 ++++++++++++++++++ AccordionBus/AccordionBus/FormBusConfig.cs | 184 +++++++++ AccordionBus/AccordionBus/FormBusConfig.resx | 120 ++++++ 10 files changed, 740 insertions(+), 76 deletions(-) create mode 100644 AccordionBus/AccordionBus/BusDelegate.cs create mode 100644 AccordionBus/AccordionBus/FormBusConfig.Designer.cs create mode 100644 AccordionBus/AccordionBus/FormBusConfig.cs create mode 100644 AccordionBus/AccordionBus/FormBusConfig.resx diff --git a/AccordionBus/AccordionBus/BusDelegate.cs b/AccordionBus/AccordionBus/BusDelegate.cs new file mode 100644 index 0000000..14d2659 --- /dev/null +++ b/AccordionBus/AccordionBus/BusDelegate.cs @@ -0,0 +1,11 @@ +using AccordionBus.Drawnings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccordionBus +{ + public delegate void BusDelegate(DrawningBus bus); +} diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs index ed3978f..98a41ba 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs @@ -26,6 +26,9 @@ namespace AccordionBus.Drawnings { EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors); } + + public void SetAdditionalColor(Color color) { (EntityBus as EntityAccordionBus).AdditionalColor = color; } + /// /// Отрисовка транспорта /// diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs index 982dde3..ec619ba 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs @@ -68,6 +68,9 @@ namespace AccordionBus.Drawnings _startPosX = null; _startPosY = null; } + + public void SetBodyColor(Color color) { EntityBus.SetBodyColor(color); } + /// /// Конструктор границ объекта /// diff --git a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs index 336dfcf..31eb8aa 100644 --- a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs +++ b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs @@ -39,5 +39,11 @@ namespace AccordionBus.Entities OnePart = onePart; FiveDoors = fiveDoors; } + + /// + /// Новый дополнительный цвет + /// + /// + public void SetAdditionalColor(Color color) { AdditionalColor = color; } } } diff --git a/AccordionBus/AccordionBus/Entities/EntityBus.cs b/AccordionBus/AccordionBus/Entities/EntityBus.cs index 18c5a80..1acacdb 100644 --- a/AccordionBus/AccordionBus/Entities/EntityBus.cs +++ b/AccordionBus/AccordionBus/Entities/EntityBus.cs @@ -14,15 +14,15 @@ namespace AccordionBus.Entities /// /// Скорость /// - public int Speed { get; set; } + public int Speed { get; private set; } /// /// Вес /// - public double Weight { get; set; } + public double Weight { get; private set; } /// /// Основной цвет /// - public Color BodyColor { get; set; } + public Color BodyColor { get; private set; } /// /// Шаг /// @@ -39,5 +39,11 @@ namespace AccordionBus.Entities Weight = weight; BodyColor = bodyColor; } + + /// + /// Новый основной цвет + /// + /// + public void SetBodyColor(Color color) { BodyColor = color; } } } diff --git a/AccordionBus/AccordionBus/FormBusCollection.Designer.cs b/AccordionBus/AccordionBus/FormBusCollection.Designer.cs index b74fb90..ad472cd 100644 --- a/AccordionBus/AccordionBus/FormBusCollection.Designer.cs +++ b/AccordionBus/AccordionBus/FormBusCollection.Designer.cs @@ -29,6 +29,8 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + buttonCreateCompany = new Button(); + comboBoxSelectedCompany = new ComboBox(); panelStorage = new Panel(); buttonCollectionDel = new Button(); listBoxCollection = new ListBox(); @@ -38,10 +40,7 @@ textBoxCollectionName = new TextBox(); labelCollectionName = new Label(); panelTools = new Panel(); - buttonCreateCompany = new Button(); - comboBoxSelectedCompany = new ComboBox(); buttonAddBus = new Button(); - buttonAddAccordionBus = new Button(); buttonRefresh = new Button(); maskedTextBox = new MaskedTextBox(); buttonGoToCheck = new Button(); @@ -67,6 +66,28 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(12, 361); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(207, 29); + buttonCreateCompany.TabIndex = 7; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += buttonCreateCompany_Click; + // + // comboBoxSelectedCompany + // + comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSelectedCompany.FormattingEnabled = true; + comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" }); + comboBoxSelectedCompany.Location = new Point(12, 327); + comboBoxSelectedCompany.Name = "comboBoxSelectedCompany"; + comboBoxSelectedCompany.Size = new Size(207, 28); + comboBoxSelectedCompany.TabIndex = 0; + comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged; + // // panelStorage // panelStorage.Controls.Add(buttonCollectionDel); @@ -151,7 +172,6 @@ // panelTools // panelTools.Controls.Add(buttonAddBus); - panelTools.Controls.Add(buttonAddAccordionBus); panelTools.Controls.Add(buttonRefresh); panelTools.Controls.Add(maskedTextBox); panelTools.Controls.Add(buttonGoToCheck); @@ -163,28 +183,6 @@ panelTools.Size = new Size(228, 354); panelTools.TabIndex = 7; // - // buttonCreateCompany - // - buttonCreateCompany.Location = new Point(12, 361); - buttonCreateCompany.Name = "buttonCreateCompany"; - buttonCreateCompany.Size = new Size(207, 29); - buttonCreateCompany.TabIndex = 7; - buttonCreateCompany.Text = "Создать компанию"; - buttonCreateCompany.UseVisualStyleBackColor = true; - buttonCreateCompany.Click += buttonCreateCompany_Click; - // - // comboBoxSelectedCompany - // - comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxSelectedCompany.FormattingEnabled = true; - comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" }); - comboBoxSelectedCompany.Location = new Point(12, 327); - comboBoxSelectedCompany.Name = "comboBoxSelectedCompany"; - comboBoxSelectedCompany.Size = new Size(207, 28); - comboBoxSelectedCompany.TabIndex = 0; - comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged; - // // buttonAddBus // buttonAddBus.Location = new Point(9, 13); @@ -195,16 +193,6 @@ buttonAddBus.UseVisualStyleBackColor = true; buttonAddBus.Click += buttonAddBus_Click; // - // buttonAddAccordionBus - // - buttonAddAccordionBus.Location = new Point(9, 73); - buttonAddAccordionBus.Name = "buttonAddAccordionBus"; - buttonAddAccordionBus.Size = new Size(207, 54); - buttonAddAccordionBus.TabIndex = 2; - buttonAddAccordionBus.Text = "Добавить автобус с гормошкой"; - buttonAddAccordionBus.UseVisualStyleBackColor = true; - buttonAddAccordionBus.Click += buttonAddAccordionBus_Click; - // // buttonRefresh // buttonRefresh.Location = new Point(9, 286); @@ -277,7 +265,6 @@ private GroupBox groupBoxTools; private ComboBox comboBoxSelectedCompany; private Button buttonAddBus; - private Button buttonAddAccordionBus; private PictureBox pictureBox; private Button buttonRemoveBus; private MaskedTextBox maskedTextBox; diff --git a/AccordionBus/AccordionBus/FormBusCollection.cs b/AccordionBus/AccordionBus/FormBusCollection.cs index a18139c..26240f6 100644 --- a/AccordionBus/AccordionBus/FormBusCollection.cs +++ b/AccordionBus/AccordionBus/FormBusCollection.cs @@ -30,29 +30,20 @@ namespace AccordionBus panelTools.Enabled = false; } - private void CreateObject(string type) + private void buttonAddBus_Click(object sender, EventArgs e) { - if (_company == null) return; + FormBusConfig form = new FormBusConfig(); + form.Show(); + form.AddEvent(SetCar); + } - Random random = new(); - DrawningBus _drawningBus; - switch (type) - { - case nameof(DrawningBus): - _drawningBus = new DrawningBus(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); - _drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height); - break; - case nameof(DrawningAccordionBus): - _drawningBus = new DrawningAccordionBus(random.Next(100, 300), random.Next(1000, 3000), - GetColor(random), GetColor(random), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - _drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height); - break; - default: - return; - } + private void SetCar(DrawningBus bus) + { + if (_company == null || bus == null) return; - if (_company + _drawningBus != -1) + bus.SetPictureSize(pictureBox.Width, pictureBox.Height); + + if (_company + bus != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -63,22 +54,6 @@ namespace AccordionBus } } - private static Color GetColor(Random rnd) - { - Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); - ColorDialog dialog = new(); - if (dialog.ShowDialog() == DialogResult.OK) - { - color = dialog.Color; - } - - return color; - } - - private void buttonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus)); - - private void buttonAddAccordionBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAccordionBus)); - private void buttonRemoveBus_Click(object sender, EventArgs e) { if (_company == null || string.IsNullOrEmpty(maskedTextBox.Text)) return; @@ -117,6 +92,7 @@ namespace AccordionBus SetBus = bus }; form.ShowDialog(); + bus.SetPictureSize(pictureBox.Width, pictureBox.Height); } private void buttonRefresh_Click(object sender, EventArgs e) diff --git a/AccordionBus/AccordionBus/FormBusConfig.Designer.cs b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs new file mode 100644 index 0000000..04e3be5 --- /dev/null +++ b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs @@ -0,0 +1,368 @@ +namespace AccordionBus +{ + partial class FormBusConfig + { + /// + /// 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(); + groupBoxColor = new GroupBox(); + panelPurple = new Panel(); + panelBlack = new Panel(); + panelGray = new Panel(); + panelWhite = new Panel(); + panelYellow = new Panel(); + panelBlue = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxFiveDoors = new CheckBox(); + checkBoxOnePart = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + labelWeight = new Label(); + numericUpDownSpeed = new NumericUpDown(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + panelObject = new Panel(); + labelAdditionalColor = new Label(); + labelBodyColor = new Label(); + groupBoxConfig.SuspendLayout(); + groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + panelObject.SuspendLayout(); + SuspendLayout(); + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColor); + groupBoxConfig.Controls.Add(checkBoxFiveDoors); + groupBoxConfig.Controls.Add(checkBoxOnePart); + 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(493, 229); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColor + // + groupBoxColor.Controls.Add(panelPurple); + groupBoxColor.Controls.Add(panelBlack); + groupBoxColor.Controls.Add(panelGray); + groupBoxColor.Controls.Add(panelWhite); + groupBoxColor.Controls.Add(panelYellow); + groupBoxColor.Controls.Add(panelBlue); + groupBoxColor.Controls.Add(panelGreen); + groupBoxColor.Controls.Add(panelRed); + groupBoxColor.Location = new Point(221, 17); + groupBoxColor.Name = "groupBoxColor"; + groupBoxColor.Size = new Size(262, 147); + groupBoxColor.TabIndex = 8; + groupBoxColor.TabStop = false; + groupBoxColor.Text = "Цвета"; + // + // panelPurple + // + panelPurple.AllowDrop = true; + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(205, 90); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(35, 35); + panelPurple.TabIndex = 6; + // + // panelBlack + // + panelBlack.AllowDrop = true; + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(143, 90); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(35, 35); + panelBlack.TabIndex = 1; + // + // panelGray + // + panelGray.AllowDrop = true; + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(77, 90); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(35, 35); + panelGray.TabIndex = 5; + // + // panelWhite + // + panelWhite.AllowDrop = true; + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(15, 90); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(35, 35); + panelWhite.TabIndex = 4; + // + // panelYellow + // + panelYellow.AllowDrop = true; + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(205, 26); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(35, 35); + panelYellow.TabIndex = 3; + // + // panelBlue + // + panelBlue.AllowDrop = true; + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(143, 26); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(35, 35); + panelBlue.TabIndex = 2; + // + // panelGreen + // + panelGreen.AllowDrop = true; + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(77, 26); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(35, 35); + panelGreen.TabIndex = 1; + // + // panelRed + // + panelRed.AllowDrop = true; + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(15, 26); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(35, 35); + panelRed.TabIndex = 0; + // + // checkBoxFiveDoors + // + checkBoxFiveDoors.AutoSize = true; + checkBoxFiveDoors.Location = new Point(24, 160); + checkBoxFiveDoors.Name = "checkBoxFiveDoors"; + checkBoxFiveDoors.Size = new Size(93, 24); + checkBoxFiveDoors.TabIndex = 7; + checkBoxFiveDoors.Text = "5 дверей"; + checkBoxFiveDoors.UseVisualStyleBackColor = true; + // + // checkBoxOnePart + // + checkBoxOnePart.AutoSize = true; + checkBoxOnePart.Location = new Point(24, 118); + checkBoxOnePart.Name = "checkBoxOnePart"; + checkBoxOnePart.Size = new Size(149, 24); + checkBoxOnePart.TabIndex = 6; + checkBoxOnePart.Text = "Простой автобус"; + checkBoxOnePart.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(94, 78); + 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(106, 27); + numericUpDownWeight.TabIndex = 5; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(12, 78); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(36, 20); + labelWeight.TabIndex = 4; + labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(94, 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(106, 27); + numericUpDownSpeed.TabIndex = 3; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(12, 37); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(76, 20); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость:"; + // + // labelModifiedObject + // + labelModifiedObject.AllowDrop = true; + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(361, 176); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(122, 39); + labelModifiedObject.TabIndex = 1; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += labelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.AllowDrop = true; + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(221, 176); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(122, 39); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += labelObject_MouseDown; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(16, 64); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(200, 100); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(515, 186); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 29); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(621, 186); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAdditionalColor); + panelObject.Controls.Add(labelBodyColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(499, 0); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(226, 178); + panelObject.TabIndex = 4; + panelObject.DragDrop += panelObject_DragDrop; + panelObject.DragEnter += panelObject_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(128, 26); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(88, 25); + labelAdditionalColor.TabIndex = 3; + labelAdditionalColor.Text = "Доп. цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += labelColor_DragEnter; + // + // labelBodyColor + // + labelBodyColor.AllowDrop = true; + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Location = new Point(16, 26); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(94, 25); + labelBodyColor.TabIndex = 2; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragDrop += labelBodyColor_DragDrop; + labelBodyColor.DragEnter += labelColor_DragEnter; + // + // FormBusConfig + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(737, 229); + Controls.Add(panelObject); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(groupBoxConfig); + Name = "FormBusConfig"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Создание объекта"; + groupBoxConfig.ResumeLayout(false); + groupBoxConfig.PerformLayout(); + groupBoxColor.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 Label labelSimpleObject; + private Label labelModifiedObject; + private Label labelSpeed; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private NumericUpDown numericUpDownWeight; + private CheckBox checkBoxOnePart; + private CheckBox checkBoxFiveDoors; + private GroupBox groupBoxColor; + private Panel panelRed; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGray; + private Panel panelWhite; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + private Panel panelObject; + private Label labelBodyColor; + private Label labelAdditionalColor; + } +} \ No newline at end of file diff --git a/AccordionBus/AccordionBus/FormBusConfig.cs b/AccordionBus/AccordionBus/FormBusConfig.cs new file mode 100644 index 0000000..b321ef3 --- /dev/null +++ b/AccordionBus/AccordionBus/FormBusConfig.cs @@ -0,0 +1,184 @@ +using AccordionBus.Drawnings; +using AccordionBus.Entities; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AccordionBus +{ + public partial class FormBusConfig : Form + { + private DrawningBus _bus; + + private event BusDelegate? _busDelegate; + + public FormBusConfig() + { + InitializeComponent(); + + panelRed.MouseDown += Panel_MouseDown; + panelBlue.MouseDown += Panel_MouseDown; + panelGreen.MouseDown += Panel_MouseDown; + panelYellow.MouseDown += Panel_MouseDown; + panelGray.MouseDown += Panel_MouseDown; + panelBlack.MouseDown += Panel_MouseDown; + panelWhite.MouseDown += Panel_MouseDown; + panelPurple.MouseDown += Panel_MouseDown; + + buttonCancel.Click += (sender, e) => Close(); + } + + public void AddEvent(BusDelegate busDelegate) + { + _busDelegate += busDelegate; + } + + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + Panel panel = sender as Panel; + panel.DoDragDrop(panel.Name, DragDropEffects.Copy); + } + + private void DrawObject() + { + if (_bus == null) return; + + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _bus.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + _bus.SetPosition(5, 5); + _bus.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + private void labelObject_MouseDown(object sender, MouseEventArgs e) + { + Label label = sender as Label; + label.DoDragDrop(label.Name, 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 "labelSimpleObject": + _bus = new DrawningBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _bus = new DrawningAccordionBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, + Color.Black, checkBoxOnePart.Checked, checkBoxFiveDoors.Checked); + break; + } + + DrawObject(); + } + + private void labelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void labelBodyColor_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "panelRed": + _bus.SetBodyColor(Color.Red); + break; + case "panelBlue": + _bus.SetBodyColor(Color.Blue); + break; + case "panelGreen": + _bus.SetBodyColor(Color.Green); + break; + case "panelYellow": + _bus.SetBodyColor(Color.Yellow); + break; + case "panelWhite": + _bus.SetBodyColor(Color.White); + break; + case "panelGray": + _bus.SetBodyColor(Color.Gray); + break; + case "panelBlack": + _bus.SetBodyColor(Color.Black); + break; + case "panelPurple": + _bus.SetBodyColor(Color.Purple); + break; + } + + DrawObject(); + } + + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_bus is DrawningAccordionBus) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "panelRed": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Red); + break; + case "panelBlue": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Blue); + break; + case "panelGreen": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Green); + break; + case "panelYellow": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Yellow); + break; + case "panelWhite": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.White); + break; + case "panelGray": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Gray); + break; + case "panelBlack": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Black); + break; + case "panelPurple": + (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Purple); + break; + } + + DrawObject(); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + if (_bus != null) + { + _busDelegate?.Invoke(_bus); + Close(); + } + } + } +} diff --git a/AccordionBus/AccordionBus/FormBusConfig.resx b/AccordionBus/AccordionBus/FormBusConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/AccordionBus/AccordionBus/FormBusConfig.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 -- 2.25.1 From c85750c8557aa5a80088b9d0a3ab58be85983d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=9F=D0=B5=D1=80=D0=BC=D1=8F?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2?= Date: Mon, 8 Apr 2024 11:11:42 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DrawningAccordionBus.cs | 2 -- .../AccordionBus/Drawnings/DrawningBus.cs | 2 -- AccordionBus/AccordionBus/FormBusConfig.cs | 36 +++++++++---------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs index 98a41ba..0339b60 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs @@ -27,8 +27,6 @@ namespace AccordionBus.Drawnings EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors); } - public void SetAdditionalColor(Color color) { (EntityBus as EntityAccordionBus).AdditionalColor = color; } - /// /// Отрисовка транспорта /// diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs index ec619ba..5443447 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs @@ -69,8 +69,6 @@ namespace AccordionBus.Drawnings _startPosY = null; } - public void SetBodyColor(Color color) { EntityBus.SetBodyColor(color); } - /// /// Конструктор границ объекта /// diff --git a/AccordionBus/AccordionBus/FormBusConfig.cs b/AccordionBus/AccordionBus/FormBusConfig.cs index b321ef3..35421b9 100644 --- a/AccordionBus/AccordionBus/FormBusConfig.cs +++ b/AccordionBus/AccordionBus/FormBusConfig.cs @@ -108,28 +108,28 @@ namespace AccordionBus switch (e.Data?.GetData(DataFormats.Text)?.ToString()) { case "panelRed": - _bus.SetBodyColor(Color.Red); + _bus.EntityBus.SetBodyColor(Color.Red); break; case "panelBlue": - _bus.SetBodyColor(Color.Blue); + _bus.EntityBus.SetBodyColor(Color.Blue); break; case "panelGreen": - _bus.SetBodyColor(Color.Green); + _bus.EntityBus.SetBodyColor(Color.Green); break; case "panelYellow": - _bus.SetBodyColor(Color.Yellow); + _bus.EntityBus.SetBodyColor(Color.Yellow); break; case "panelWhite": - _bus.SetBodyColor(Color.White); + _bus.EntityBus.SetBodyColor(Color.White); break; case "panelGray": - _bus.SetBodyColor(Color.Gray); + _bus.EntityBus.SetBodyColor(Color.Gray); break; case "panelBlack": - _bus.SetBodyColor(Color.Black); + _bus.EntityBus.SetBodyColor(Color.Black); break; case "panelPurple": - _bus.SetBodyColor(Color.Purple); + _bus.EntityBus.SetBodyColor(Color.Purple); break; } @@ -138,37 +138,37 @@ namespace AccordionBus private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) { - if (_bus is DrawningAccordionBus) + if (_bus.EntityBus is EntityAccordionBus entityAccordionBus) { switch (e.Data?.GetData(DataFormats.Text)?.ToString()) { case "panelRed": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Red); + entityAccordionBus.SetAdditionalColor(Color.Red); break; case "panelBlue": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Blue); + entityAccordionBus.SetAdditionalColor(Color.Blue); break; case "panelGreen": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Green); + entityAccordionBus.SetAdditionalColor(Color.Green); break; case "panelYellow": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Yellow); + entityAccordionBus.SetAdditionalColor(Color.Yellow); break; case "panelWhite": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.White); + entityAccordionBus.SetAdditionalColor(Color.White); break; case "panelGray": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Gray); + entityAccordionBus.SetAdditionalColor(Color.Gray); break; case "panelBlack": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Black); + entityAccordionBus.SetAdditionalColor(Color.Black); break; case "panelPurple": - (_bus as DrawningAccordionBus).SetAdditionalColor(Color.Purple); + entityAccordionBus.SetAdditionalColor(Color.Purple); break; } - DrawObject(); + DrawObject() ; } } -- 2.25.1 From ff496f96ed831367140a1eb5f997251e03ecc4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=9F=D0=B5=D1=80=D0=BC=D1=8F?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2?= Date: Mon, 8 Apr 2024 14:05:45 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DrawningAccordionBus.cs | 116 +++++++++--------- .../Entities/EntityAccordionBus.cs | 8 +- .../AccordionBus/FormBusConfig.Designer.cs | 20 +-- AccordionBus/AccordionBus/FormBusConfig.cs | 8 +- 4 files changed, 79 insertions(+), 73 deletions(-) diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs index 0339b60..3cfccc9 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs @@ -19,12 +19,12 @@ namespace AccordionBus.Drawnings /// /// /// - /// + /// /// public DrawningAccordionBus(int speed, double weight, Color bodyColor, Color - additionalColor, bool onePart, bool fiveDoors): base(130, 20) + additionalColor, bool hatch, bool fiveDoors): base(130, 20) { - EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors); + EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, hatch, fiveDoors); } /// @@ -41,60 +41,66 @@ namespace AccordionBus.Drawnings base.DrawTransport(g); - if (!accordionBus.OnePart) + Pen pen = new(Color.Black); + Brush brWhite = new SolidBrush(Color.White); + Brush br = new SolidBrush(accordionBus.BodyColor); + Brush brBlue = new SolidBrush(Color.LightBlue); + Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor); + //корпус + g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15); + g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15); + + //колёса + g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); + g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); + + //стёкла + g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); + + //гормошка + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value); + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15); + + //двери + g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); + g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); + if (accordionBus.FiveDoors) { - Pen pen = new(Color.Black); - Brush brWhite = new SolidBrush(Color.White); - Brush br = new SolidBrush(accordionBus.BodyColor); - Brush brBlue = new SolidBrush(Color.LightBlue); - Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor); - //корпус - g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15); - g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); + g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); + g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); + g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); + g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); + g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); + } - //колёса - g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); - g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); - - //стёкла - g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); - - //гормошка - g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value); - g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15); - - //двери - g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); - g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); - if (accordionBus.FiveDoors) - { - g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); - g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); - g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); - g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); - g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); - g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); - } + //люки + if (accordionBus.Hatch) + { + g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3); + g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3); + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3); } } } diff --git a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs index 31eb8aa..019fbd5 100644 --- a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs +++ b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs @@ -18,7 +18,7 @@ namespace AccordionBus.Entities /// /// Одна часть /// - public bool OnePart { get; set; } + public bool Hatch { get; set; } /// /// 5 дверей /// @@ -30,13 +30,13 @@ namespace AccordionBus.Entities /// вес /// Основной цвет /// Дополнительный цвет - /// 1 часть + /// 1 часть /// 5 дверей public EntityAccordionBus(int speed, double weight, Color bodyColor, - Color additionalColor, bool onePart, bool fiveDoors) : base(speed, weight, bodyColor) + Color additionalColor, bool hatch, bool fiveDoors) : base(speed, weight, bodyColor) { AdditionalColor = additionalColor; - OnePart = onePart; + Hatch = hatch; FiveDoors = fiveDoors; } diff --git a/AccordionBus/AccordionBus/FormBusConfig.Designer.cs b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs index 04e3be5..9de1234 100644 --- a/AccordionBus/AccordionBus/FormBusConfig.Designer.cs +++ b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs @@ -39,7 +39,7 @@ panelGreen = new Panel(); panelRed = new Panel(); checkBoxFiveDoors = new CheckBox(); - checkBoxOnePart = new CheckBox(); + checkBoxHatch = new CheckBox(); numericUpDownWeight = new NumericUpDown(); labelWeight = new Label(); numericUpDownSpeed = new NumericUpDown(); @@ -64,7 +64,7 @@ // groupBoxConfig.Controls.Add(groupBoxColor); groupBoxConfig.Controls.Add(checkBoxFiveDoors); - groupBoxConfig.Controls.Add(checkBoxOnePart); + groupBoxConfig.Controls.Add(checkBoxHatch); groupBoxConfig.Controls.Add(numericUpDownWeight); groupBoxConfig.Controls.Add(labelWeight); groupBoxConfig.Controls.Add(numericUpDownSpeed); @@ -180,13 +180,13 @@ // // checkBoxOnePart // - checkBoxOnePart.AutoSize = true; - checkBoxOnePart.Location = new Point(24, 118); - checkBoxOnePart.Name = "checkBoxOnePart"; - checkBoxOnePart.Size = new Size(149, 24); - checkBoxOnePart.TabIndex = 6; - checkBoxOnePart.Text = "Простой автобус"; - checkBoxOnePart.UseVisualStyleBackColor = true; + checkBoxHatch.AutoSize = true; + checkBoxHatch.Location = new Point(24, 118); + checkBoxHatch.Name = "checkBoxOnePart"; + checkBoxHatch.Size = new Size(69, 24); + checkBoxHatch.TabIndex = 6; + checkBoxHatch.Text = "Люки"; + checkBoxHatch.UseVisualStyleBackColor = true; // // numericUpDownWeight // @@ -347,7 +347,7 @@ private Label labelWeight; private NumericUpDown numericUpDownSpeed; private NumericUpDown numericUpDownWeight; - private CheckBox checkBoxOnePart; + private CheckBox checkBoxHatch; private CheckBox checkBoxFiveDoors; private GroupBox groupBoxColor; private Panel panelRed; diff --git a/AccordionBus/AccordionBus/FormBusConfig.cs b/AccordionBus/AccordionBus/FormBusConfig.cs index 35421b9..d01ff71 100644 --- a/AccordionBus/AccordionBus/FormBusConfig.cs +++ b/AccordionBus/AccordionBus/FormBusConfig.cs @@ -16,7 +16,7 @@ namespace AccordionBus { private DrawningBus _bus; - private event BusDelegate? _busDelegate; + private event Action _busDelegate; public FormBusConfig() { @@ -34,7 +34,7 @@ namespace AccordionBus buttonCancel.Click += (sender, e) => Close(); } - public void AddEvent(BusDelegate busDelegate) + public void AddEvent(Action busDelegate) { _busDelegate += busDelegate; } @@ -84,7 +84,7 @@ namespace AccordionBus break; case "labelModifiedObject": _bus = new DrawningAccordionBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, - Color.Black, checkBoxOnePart.Checked, checkBoxFiveDoors.Checked); + Color.Black, checkBoxHatch.Checked, checkBoxFiveDoors.Checked); break; } @@ -176,7 +176,7 @@ namespace AccordionBus { if (_bus != null) { - _busDelegate?.Invoke(_bus); + _busDelegate.Invoke(_bus); Close(); } } -- 2.25.1