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..3cfccc9 100644
--- a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs
+++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs
@@ -19,13 +19,14 @@ 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);
}
+
///
/// Отрисовка транспорта
///
@@ -40,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/Drawnings/DrawningBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs
index 982dde3..5443447 100644
--- a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs
+++ b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs
@@ -68,6 +68,7 @@ namespace AccordionBus.Drawnings
_startPosX = null;
_startPosY = null;
}
+
///
/// Конструктор границ объекта
///
diff --git a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs
index 336dfcf..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,14 +30,20 @@ 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;
}
+
+ ///
+ /// Новый дополнительный цвет
+ ///
+ ///
+ 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..9de1234
--- /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();
+ checkBoxHatch = 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(checkBoxHatch);
+ 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
+ //
+ 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
+ //
+ 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 checkBoxHatch;
+ 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..d01ff71
--- /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 Action _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(Action 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, checkBoxHatch.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.EntityBus.SetBodyColor(Color.Red);
+ break;
+ case "panelBlue":
+ _bus.EntityBus.SetBodyColor(Color.Blue);
+ break;
+ case "panelGreen":
+ _bus.EntityBus.SetBodyColor(Color.Green);
+ break;
+ case "panelYellow":
+ _bus.EntityBus.SetBodyColor(Color.Yellow);
+ break;
+ case "panelWhite":
+ _bus.EntityBus.SetBodyColor(Color.White);
+ break;
+ case "panelGray":
+ _bus.EntityBus.SetBodyColor(Color.Gray);
+ break;
+ case "panelBlack":
+ _bus.EntityBus.SetBodyColor(Color.Black);
+ break;
+ case "panelPurple":
+ _bus.EntityBus.SetBodyColor(Color.Purple);
+ break;
+ }
+
+ DrawObject();
+ }
+
+ private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_bus.EntityBus is EntityAccordionBus entityAccordionBus)
+ {
+ switch (e.Data?.GetData(DataFormats.Text)?.ToString())
+ {
+ case "panelRed":
+ entityAccordionBus.SetAdditionalColor(Color.Red);
+ break;
+ case "panelBlue":
+ entityAccordionBus.SetAdditionalColor(Color.Blue);
+ break;
+ case "panelGreen":
+ entityAccordionBus.SetAdditionalColor(Color.Green);
+ break;
+ case "panelYellow":
+ entityAccordionBus.SetAdditionalColor(Color.Yellow);
+ break;
+ case "panelWhite":
+ entityAccordionBus.SetAdditionalColor(Color.White);
+ break;
+ case "panelGray":
+ entityAccordionBus.SetAdditionalColor(Color.Gray);
+ break;
+ case "panelBlack":
+ entityAccordionBus.SetAdditionalColor(Color.Black);
+ break;
+ case "panelPurple":
+ entityAccordionBus.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