diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningBus.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningBus.cs
index a67f67b..55c3edc 100644
--- a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningBus.cs
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningBus.cs
@@ -230,5 +230,20 @@ namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base.DrawningObjects
g.FillEllipse(brBlue, _startPosX + 70, _startPosY + 35, 10, 15);
g.FillEllipse(brBlue, _startPosX + 90, _startPosY + 35, 10, 15);
}
+
+ public void SetColor(Color color)
+ {
+ if (EntityBus == null)
+ {
+ return;
+ }
+ EntityBus.BodyColor = color;
+ }
+
+ public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
+ {
+ _pictureWidth = pictureBoxWidth;
+ _pictureHeight = pictureBoxHeight;
+ }
}
}
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningDoubleDeckerBus.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningDoubleDeckerBus.cs
index 4bc5e21..13a3888 100644
--- a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningDoubleDeckerBus.cs
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/DrawningObjects/DrawningDoubleDeckerBus.cs
@@ -96,5 +96,10 @@ additionalColor, bool secondFloor, bool ladder, bool lineBetweenFloor, int width
g.FillRectangle(brBlack, _startPosX, _startPosY + 30, 100, 3);
}
}
+
+ public void SetAddColor(Color color)
+ {
+ ((EntityDoubleDeckerBus)EntityBus).AdditionalColor = color;
+ }
}
}
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityBus.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityBus.cs
index b483493..d18b62e 100644
--- a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityBus.cs
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityBus.cs
@@ -24,7 +24,7 @@ namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base.Entities
///
/// Основной цвет
///
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
///
/// Шаг перемещения автомобиля
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityDoubleDeckerBus.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityDoubleDeckerBus.cs
index 7fc6596..9f0440d 100644
--- a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityDoubleDeckerBus.cs
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/Entities/EntityDoubleDeckerBus.cs
@@ -14,7 +14,7 @@ namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base.Entities
///
/// Дополнительный цвет (для опциональных элементов)
///
- public Color AdditionalColor { get; private set; }
+ public Color AdditionalColor { get; set; }
///
/// Признак (опция) наличия второго этажа
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusCollection.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusCollection.cs
index 167259d..f7d74e3 100644
--- a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusCollection.cs
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusCollection.cs
@@ -118,20 +118,24 @@ namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base
{
return;
}
- FormDoubleDeckerBus form = new();
- if (form.ShowDialog() == DialogResult.OK)
+
+ FormBusConfig form = new();
+ form.Show();
+ Action? busDelegate = new((m) =>
{
- if (obj + form.SelectedBus)
+ bool isAdditionSuccessful = (obj + m);
+ if (isAdditionSuccessful)
{
MessageBox.Show("Объект добавлен");
+ m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
pictureBoxCollection.Image = obj.ShowTheBuses();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
- }
-
+ });
+ form.AddEvent(busDelegate);
}
///
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.Designer.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.Designer.cs
new file mode 100644
index 0000000..810838d
--- /dev/null
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.Designer.cs
@@ -0,0 +1,368 @@
+namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base
+{
+ 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()
+ {
+ groupBoxParameters = new GroupBox();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ groupBoxColor = new GroupBox();
+ panelPurple = new Panel();
+ panelBlack = new Panel();
+ panelYellow = new Panel();
+ panelGray = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelWhite = new Panel();
+ panelRed = new Panel();
+ checkBoxLineBetweenFloor = new CheckBox();
+ checkBoxLadder = new CheckBox();
+ checkBoxSecondFloor = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ numericUpDownSpeed = new NumericUpDown();
+ labelWeight = new Label();
+ labelSpeed = new Label();
+ panelObject = new Panel();
+ buttonAdd = new Button();
+ buttonCancel = new Button();
+ labelColor = new Label();
+ labelExtraColor = new Label();
+ pictureBoxObject = new PictureBox();
+ groupBoxParameters.SuspendLayout();
+ groupBoxColor.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ panelObject.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxParameters
+ //
+ groupBoxParameters.Controls.Add(labelModifiedObject);
+ groupBoxParameters.Controls.Add(labelSimpleObject);
+ groupBoxParameters.Controls.Add(groupBoxColor);
+ groupBoxParameters.Controls.Add(checkBoxLineBetweenFloor);
+ groupBoxParameters.Controls.Add(checkBoxLadder);
+ groupBoxParameters.Controls.Add(checkBoxSecondFloor);
+ groupBoxParameters.Controls.Add(numericUpDownWeight);
+ groupBoxParameters.Controls.Add(numericUpDownSpeed);
+ groupBoxParameters.Controls.Add(labelWeight);
+ groupBoxParameters.Controls.Add(labelSpeed);
+ groupBoxParameters.Location = new Point(25, 12);
+ groupBoxParameters.Name = "groupBoxParameters";
+ groupBoxParameters.Size = new Size(673, 266);
+ groupBoxParameters.TabIndex = 0;
+ groupBoxParameters.TabStop = false;
+ groupBoxParameters.Text = "Параметры";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(528, 196);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(101, 43);
+ labelModifiedObject.TabIndex = 9;
+ labelModifiedObject.Text = "Сложный";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(412, 196);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(101, 43);
+ labelSimpleObject.TabIndex = 8;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ //
+ // groupBoxColor
+ //
+ groupBoxColor.Controls.Add(panelPurple);
+ groupBoxColor.Controls.Add(panelBlack);
+ groupBoxColor.Controls.Add(panelYellow);
+ groupBoxColor.Controls.Add(panelGray);
+ groupBoxColor.Controls.Add(panelBlue);
+ groupBoxColor.Controls.Add(panelGreen);
+ groupBoxColor.Controls.Add(panelWhite);
+ groupBoxColor.Controls.Add(panelRed);
+ groupBoxColor.Location = new Point(385, 32);
+ groupBoxColor.Name = "groupBoxColor";
+ groupBoxColor.Size = new Size(272, 151);
+ groupBoxColor.TabIndex = 7;
+ groupBoxColor.TabStop = false;
+ groupBoxColor.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.Purple;
+ panelPurple.Location = new Point(207, 92);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(47, 47);
+ panelPurple.TabIndex = 4;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(143, 92);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(47, 47);
+ panelBlack.TabIndex = 4;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(207, 32);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(47, 47);
+ panelYellow.TabIndex = 3;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(81, 92);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(47, 47);
+ panelGray.TabIndex = 2;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(143, 32);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(47, 47);
+ panelBlue.TabIndex = 3;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(81, 32);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(47, 47);
+ panelGreen.TabIndex = 1;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(18, 92);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(47, 47);
+ panelWhite.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(18, 32);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(47, 47);
+ panelRed.TabIndex = 0;
+ //
+ // checkBoxLineBetweenFloor
+ //
+ checkBoxLineBetweenFloor.AutoSize = true;
+ checkBoxLineBetweenFloor.Location = new Point(17, 232);
+ checkBoxLineBetweenFloor.Name = "checkBoxLineBetweenFloor";
+ checkBoxLineBetweenFloor.Size = new Size(315, 24);
+ checkBoxLineBetweenFloor.TabIndex = 6;
+ checkBoxLineBetweenFloor.Text = "Признак наличия линии между этажами";
+ checkBoxLineBetweenFloor.UseVisualStyleBackColor = true;
+ //
+ // checkBoxLadder
+ //
+ checkBoxLadder.AutoSize = true;
+ checkBoxLadder.Location = new Point(17, 184);
+ checkBoxLadder.Name = "checkBoxLadder";
+ checkBoxLadder.Size = new Size(336, 24);
+ checkBoxLadder.TabIndex = 5;
+ checkBoxLadder.Text = "Признак наличия лестницы на второй этаж";
+ checkBoxLadder.UseVisualStyleBackColor = true;
+ //
+ // checkBoxSecondFloor
+ //
+ checkBoxSecondFloor.AutoSize = true;
+ checkBoxSecondFloor.Location = new Point(17, 138);
+ checkBoxSecondFloor.Name = "checkBoxSecondFloor";
+ checkBoxSecondFloor.Size = new Size(258, 24);
+ checkBoxSecondFloor.TabIndex = 4;
+ checkBoxSecondFloor.Text = "Признак наличия второго этажа";
+ checkBoxSecondFloor.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(108, 94);
+ 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(86, 27);
+ numericUpDownWeight.TabIndex = 3;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(108, 44);
+ 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(86, 27);
+ numericUpDownSpeed.TabIndex = 2;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(17, 94);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(36, 20);
+ labelWeight.TabIndex = 1;
+ labelWeight.Text = "Вес:";
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(17, 44);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(76, 20);
+ labelSpeed.TabIndex = 0;
+ labelSpeed.Text = "Скорость:";
+ //
+ // panelObject
+ //
+ panelObject.AllowDrop = true;
+ panelObject.Controls.Add(pictureBoxObject);
+ panelObject.Controls.Add(labelExtraColor);
+ panelObject.Controls.Add(labelColor);
+ panelObject.Location = new Point(714, 12);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(329, 214);
+ panelObject.TabIndex = 1;
+ panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(717, 232);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(160, 46);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(883, 232);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(160, 46);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отменить";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // labelColor
+ //
+ labelColor.AllowDrop = true;
+ labelColor.BorderStyle = BorderStyle.FixedSingle;
+ labelColor.Location = new Point(13, 14);
+ labelColor.Name = "labelColor";
+ labelColor.Size = new Size(150, 35);
+ labelColor.TabIndex = 0;
+ labelColor.Text = "Цвет";
+ labelColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
+ labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
+ //
+ // labelExtraColor
+ //
+ labelExtraColor.AllowDrop = true;
+ labelExtraColor.BorderStyle = BorderStyle.FixedSingle;
+ labelExtraColor.Location = new Point(169, 14);
+ labelExtraColor.Name = "labelExtraColor";
+ labelExtraColor.Size = new Size(150, 35);
+ labelExtraColor.TabIndex = 1;
+ labelExtraColor.Text = "Доп. цвет";
+ labelExtraColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelExtraColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
+ labelExtraColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(13, 52);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(306, 154);
+ pictureBoxObject.TabIndex = 2;
+ pictureBoxObject.TabStop = false;
+ //
+ // FormBusConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1048, 290);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(panelObject);
+ Controls.Add(groupBoxParameters);
+ Name = "FormBusConfig";
+ Text = "Создание объекта";
+ groupBoxParameters.ResumeLayout(false);
+ groupBoxParameters.PerformLayout();
+ groupBoxColor.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 groupBoxParameters;
+ private Label labelWeight;
+ private Label labelSpeed;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private CheckBox checkBoxSecondFloor;
+ private CheckBox checkBoxLadder;
+ private CheckBox checkBoxLineBetweenFloor;
+ private GroupBox groupBoxColor;
+ private Panel panelGreen;
+ private Panel panelWhite;
+ private Panel panelRed;
+ private Panel panelPurple;
+ private Panel panelBlack;
+ private Panel panelYellow;
+ private Panel panelGray;
+ private Panel panelBlue;
+ private Label labelSimpleObject;
+ private Label labelModifiedObject;
+ private Panel panelObject;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ private PictureBox pictureBoxObject;
+ private Label labelExtraColor;
+ private Label labelColor;
+ }
+}
\ No newline at end of file
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.cs b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.cs
new file mode 100644
index 0000000..946c25b
--- /dev/null
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.cs
@@ -0,0 +1,198 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Forms.VisualStyles;
+using PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base.DrawningObjects;
+
+namespace PIbd_23_Ivanov_V.N._DoubleDeckerBus._Base
+{
+ ///
+ /// Форма создания объекта
+ ///
+ public partial class FormBusConfig : Form
+ {
+ ///
+ /// Переменная-выбранный автобус
+ ///
+ DrawningBus? _bus = null;
+
+ ///
+ /// Событие
+ ///
+ private event Action? EventAddBus;
+
+ ///
+ /// Конструктор
+ ///
+ public FormBusConfig()
+ {
+ InitializeComponent();
+ panelBlack.MouseDown += PanelColor_MouseDown;
+ panelPurple.MouseDown += PanelColor_MouseDown;
+ panelGray.MouseDown += PanelColor_MouseDown;
+ panelGreen.MouseDown += PanelColor_MouseDown;
+ panelRed.MouseDown += PanelColor_MouseDown;
+ panelWhite.MouseDown += PanelColor_MouseDown;
+ panelYellow.MouseDown += PanelColor_MouseDown;
+ panelBlue.MouseDown += PanelColor_MouseDown;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ buttonCancel.Click += (s, e) => Close();
+ }
+
+ ///
+ /// Отрисовать автобус
+ ///
+ private void DrawBus()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _bus?.SetPosition(5, 5);
+ _bus?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ ///
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(Action ev)
+ {
+ if (EventAddBus == null)
+ {
+ EventAddBus = ev;
+ }
+ else
+ {
+ EventAddBus += ev;
+ }
+ }
+
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void PanelObject_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ private void PanelObject_DragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text).ToString())
+ {
+ case "labelSimpleObject":
+ _bus = new DrawningBus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
+ Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
+ break;
+ case "labelModifiedObject":
+ _bus = new DrawningDoubleDeckerBus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
+ Color.White, Color.Black, checkBoxSecondFloor.Checked, checkBoxLadder.Checked,
+ checkBoxLineBetweenFloor.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
+ break;
+ }
+ labelColor.BackColor = Color.Empty;
+ labelExtraColor.BackColor = Color.Empty;
+ DrawBus();
+ }
+
+ ///
+ /// Отправляем цвет с панели
+ ///
+ ///
+ ///
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Принимаем основной цвет
+ ///
+ ///
+ ///
+ private void LabelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_bus == null)
+ {
+ return;
+ }
+ labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
+ _bus.SetColor(labelColor.BackColor);
+ DrawBus();
+ }
+
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ ///
+ /// Принимаем дополнительный цвет
+ ///
+ ///
+ ///
+ private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if ((_bus == null) || (_bus is DrawningDoubleDeckerBus == false))
+ {
+ return;
+ }
+ labelExtraColor.BackColor = (Color)e.Data.GetData(typeof(Color));
+ ((DrawningDoubleDeckerBus)_bus).SetAddColor(labelExtraColor.BackColor);
+ DrawBus();
+ }
+
+ ///
+ /// Добавление автобуса
+ ///
+ ///
+ ///
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ EventAddBus?.Invoke(_bus);
+ Close();
+ }
+ }
+}
diff --git a/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.resx b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/FormBusConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/PIbd-23_Ivanov_V.N._DoubleDeckerBus._Base/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