diff --git a/DoubleDeckerBus/DoubleDeckerBus/BusDelegate.cs b/DoubleDeckerBus/DoubleDeckerBus/BusDelegate.cs
new file mode 100644
index 0000000..8bd80c4
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/BusDelegate.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DoubleDeckerBus
+{
+ public delegate void BusDelegate(DrawningBus bus);
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs
index 065f1b4..3a821cf 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs
@@ -8,6 +8,10 @@ namespace DoubleDeckerBus
{
internal class DrawningDoubleDeckerBus : DrawningBus
{
+ public void SetDopColor(Color color)
+ {
+ ((EntityDoubleDeckerBus)Bus).DopColor = color;
+ }
///
/// Инициализация свойств
///
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
index 5bb39ad..87affee 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs
@@ -22,7 +22,7 @@ namespace DoubleDeckerBus
///
/// Цвет кузова
///
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
///
/// Шаг перемещения автомобуса
///
@@ -41,5 +41,9 @@ namespace DoubleDeckerBus
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
+ public void setColor(Color newColor)
+ {
+ BodyColor = newColor;
+ }
}
}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
index 9a8c5cb..74797fb 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
@@ -11,7 +11,7 @@ namespace DoubleDeckerBus
///
/// Дополнительный цвет
///
- public Color DopColor { get; private set; }
+ public Color DopColor { get; set; }
///
/// Признак наличия обвеса
///
@@ -42,6 +42,9 @@ namespace DoubleDeckerBus
BodyKit = bodyKit;
Stair = stair;
}
-
+ public void setDopColor(Color newDopColor)
+ {
+ DopColor = newDopColor;
+ }
}
}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.Designer.cs
new file mode 100644
index 0000000..c40da5b
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.Designer.cs
@@ -0,0 +1,374 @@
+namespace DoubleDeckerBus
+{
+ 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()
+ {
+ this.groupBoxConfig = new System.Windows.Forms.GroupBox();
+ this.labelModifiedObject = new System.Windows.Forms.Label();
+ this.labelSimpleObject = new System.Windows.Forms.Label();
+ this.groupBoxColors = new System.Windows.Forms.GroupBox();
+ this.panelPurple = new System.Windows.Forms.Panel();
+ this.panelBlack = new System.Windows.Forms.Panel();
+ this.panelGray = new System.Windows.Forms.Panel();
+ this.panelWhite = new System.Windows.Forms.Panel();
+ this.panelYellow = new System.Windows.Forms.Panel();
+ this.panelBlue = new System.Windows.Forms.Panel();
+ this.panelGreen = new System.Windows.Forms.Panel();
+ this.panelRed = new System.Windows.Forms.Panel();
+ this.checkBoxStair = new System.Windows.Forms.CheckBox();
+ this.checkBoxSecondFloor = new System.Windows.Forms.CheckBox();
+ this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
+ this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.pictureBoxObject = new System.Windows.Forms.PictureBox();
+ this.panelObject = new System.Windows.Forms.Panel();
+ this.labelDopColor = new System.Windows.Forms.Label();
+ this.labelColor = new System.Windows.Forms.Label();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.groupBoxConfig.SuspendLayout();
+ this.groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
+ this.panelObject.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
+ this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
+ this.groupBoxConfig.Controls.Add(this.groupBoxColors);
+ this.groupBoxConfig.Controls.Add(this.checkBoxStair);
+ this.groupBoxConfig.Controls.Add(this.checkBoxSecondFloor);
+ this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
+ this.groupBoxConfig.Controls.Add(this.labelWeight);
+ this.groupBoxConfig.Controls.Add(this.labelSpeed);
+ this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
+ this.groupBoxConfig.Name = "groupBoxConfig";
+ this.groupBoxConfig.Size = new System.Drawing.Size(564, 247);
+ this.groupBoxConfig.TabIndex = 0;
+ this.groupBoxConfig.TabStop = false;
+ this.groupBoxConfig.Text = "Параметры";
+ //
+ // labelModifiedObject
+ //
+ this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelModifiedObject.Location = new System.Drawing.Point(432, 193);
+ this.labelModifiedObject.Name = "labelModifiedObject";
+ this.labelModifiedObject.Size = new System.Drawing.Size(100, 34);
+ this.labelModifiedObject.TabIndex = 8;
+ this.labelModifiedObject.Text = "Продвинутый";
+ this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // labelSimpleObject
+ //
+ this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelSimpleObject.Location = new System.Drawing.Point(300, 193);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(100, 34);
+ this.labelSimpleObject.TabIndex = 7;
+ this.labelSimpleObject.Text = "Простой";
+ this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // groupBoxColors
+ //
+ this.groupBoxColors.Controls.Add(this.panelPurple);
+ this.groupBoxColors.Controls.Add(this.panelBlack);
+ this.groupBoxColors.Controls.Add(this.panelGray);
+ this.groupBoxColors.Controls.Add(this.panelWhite);
+ this.groupBoxColors.Controls.Add(this.panelYellow);
+ this.groupBoxColors.Controls.Add(this.panelBlue);
+ this.groupBoxColors.Controls.Add(this.panelGreen);
+ this.groupBoxColors.Controls.Add(this.panelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(282, 44);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(263, 138);
+ this.groupBoxColors.TabIndex = 6;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ this.panelPurple.BackColor = System.Drawing.Color.Purple;
+ this.panelPurple.Location = new System.Drawing.Point(199, 81);
+ this.panelPurple.Name = "panelPurple";
+ this.panelPurple.Size = new System.Drawing.Size(40, 40);
+ this.panelPurple.TabIndex = 3;
+ //
+ // panelBlack
+ //
+ this.panelBlack.BackColor = System.Drawing.Color.Black;
+ this.panelBlack.Location = new System.Drawing.Point(140, 81);
+ this.panelBlack.Name = "panelBlack";
+ this.panelBlack.Size = new System.Drawing.Size(40, 40);
+ this.panelBlack.TabIndex = 4;
+ //
+ // panelGray
+ //
+ this.panelGray.BackColor = System.Drawing.Color.Gray;
+ this.panelGray.Location = new System.Drawing.Point(78, 81);
+ this.panelGray.Name = "panelGray";
+ this.panelGray.Size = new System.Drawing.Size(40, 40);
+ this.panelGray.TabIndex = 5;
+ //
+ // panelWhite
+ //
+ this.panelWhite.BackColor = System.Drawing.Color.White;
+ this.panelWhite.Location = new System.Drawing.Point(18, 81);
+ this.panelWhite.Name = "panelWhite";
+ this.panelWhite.Size = new System.Drawing.Size(40, 40);
+ this.panelWhite.TabIndex = 2;
+ //
+ // panelYellow
+ //
+ this.panelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.panelYellow.Location = new System.Drawing.Point(199, 33);
+ this.panelYellow.Name = "panelYellow";
+ this.panelYellow.Size = new System.Drawing.Size(40, 40);
+ this.panelYellow.TabIndex = 1;
+ //
+ // panelBlue
+ //
+ this.panelBlue.BackColor = System.Drawing.Color.Blue;
+ this.panelBlue.Location = new System.Drawing.Point(140, 33);
+ this.panelBlue.Name = "panelBlue";
+ this.panelBlue.Size = new System.Drawing.Size(40, 40);
+ this.panelBlue.TabIndex = 1;
+ //
+ // panelGreen
+ //
+ this.panelGreen.BackColor = System.Drawing.Color.Green;
+ this.panelGreen.Location = new System.Drawing.Point(78, 33);
+ this.panelGreen.Name = "panelGreen";
+ this.panelGreen.Size = new System.Drawing.Size(40, 40);
+ this.panelGreen.TabIndex = 1;
+ //
+ // panelRed
+ //
+ this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.Location = new System.Drawing.Point(18, 33);
+ this.panelRed.Name = "panelRed";
+ this.panelRed.Size = new System.Drawing.Size(40, 40);
+ this.panelRed.TabIndex = 0;
+ //
+ // checkBoxStair
+ //
+ this.checkBoxStair.AutoSize = true;
+ this.checkBoxStair.Location = new System.Drawing.Point(35, 202);
+ this.checkBoxStair.Name = "checkBoxStair";
+ this.checkBoxStair.Size = new System.Drawing.Size(180, 19);
+ this.checkBoxStair.TabIndex = 1;
+ this.checkBoxStair.Text = "Признак наличия лестницы";
+ this.checkBoxStair.UseVisualStyleBackColor = true;
+ //
+ // checkBoxSecondFloor
+ //
+ this.checkBoxSecondFloor.AutoSize = true;
+ this.checkBoxSecondFloor.Location = new System.Drawing.Point(35, 127);
+ this.checkBoxSecondFloor.Name = "checkBoxSecondFloor";
+ this.checkBoxSecondFloor.Size = new System.Drawing.Size(205, 19);
+ this.checkBoxSecondFloor.TabIndex = 5;
+ this.checkBoxSecondFloor.Text = "Признак наличия второго этажа";
+ this.checkBoxSecondFloor.UseVisualStyleBackColor = true;
+ //
+ // checkBoxBodyKit
+ //
+ this.checkBoxBodyKit.AutoSize = true;
+ this.checkBoxBodyKit.Location = new System.Drawing.Point(35, 165);
+ this.checkBoxBodyKit.Name = "checkBoxBodyKit";
+ this.checkBoxBodyKit.Size = new System.Drawing.Size(164, 19);
+ this.checkBoxBodyKit.TabIndex = 4;
+ this.checkBoxBodyKit.Text = "Признак наличия обвеса";
+ this.checkBoxBodyKit.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ this.numericUpDownWeight.Location = new System.Drawing.Point(103, 79);
+ this.numericUpDownWeight.Name = "numericUpDownWeight";
+ this.numericUpDownWeight.Size = new System.Drawing.Size(69, 23);
+ this.numericUpDownWeight.TabIndex = 3;
+ this.numericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // numericUpDownSpeed
+ //
+ this.numericUpDownSpeed.Location = new System.Drawing.Point(103, 44);
+ this.numericUpDownSpeed.Name = "numericUpDownSpeed";
+ this.numericUpDownSpeed.Size = new System.Drawing.Size(69, 23);
+ this.numericUpDownSpeed.TabIndex = 2;
+ this.numericUpDownSpeed.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // labelWeight
+ //
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(35, 81);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(29, 15);
+ this.labelWeight.TabIndex = 1;
+ this.labelWeight.Text = "Вес:";
+ //
+ // labelSpeed
+ //
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(35, 46);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(62, 15);
+ this.labelSpeed.TabIndex = 0;
+ this.labelSpeed.Text = "Скорость:";
+ //
+ // pictureBoxObject
+ //
+ this.pictureBoxObject.Location = new System.Drawing.Point(17, 46);
+ this.pictureBoxObject.Name = "pictureBoxObject";
+ this.pictureBoxObject.Size = new System.Drawing.Size(259, 119);
+ this.pictureBoxObject.TabIndex = 1;
+ this.pictureBoxObject.TabStop = false;
+ //
+ // panelObject
+ //
+ this.panelObject.AllowDrop = true;
+ this.panelObject.Controls.Add(this.labelDopColor);
+ this.panelObject.Controls.Add(this.labelColor);
+ this.panelObject.Controls.Add(this.pictureBoxObject);
+ this.panelObject.Location = new System.Drawing.Point(598, 12);
+ this.panelObject.Name = "panelObject";
+ this.panelObject.Size = new System.Drawing.Size(294, 182);
+ this.panelObject.TabIndex = 2;
+ this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
+ //
+ // labelDopColor
+ //
+ this.labelDopColor.AllowDrop = true;
+ this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelDopColor.Location = new System.Drawing.Point(161, 9);
+ this.labelDopColor.Name = "labelDopColor";
+ this.labelDopColor.Size = new System.Drawing.Size(115, 34);
+ this.labelDopColor.TabIndex = 3;
+ this.labelDopColor.Text = "Доп. цвет";
+ this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
+ this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter);
+ //
+ // labelColor
+ //
+ this.labelColor.AllowDrop = true;
+ this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelColor.Location = new System.Drawing.Point(17, 9);
+ this.labelColor.Name = "labelColor";
+ this.labelColor.Size = new System.Drawing.Size(118, 34);
+ this.labelColor.TabIndex = 2;
+ this.labelColor.Text = "Цвет";
+ this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
+ this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(615, 204);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(105, 37);
+ this.buttonAdd.TabIndex = 3;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonOk_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(759, 204);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(115, 37);
+ this.buttonCancel.TabIndex = 4;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormBusConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(912, 266);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.panelObject);
+ this.Controls.Add(this.groupBoxConfig);
+ this.Name = "FormBusConfig";
+ this.Text = "Создание объекта";
+ this.groupBoxConfig.ResumeLayout(false);
+ this.groupBoxConfig.PerformLayout();
+ this.groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
+ this.panelObject.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private CheckBox checkBoxStair;
+ private CheckBox checkBoxSecondFloor;
+ private CheckBox checkBoxBodyKit;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelWeight;
+ private Label labelSpeed;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private GroupBox groupBoxColors;
+ private Panel panelPurple;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelWhite;
+ private Panel panelYellow;
+ private Panel panelBlue;
+ private Panel panelGreen;
+ private Panel panelRed;
+ private PictureBox pictureBoxObject;
+ private Panel panelObject;
+ private Label labelDopColor;
+ private Label labelColor;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.cs
new file mode 100644
index 0000000..fdc9c68
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.cs
@@ -0,0 +1,153 @@
+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;
+
+namespace DoubleDeckerBus
+{
+ public partial class FormBusConfig : Form
+ {
+ DrawningBus _bus = null;
+ private event BusDelegate 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;
+ buttonCancel.Click += (object sender, EventArgs a) => Close();
+ }
+
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void DrawBus()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _bus?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
+ _bus?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ public void AddEvent(BusDelegate ev)
+ {
+ if (EventAddBus == null)
+ {
+ EventAddBus = new BusDelegate(ev);
+ }
+ else
+ {
+ EventAddBus += ev;
+ }
+ }
+
+ private void PanelObject_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.Text))
+ {
+ 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, labelColor.BackColor);
+ break;
+ case "labelModifiedObject":
+ _bus = new DrawningDoubleDeckerBus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelColor.BackColor, labelDopColor.BackColor,
+ checkBoxSecondFloor.Checked, checkBoxBodyKit.Checked, checkBoxStair.Checked);
+ break;
+ }
+ DrawBus();
+ }
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ 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 LabelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ var color = e.Data.GetData(typeof(Color));
+ if (color != null)
+ {
+ (sender as Label).BackColor = (Color)color;
+ }
+ if (_bus != null)
+ {
+ _bus.Bus.BodyColor = (Color)color;
+ DrawBus();
+ }
+ }
+
+ private void LabelDopColor_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)
+ {
+ var color = e.Data.GetData(typeof(Color));
+ if (color != null)
+ {
+ (sender as Label).BackColor = (Color)color;
+ }
+ if (_bus != null)
+ {
+ if (_bus is DrawningDoubleDeckerBus bus)
+ {
+ bus.SetDopColor((Color)color);
+ DrawBus();
+ }
+ DrawBus();
+ }
+ }
+
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddBus?.Invoke(_bus);
+ Close();
+ }
+ }
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.resx b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs
index 88ee7df..006bd75 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormMapWithSetBuses.cs
@@ -31,6 +31,7 @@ namespace DoubleDeckerBus
}
}
+
private void ReloadMaps()
{
int index = listBoxMaps.SelectedIndex;
@@ -52,34 +53,28 @@ namespace DoubleDeckerBus
}
private void ButtonAddBus_Click(object sender, EventArgs e)
+ {
+ var formBusConfig = new FormBusConfig();
+ formBusConfig.AddEvent(AddBus);
+ formBusConfig.Show();
+ }
+ private void AddBus(DrawningBus bus)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
- FormBus form = new();
- if (form.ShowDialog() == DialogResult.OK)
+ DrawningObjectBus boat = new(bus);
+ if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
{
- if (form.SelectedBus == null)
- {
- MessageBox.Show("Вы не создали объект");
- return;
- }
-
- DrawningObjectBus bus = new(form.SelectedBus);
-
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + bus != -1)
- {
- MessageBox.Show("Объект добавлен");
- pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
}
}
-
private void ButtonRemoveBus_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))