diff --git a/Locomotive/Locomotive/DrawningLocomotive.cs b/Locomotive/Locomotive/DrawningLocomotive.cs
index 827d7d2..9615e6e 100644
--- a/Locomotive/Locomotive/DrawningLocomotive.cs
+++ b/Locomotive/Locomotive/DrawningLocomotive.cs
@@ -38,6 +38,20 @@ namespace Locomotive
_locomotiveHeight = locomotiveHeight;
}
+ public void SetBaseColor(Color color)
+ {
+ if (Locomotive is EntityWarmlyLocomotive)
+ {
+ Locomotive = (EntityWarmlyLocomotive)Locomotive;
+ if (Locomotive is not null)
+ {
+ Locomotive = new EntityWarmlyLocomotive(Locomotive.Speed, Locomotive.Weight, color, (Locomotive as EntityWarmlyLocomotive).ExtraColor, (Locomotive as EntityWarmlyLocomotive).Pipe, (Locomotive as EntityWarmlyLocomotive).FuelStorage);
+ return;
+ }
+ }
+ Locomotive = new EntityLocomotive(Locomotive.Speed, Locomotive.Weight, color);
+ }
+
/// Установка позиции локомотива
public void SetPosition(int x, int y, int width, int height)
{
diff --git a/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs b/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs
index dbb2b78..0f3af01 100644
--- a/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs
+++ b/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs
@@ -14,6 +14,15 @@ namespace Locomotive
Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage);
}
+ public void SetExtraColor(Color color)
+ {
+ Locomotive = Locomotive as EntityWarmlyLocomotive;
+ if (Locomotive is not null)
+ {
+ Locomotive = new EntityWarmlyLocomotive(Locomotive.Speed, Locomotive.Weight, Locomotive.BodyColor, color, (Locomotive as EntityWarmlyLocomotive).Pipe, (Locomotive as EntityWarmlyLocomotive).FuelStorage);
+ }
+ }
+
public override void DrawTransport(Graphics g)
{
if (Locomotive is not EntityWarmlyLocomotive warmlyLocomotive)
diff --git a/Locomotive/Locomotive/EntityElectroLocomotive.cs b/Locomotive/Locomotive/EntityWarmlyLocomotive.cs
similarity index 100%
rename from Locomotive/Locomotive/EntityElectroLocomotive.cs
rename to Locomotive/Locomotive/EntityWarmlyLocomotive.cs
diff --git a/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs b/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs
new file mode 100644
index 0000000..77cf4bf
--- /dev/null
+++ b/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs
@@ -0,0 +1,371 @@
+namespace Locomotive
+{
+ partial class FormLocomotiveConfig
+ {
+ ///
+ /// 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.panelGreen = new System.Windows.Forms.Panel();
+ this.panelBlue = new System.Windows.Forms.Panel();
+ this.panelRed = new System.Windows.Forms.Panel();
+ this.checkBoxFuelStorage = new System.Windows.Forms.CheckBox();
+ this.checkBoxPipe = new System.Windows.Forms.CheckBox();
+ this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.panelObject = new System.Windows.Forms.Panel();
+ this.labelDopColor = new System.Windows.Forms.Label();
+ this.labelBaseColor = new System.Windows.Forms.Label();
+ this.pictureBoxObject = new System.Windows.Forms.PictureBox();
+ 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();
+ this.panelObject.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
+ 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.checkBoxFuelStorage);
+ this.groupBoxConfig.Controls.Add(this.checkBoxPipe);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
+ this.groupBoxConfig.Controls.Add(this.labelWeight);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
+ 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(453, 260);
+ this.groupBoxConfig.TabIndex = 0;
+ this.groupBoxConfig.TabStop = false;
+ this.groupBoxConfig.Text = "Configuration";
+ //
+ // labelModifiedObject
+ //
+ this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelModifiedObject.Location = new System.Drawing.Point(312, 200);
+ this.labelModifiedObject.Name = "labelModifiedObject";
+ this.labelModifiedObject.Size = new System.Drawing.Size(115, 45);
+ this.labelModifiedObject.TabIndex = 8;
+ this.labelModifiedObject.Text = "Modified";
+ 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(179, 200);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(115, 45);
+ this.labelSimpleObject.TabIndex = 7;
+ this.labelSimpleObject.Text = "Simple";
+ 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.panelGreen);
+ this.groupBoxColors.Controls.Add(this.panelBlue);
+ this.groupBoxColors.Controls.Add(this.panelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(179, 26);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(248, 156);
+ this.groupBoxColors.TabIndex = 6;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Colors";
+ //
+ // panelPurple
+ //
+ this.panelPurple.BackColor = System.Drawing.Color.Fuchsia;
+ this.panelPurple.Location = new System.Drawing.Point(193, 102);
+ this.panelPurple.Name = "panelPurple";
+ this.panelPurple.Size = new System.Drawing.Size(43, 40);
+ this.panelPurple.TabIndex = 3;
+ //
+ // panelBlack
+ //
+ this.panelBlack.BackColor = System.Drawing.Color.Black;
+ this.panelBlack.Location = new System.Drawing.Point(132, 102);
+ this.panelBlack.Name = "panelBlack";
+ this.panelBlack.Size = new System.Drawing.Size(43, 40);
+ this.panelBlack.TabIndex = 2;
+ //
+ // panelGray
+ //
+ this.panelGray.BackColor = System.Drawing.Color.Gray;
+ this.panelGray.Location = new System.Drawing.Point(72, 102);
+ this.panelGray.Name = "panelGray";
+ this.panelGray.Size = new System.Drawing.Size(43, 40);
+ this.panelGray.TabIndex = 3;
+ //
+ // panelWhite
+ //
+ this.panelWhite.BackColor = System.Drawing.Color.White;
+ this.panelWhite.Location = new System.Drawing.Point(11, 102);
+ this.panelWhite.Name = "panelWhite";
+ this.panelWhite.Size = new System.Drawing.Size(43, 40);
+ this.panelWhite.TabIndex = 2;
+ //
+ // panelYellow
+ //
+ this.panelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.panelYellow.Location = new System.Drawing.Point(193, 31);
+ this.panelYellow.Name = "panelYellow";
+ this.panelYellow.Size = new System.Drawing.Size(43, 40);
+ this.panelYellow.TabIndex = 1;
+ //
+ // panelGreen
+ //
+ this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
+ this.panelGreen.Location = new System.Drawing.Point(72, 31);
+ this.panelGreen.Name = "panelGreen";
+ this.panelGreen.Size = new System.Drawing.Size(43, 40);
+ this.panelGreen.TabIndex = 1;
+ //
+ // panelBlue
+ //
+ this.panelBlue.BackColor = System.Drawing.Color.Blue;
+ this.panelBlue.Location = new System.Drawing.Point(133, 31);
+ this.panelBlue.Name = "panelBlue";
+ this.panelBlue.Size = new System.Drawing.Size(43, 40);
+ this.panelBlue.TabIndex = 1;
+ //
+ // panelRed
+ //
+ this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.Location = new System.Drawing.Point(11, 31);
+ this.panelRed.Name = "panelRed";
+ this.panelRed.Size = new System.Drawing.Size(43, 40);
+ this.panelRed.TabIndex = 0;
+ //
+ // checkBoxFuelStorage
+ //
+ this.checkBoxFuelStorage.AutoSize = true;
+ this.checkBoxFuelStorage.Location = new System.Drawing.Point(7, 158);
+ this.checkBoxFuelStorage.Name = "checkBoxFuelStorage";
+ this.checkBoxFuelStorage.Size = new System.Drawing.Size(146, 24);
+ this.checkBoxFuelStorage.TabIndex = 5;
+ this.checkBoxFuelStorage.Text = "Add Fuel Storage";
+ this.checkBoxFuelStorage.UseVisualStyleBackColor = true;
+ //
+ // checkBoxPipe
+ //
+ this.checkBoxPipe.AutoSize = true;
+ this.checkBoxPipe.Location = new System.Drawing.Point(7, 128);
+ this.checkBoxPipe.Name = "checkBoxPipe";
+ this.checkBoxPipe.Size = new System.Drawing.Size(92, 24);
+ this.checkBoxPipe.TabIndex = 4;
+ this.checkBoxPipe.Text = "Add Pipe";
+ this.checkBoxPipe.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ this.numericUpDownWeight.Location = new System.Drawing.Point(75, 75);
+ this.numericUpDownWeight.Maximum = new decimal(new int[] {
+ 500,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownWeight.Name = "numericUpDownWeight";
+ this.numericUpDownWeight.Size = new System.Drawing.Size(68, 27);
+ this.numericUpDownWeight.TabIndex = 3;
+ this.numericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // labelWeight
+ //
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(7, 77);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(63, 20);
+ this.labelWeight.TabIndex = 2;
+ this.labelWeight.Text = "Weight: ";
+ //
+ // numericUpDownSpeed
+ //
+ this.numericUpDownSpeed.Location = new System.Drawing.Point(74, 31);
+ this.numericUpDownSpeed.Maximum = new decimal(new int[] {
+ 500,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownSpeed.Name = "numericUpDownSpeed";
+ this.numericUpDownSpeed.Size = new System.Drawing.Size(69, 27);
+ this.numericUpDownSpeed.TabIndex = 1;
+ this.numericUpDownSpeed.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // labelSpeed
+ //
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(6, 33);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(62, 20);
+ this.labelSpeed.TabIndex = 0;
+ this.labelSpeed.Text = " Speed: ";
+ //
+ // panelObject
+ //
+ this.panelObject.AllowDrop = true;
+ this.panelObject.Controls.Add(this.labelDopColor);
+ this.panelObject.Controls.Add(this.labelBaseColor);
+ this.panelObject.Controls.Add(this.pictureBoxObject);
+ this.panelObject.Location = new System.Drawing.Point(471, 22);
+ this.panelObject.Name = "panelObject";
+ this.panelObject.Size = new System.Drawing.Size(419, 250);
+ this.panelObject.TabIndex = 1;
+ 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(232, 16);
+ this.labelDopColor.Name = "labelDopColor";
+ this.labelDopColor.Size = new System.Drawing.Size(115, 45);
+ this.labelDopColor.TabIndex = 9;
+ this.labelDopColor.Text = "Extra Color";
+ 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);
+ //
+ // labelBaseColor
+ //
+ this.labelBaseColor.AllowDrop = true;
+ this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelBaseColor.Location = new System.Drawing.Point(69, 16);
+ this.labelBaseColor.Name = "labelBaseColor";
+ this.labelBaseColor.Size = new System.Drawing.Size(115, 45);
+ this.labelBaseColor.TabIndex = 8;
+ this.labelBaseColor.Text = "Base Color";
+ this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragDrop);
+ this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragEnter);
+ //
+ // pictureBoxObject
+ //
+ this.pictureBoxObject.Location = new System.Drawing.Point(16, 67);
+ this.pictureBoxObject.Name = "pictureBoxObject";
+ this.pictureBoxObject.Size = new System.Drawing.Size(386, 168);
+ this.pictureBoxObject.TabIndex = 0;
+ this.pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(487, 278);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(168, 29);
+ this.buttonAdd.TabIndex = 2;
+ this.buttonAdd.Text = "Add";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(703, 278);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(170, 29);
+ this.buttonCancel.TabIndex = 3;
+ this.buttonCancel.Text = "Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormLocomotiveConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(902, 315);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.panelObject);
+ this.Controls.Add(this.groupBoxConfig);
+ this.Name = "FormLocomotiveConfig";
+ this.Text = "Object Creation";
+ this.groupBoxConfig.ResumeLayout(false);
+ this.groupBoxConfig.PerformLayout();
+ this.groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ this.panelObject.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelSpeed;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private CheckBox checkBoxFuelStorage;
+ private CheckBox checkBoxPipe;
+ private GroupBox groupBoxColors;
+ private Panel panelRed;
+ private Panel panelPurple;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelWhite;
+ private Panel panelYellow;
+ private Panel panelGreen;
+ private Panel panelBlue;
+ private Label labelSimpleObject;
+ private Label labelModifiedObject;
+ private Panel panelObject;
+ private PictureBox pictureBoxObject;
+ private Label labelDopColor;
+ private Label labelBaseColor;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Locomotive/Locomotive/FormLocomotiveConfig.cs b/Locomotive/Locomotive/FormLocomotiveConfig.cs
new file mode 100644
index 0000000..f016a97
--- /dev/null
+++ b/Locomotive/Locomotive/FormLocomotiveConfig.cs
@@ -0,0 +1,141 @@
+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 Locomotive
+{
+ public partial class FormLocomotiveConfig : Form
+ {
+ DrawningLocomotive _locomotive = null;
+
+ private event Action eventAddLocomotive;
+
+ public void AddEvent(Action ev)
+ {
+ if (eventAddLocomotive == null)
+ {
+ eventAddLocomotive = new Action(ev);
+ }
+ else
+ {
+ eventAddLocomotive += ev;
+ }
+ }
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ eventAddLocomotive?.Invoke(_locomotive);
+ Close();
+ }
+
+ public FormLocomotiveConfig()
+ {
+ 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 e) => Close();
+ }
+
+ 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))
+ {
+ 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":
+ _locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _locomotive = new DrawningWarmlyLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
+ Color.White, Color.Black,
+ checkBoxPipe.Checked, checkBoxFuelStorage.Checked);
+ break;
+ }
+ DrawLocomotive();
+ }
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void DrawLocomotive()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _locomotive?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
+ _locomotive?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ private void labelBaseColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void labelBaseColor_DragDrop(object sender, DragEventArgs e)
+ {
+ _locomotive.SetBaseColor((Color)e.Data.GetData(typeof(Color)));
+ DrawLocomotive();
+
+ }
+ 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)
+ {
+ if (_locomotive is DrawningWarmlyLocomotive)
+ {
+ var locomotive = _locomotive as DrawningWarmlyLocomotive;
+ locomotive.SetExtraColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawLocomotive();
+
+ }
+
+ }
+}
diff --git a/Locomotive/Locomotive/FormLocomotiveConfig.resx b/Locomotive/Locomotive/FormLocomotiveConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Locomotive/Locomotive/FormLocomotiveConfig.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/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
index a4dcc05..4c9a0ad 100644
--- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
+++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
@@ -86,26 +86,32 @@ namespace Locomotive
}
/// Добавление объекта
private void buttonAddLocomotive_Click(object sender, EventArgs e)
+ {
+ var formCarConfig = new FormLocomotiveConfig();
+ formCarConfig.AddEvent(new (AddLocomotive));
+ formCarConfig.Show();
+ }
+
+ private void AddLocomotive(DrawningLocomotive locomotive)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
- FormLocomotive form = new();
- if (form.ShowDialog() == DialogResult.OK)
+
+ if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectLocomotive(locomotive) != -1)
{
- DrawningObjectLocomotive locomotive = new(form.SelectedLocomotive);
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + locomotive != -1)
- {
- MessageBox.Show("Object added");
- pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
- {
- MessageBox.Show("Failed to add object");
- }
+ MessageBox.Show("Object added");
+ pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
+
+ else
+ {
+ MessageBox.Show("Failed to add object");
+ }
+
}
+
/// Удаление объекта
private void buttonRemoveLocomotive_Click(object sender, EventArgs e)
{