diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/DelegateLoco.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/DelegateLoco.cs
new file mode 100644
index 0000000..69a55d3
--- /dev/null
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/DelegateLoco.cs
@@ -0,0 +1,15 @@
+using ProjectElectricLocomotive.DrawingObjects;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectElectricLocomotive
+{
+ ///
+ /// Делегат для передачи объекта-локомотив
+ ///
+ ///
+ public delegate void LocoDelegate(DrawingLocomotive loco);
+}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingElectricLocomotive.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingElectricLocomotive.cs
index b730aca..f944efc 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingElectricLocomotive.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingElectricLocomotive.cs
@@ -24,10 +24,8 @@ namespace ProjectElectricLocomotive.DrawingObjects
return;
}
- Pen pen = new(Color.Black);
+ Pen pen = new Pen(electricLocomotive.AdditionalColor);
Brush blackBrush = new SolidBrush(Color.Black);
- Brush windows = new SolidBrush(Color.LightBlue);
- Brush bodyColor = new SolidBrush(electricLocomotive.BodyColor);
Brush additionalBrush = new SolidBrush(electricLocomotive.AdditionalColor);
if (electricLocomotive.Horns)
@@ -42,9 +40,14 @@ namespace ProjectElectricLocomotive.DrawingObjects
if (electricLocomotive.SeifBatteries)
{
- g.FillRectangle(blackBrush, _startPosX + 80, _startPosY + 30, 5, 10);
+ g.FillRectangle(additionalBrush, _startPosX + 80, _startPosY + 30, 5, 10);
}
base.DrawTransport(g);
}
+
+ public void SetAddColor(Color color)
+ {
+ (EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color);
+ }
}
}
\ No newline at end of file
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingLocomotive.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingLocomotive.cs
index 9106a51..3ef07d0 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingLocomotive.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/DrawingLocomotive.cs
@@ -14,9 +14,9 @@ namespace ProjectElectricLocomotive.DrawingObjects
{
public EntityLocomotive? EntityLocomotive { get; protected set; }
- protected int _pictureWidth;
+ public int _pictureWidth;
- protected int _pictureHeight;
+ public int _pictureHeight;
protected int _startPosX;
@@ -196,5 +196,10 @@ namespace ProjectElectricLocomotive.DrawingObjects
DirectionType.Down => _startPosY + EntityLocomotive.Step < _pictureHeight,
};
}
+
+ public void SetColor(Color color)
+ {
+ (EntityLocomotive as EntityLocomotive).SetColor(color);
+ }
}
}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityElectricLocomotive.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityElectricLocomotive.cs
index 07c8bac..2da83a0 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityElectricLocomotive.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityElectricLocomotive.cs
@@ -19,5 +19,10 @@ namespace ProjectElectricLocomotive.Entities
Horns = horns;
SeifBatteries = seifBatteries;
}
+
+ public void SetAdditionalColor(Color color)
+ {
+ AdditionalColor = color;
+ }
}
}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityLocomotive.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityLocomotive.cs
index 9adfee6..ef4f531 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityLocomotive.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/EntityLocomotive.cs
@@ -18,5 +18,10 @@ namespace ProjectElectricLocomotive.Entities
Weight = weight;
BodyColor = bodyColor;
}
+
+ public void SetColor(Color color)
+ {
+ BodyColor = color;
+ }
}
}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs
index e58d54b..7d4cae9 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.cs
@@ -18,7 +18,6 @@ namespace ProjectElectricLocomotive
public partial class FormLocomotiveCollections : Form
{
private readonly LocomotiveGenericStorage _storage;
- //private readonly LocomotiveGenericCollection _locomotives;
public FormLocomotiveCollections()
{
InitializeComponent();
@@ -79,6 +78,15 @@ namespace ProjectElectricLocomotive
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
+ var formLocomotiveConfig = new FormLocomotiveConfig();
+ formLocomotiveConfig.AddEvent(addLoco);
+ formLocomotiveConfig.Show();
+ }
+
+ public void addLoco(DrawingLocomotive loco)
+ {
+ loco._pictureWidth = pictureBoxCollections.Width;
+ loco._pictureHeight = pictureBoxCollections.Height;
if (listBoxStorage.SelectedIndex == -1) return;
@@ -88,19 +96,15 @@ namespace ProjectElectricLocomotive
return;
}
- FormElectricLocomotive form = new();
- if (form.ShowDialog() == DialogResult.OK)
+ //проверяем, удалось ли нам загрузить объект
+ if (obj + loco > -1)
{
- //проверяем, удалось ли нам загрузить объект
- if (obj + form.SelectedLocomotive > -1)
- {
- MessageBox.Show("Объект добавлен");
- pictureBoxCollections.Image = obj.ShowLocomotives();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollections.Image = obj.ShowLocomotives();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
}
}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.Designer.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.Designer.cs
index 8ed9310..218c423 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.Designer.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.Designer.cs
@@ -29,33 +29,34 @@
private void InitializeComponent()
{
this.groupBoxObjectParameters = new System.Windows.Forms.GroupBox();
- this.groupBoxColors = new System.Windows.Forms.GroupBox();
- this.labelSpeed = new System.Windows.Forms.Label();
- this.labelWeight = new System.Windows.Forms.Label();
- this.labelSimpleObject = new System.Windows.Forms.Label();
- this.labelModifiedObject = new System.Windows.Forms.Label();
- this.checkBoxHorns = new System.Windows.Forms.CheckBox();
- this.checkBoxSeifBatteries = new System.Windows.Forms.CheckBox();
- this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
- this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel3 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel4 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel5 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel7 = new System.Windows.Forms.FlowLayoutPanel();
- this.flowLayoutPanel8 = new System.Windows.Forms.FlowLayoutPanel();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.checkBoxSeifBatteries = new System.Windows.Forms.CheckBox();
+ this.checkBoxHorns = new System.Windows.Forms.CheckBox();
+ this.labelModifiedObject = new System.Windows.Forms.Label();
+ this.labelSimpleObject = new System.Windows.Forms.Label();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.groupBoxColors = new System.Windows.Forms.GroupBox();
+ this.panelPastelViolet = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelLilac = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelSkyBlue = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelGreen = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelYellow = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelOrange = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelPink = new System.Windows.Forms.FlowLayoutPanel();
+ this.panelPastelRed = new System.Windows.Forms.FlowLayoutPanel();
this.panelObject = new System.Windows.Forms.Panel();
+ this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.labelAddColor = new System.Windows.Forms.Label();
this.labelColor = new System.Windows.Forms.Label();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.pictureBoxObject = new System.Windows.Forms.PictureBox();
+ this.ButtonOk = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.groupBoxObjectParameters.SuspendLayout();
- this.groupBoxColors.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
+ this.groupBoxColors.SuspendLayout();
this.panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.SuspendLayout();
@@ -80,81 +81,27 @@
this.groupBoxObjectParameters.TabStop = false;
this.groupBoxObjectParameters.Text = "Параметры";
//
- // groupBoxColors
+ // numericUpDownWeight
//
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel5);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel6);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel7);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel8);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel4);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel3);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel2);
- this.groupBoxColors.Controls.Add(this.flowLayoutPanel1);
- this.groupBoxColors.Location = new System.Drawing.Point(390, 22);
- this.groupBoxColors.Name = "groupBoxColors";
- this.groupBoxColors.Size = new System.Drawing.Size(378, 176);
- this.groupBoxColors.TabIndex = 0;
- this.groupBoxColors.TabStop = false;
- this.groupBoxColors.Text = "Цвета";
- //
- // labelSpeed
- //
- this.labelSpeed.AutoSize = true;
- this.labelSpeed.Location = new System.Drawing.Point(19, 36);
- this.labelSpeed.Name = "labelSpeed";
- this.labelSpeed.Size = new System.Drawing.Size(73, 20);
- this.labelSpeed.TabIndex = 1;
- this.labelSpeed.Text = "Скорость";
- //
- // labelWeight
- //
- this.labelWeight.AutoSize = true;
- this.labelWeight.Location = new System.Drawing.Point(19, 94);
- this.labelWeight.Name = "labelWeight";
- this.labelWeight.Size = new System.Drawing.Size(33, 20);
- this.labelWeight.TabIndex = 2;
- this.labelWeight.Text = "Вес";
- //
- // labelSimpleObject
- //
- this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.labelSimpleObject.Location = new System.Drawing.Point(390, 239);
- this.labelSimpleObject.Name = "labelSimpleObject";
- this.labelSimpleObject.Size = new System.Drawing.Size(113, 44);
- this.labelSimpleObject.TabIndex = 3;
- this.labelSimpleObject.Text = "Простой";
- this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
- //
- // labelModifiedObject
- //
- this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.labelModifiedObject.Location = new System.Drawing.Point(655, 239);
- this.labelModifiedObject.Name = "labelModifiedObject";
- this.labelModifiedObject.Size = new System.Drawing.Size(113, 44);
- this.labelModifiedObject.TabIndex = 4;
- this.labelModifiedObject.Text = "Продвинутый";
- this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // checkBoxHorns
- //
- this.checkBoxHorns.AutoSize = true;
- this.checkBoxHorns.Location = new System.Drawing.Point(19, 174);
- this.checkBoxHorns.Name = "checkBoxHorns";
- this.checkBoxHorns.Size = new System.Drawing.Size(199, 24);
- this.checkBoxHorns.TabIndex = 5;
- this.checkBoxHorns.Text = "Признак наличия рогов";
- this.checkBoxHorns.UseVisualStyleBackColor = true;
- //
- // checkBoxSeifBatteries
- //
- this.checkBoxSeifBatteries.AutoSize = true;
- this.checkBoxSeifBatteries.Location = new System.Drawing.Point(19, 259);
- this.checkBoxSeifBatteries.Name = "checkBoxSeifBatteries";
- this.checkBoxSeifBatteries.Size = new System.Drawing.Size(297, 24);
- this.checkBoxSeifBatteries.TabIndex = 6;
- this.checkBoxSeifBatteries.Text = "Признак наличия батарейного отсека";
- this.checkBoxSeifBatteries.UseVisualStyleBackColor = true;
+ this.numericUpDownWeight.Location = new System.Drawing.Point(108, 92);
+ this.numericUpDownWeight.Maximum = new decimal(new int[] {
+ 1000,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownWeight.Minimum = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownWeight.Name = "numericUpDownWeight";
+ this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
+ this.numericUpDownWeight.TabIndex = 8;
+ this.numericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
//
// numericUpDownSpeed
//
@@ -178,91 +125,154 @@
0,
0});
//
- // numericUpDownWeight
+ // checkBoxSeifBatteries
//
- this.numericUpDownWeight.Location = new System.Drawing.Point(108, 92);
- this.numericUpDownWeight.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDownWeight.Minimum = new decimal(new int[] {
- 100,
- 0,
- 0,
- 0});
- this.numericUpDownWeight.Name = "numericUpDownWeight";
- this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
- this.numericUpDownWeight.TabIndex = 8;
- this.numericUpDownWeight.Value = new decimal(new int[] {
- 100,
- 0,
- 0,
- 0});
+ this.checkBoxSeifBatteries.AutoSize = true;
+ this.checkBoxSeifBatteries.Location = new System.Drawing.Point(19, 259);
+ this.checkBoxSeifBatteries.Name = "checkBoxSeifBatteries";
+ this.checkBoxSeifBatteries.Size = new System.Drawing.Size(297, 24);
+ this.checkBoxSeifBatteries.TabIndex = 6;
+ this.checkBoxSeifBatteries.Text = "Признак наличия батарейного отсека";
+ this.checkBoxSeifBatteries.UseVisualStyleBackColor = true;
//
- // flowLayoutPanel1
+ // checkBoxHorns
//
- this.flowLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
- this.flowLayoutPanel1.Location = new System.Drawing.Point(55, 35);
- this.flowLayoutPanel1.Name = "flowLayoutPanel1";
- this.flowLayoutPanel1.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel1.TabIndex = 0;
+ this.checkBoxHorns.AutoSize = true;
+ this.checkBoxHorns.Location = new System.Drawing.Point(19, 174);
+ this.checkBoxHorns.Name = "checkBoxHorns";
+ this.checkBoxHorns.Size = new System.Drawing.Size(199, 24);
+ this.checkBoxHorns.TabIndex = 5;
+ this.checkBoxHorns.Text = "Признак наличия рогов";
+ this.checkBoxHorns.UseVisualStyleBackColor = true;
//
- // flowLayoutPanel2
+ // labelModifiedObject
//
- this.flowLayoutPanel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
- this.flowLayoutPanel2.Location = new System.Drawing.Point(132, 35);
- this.flowLayoutPanel2.Name = "flowLayoutPanel2";
- this.flowLayoutPanel2.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel2.TabIndex = 1;
+ this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelModifiedObject.Location = new System.Drawing.Point(655, 239);
+ this.labelModifiedObject.Name = "labelModifiedObject";
+ this.labelModifiedObject.Size = new System.Drawing.Size(113, 44);
+ this.labelModifiedObject.TabIndex = 4;
+ this.labelModifiedObject.Text = "Продвинутый";
+ this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
- // flowLayoutPanel3
+ // labelSimpleObject
//
- this.flowLayoutPanel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
- this.flowLayoutPanel3.Location = new System.Drawing.Point(207, 35);
- this.flowLayoutPanel3.Name = "flowLayoutPanel3";
- this.flowLayoutPanel3.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel3.TabIndex = 1;
+ this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelSimpleObject.Location = new System.Drawing.Point(390, 239);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(113, 44);
+ this.labelSimpleObject.TabIndex = 3;
+ this.labelSimpleObject.Text = "Простой";
+ this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
- // flowLayoutPanel4
+ // labelWeight
//
- this.flowLayoutPanel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
- this.flowLayoutPanel4.Location = new System.Drawing.Point(281, 35);
- this.flowLayoutPanel4.Name = "flowLayoutPanel4";
- this.flowLayoutPanel4.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel4.TabIndex = 1;
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(19, 94);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(33, 20);
+ this.labelWeight.TabIndex = 2;
+ this.labelWeight.Text = "Вес";
//
- // flowLayoutPanel5
+ // labelSpeed
//
- this.flowLayoutPanel5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.flowLayoutPanel5.Location = new System.Drawing.Point(281, 110);
- this.flowLayoutPanel5.Name = "flowLayoutPanel5";
- this.flowLayoutPanel5.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel5.TabIndex = 3;
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(19, 36);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(73, 20);
+ this.labelSpeed.TabIndex = 1;
+ this.labelSpeed.Text = "Скорость";
//
- // flowLayoutPanel6
+ // groupBoxColors
//
- this.flowLayoutPanel6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
- this.flowLayoutPanel6.Location = new System.Drawing.Point(207, 110);
- this.flowLayoutPanel6.Name = "flowLayoutPanel6";
- this.flowLayoutPanel6.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel6.TabIndex = 4;
+ this.groupBoxColors.Controls.Add(this.panelPastelViolet);
+ this.groupBoxColors.Controls.Add(this.panelPastelLilac);
+ this.groupBoxColors.Controls.Add(this.panelSkyBlue);
+ this.groupBoxColors.Controls.Add(this.panelPastelGreen);
+ this.groupBoxColors.Controls.Add(this.panelPastelYellow);
+ this.groupBoxColors.Controls.Add(this.panelPastelOrange);
+ this.groupBoxColors.Controls.Add(this.panelPastelPink);
+ this.groupBoxColors.Controls.Add(this.panelPastelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(390, 22);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(378, 176);
+ this.groupBoxColors.TabIndex = 0;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Цвета";
//
- // flowLayoutPanel7
+ // panelPastelViolet
//
- this.flowLayoutPanel7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.flowLayoutPanel7.Location = new System.Drawing.Point(132, 110);
- this.flowLayoutPanel7.Name = "flowLayoutPanel7";
- this.flowLayoutPanel7.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel7.TabIndex = 5;
+ this.panelPastelViolet.AllowDrop = true;
+ this.panelPastelViolet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
+ this.panelPastelViolet.Location = new System.Drawing.Point(281, 110);
+ this.panelPastelViolet.Name = "panelPastelViolet";
+ this.panelPastelViolet.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelViolet.TabIndex = 3;
//
- // flowLayoutPanel8
+ // panelPastelLilac
//
- this.flowLayoutPanel8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
- this.flowLayoutPanel8.Location = new System.Drawing.Point(55, 110);
- this.flowLayoutPanel8.Name = "flowLayoutPanel8";
- this.flowLayoutPanel8.Size = new System.Drawing.Size(40, 40);
- this.flowLayoutPanel8.TabIndex = 2;
+ this.panelPastelLilac.AllowDrop = true;
+ this.panelPastelLilac.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
+ this.panelPastelLilac.Location = new System.Drawing.Point(207, 110);
+ this.panelPastelLilac.Name = "panelPastelLilac";
+ this.panelPastelLilac.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelLilac.TabIndex = 4;
+ //
+ // panelSkyBlue
+ //
+ this.panelSkyBlue.AllowDrop = true;
+ this.panelSkyBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+ this.panelSkyBlue.Location = new System.Drawing.Point(132, 110);
+ this.panelSkyBlue.Name = "panelSkyBlue";
+ this.panelSkyBlue.Size = new System.Drawing.Size(40, 40);
+ this.panelSkyBlue.TabIndex = 5;
+ //
+ // panelPastelGreen
+ //
+ this.panelPastelGreen.AllowDrop = true;
+ this.panelPastelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
+ this.panelPastelGreen.Location = new System.Drawing.Point(55, 110);
+ this.panelPastelGreen.Name = "panelPastelGreen";
+ this.panelPastelGreen.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelGreen.TabIndex = 2;
+ //
+ // panelPastelYellow
+ //
+ this.panelPastelYellow.AllowDrop = true;
+ this.panelPastelYellow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
+ this.panelPastelYellow.Location = new System.Drawing.Point(281, 35);
+ this.panelPastelYellow.Name = "panelPastelYellow";
+ this.panelPastelYellow.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelYellow.TabIndex = 1;
+ //
+ // panelPastelOrange
+ //
+ this.panelPastelOrange.AllowDrop = true;
+ this.panelPastelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
+ this.panelPastelOrange.Location = new System.Drawing.Point(207, 35);
+ this.panelPastelOrange.Name = "panelPastelOrange";
+ this.panelPastelOrange.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelOrange.TabIndex = 1;
+ //
+ // panelPastelPink
+ //
+ this.panelPastelPink.AllowDrop = true;
+ this.panelPastelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
+ this.panelPastelPink.Location = new System.Drawing.Point(132, 35);
+ this.panelPastelPink.Name = "panelPastelPink";
+ this.panelPastelPink.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelPink.TabIndex = 1;
+ //
+ // panelPastelRed
+ //
+ this.panelPastelRed.AllowDrop = true;
+ this.panelPastelRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
+ this.panelPastelRed.Location = new System.Drawing.Point(55, 35);
+ this.panelPastelRed.Name = "panelPastelRed";
+ this.panelPastelRed.Size = new System.Drawing.Size(40, 40);
+ this.panelPastelRed.TabIndex = 0;
//
// panelObject
//
@@ -274,44 +284,8 @@
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(392, 300);
this.panelObject.TabIndex = 1;
- //
- // labelAddColor
- //
- this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.labelAddColor.Location = new System.Drawing.Point(260, 21);
- this.labelAddColor.Name = "labelAddColor";
- this.labelAddColor.Size = new System.Drawing.Size(113, 44);
- this.labelAddColor.TabIndex = 6;
- this.labelAddColor.Text = "Доп. Цвет";
- this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // labelColor
- //
- this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.labelColor.Location = new System.Drawing.Point(19, 21);
- this.labelColor.Name = "labelColor";
- this.labelColor.Size = new System.Drawing.Size(113, 44);
- this.labelColor.TabIndex = 5;
- this.labelColor.Text = "Цвет";
- this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(813, 341);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(131, 49);
- this.button1.TabIndex = 2;
- this.button1.Text = "Добавить";
- this.button1.UseVisualStyleBackColor = true;
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(1072, 341);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(131, 49);
- this.button2.TabIndex = 3;
- this.button2.Text = "Отмена";
- this.button2.UseVisualStyleBackColor = true;
+ this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBoxObject
//
@@ -321,22 +295,67 @@
this.pictureBoxObject.TabIndex = 7;
this.pictureBoxObject.TabStop = false;
//
+ // labelAddColor
+ //
+ this.labelAddColor.AllowDrop = true;
+ this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelAddColor.Location = new System.Drawing.Point(260, 21);
+ this.labelAddColor.Name = "labelAddColor";
+ this.labelAddColor.Size = new System.Drawing.Size(113, 44);
+ this.labelAddColor.TabIndex = 6;
+ this.labelAddColor.Text = "Доп. Цвет";
+ this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
+ this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
+ //
+ // labelColor
+ //
+ this.labelColor.AllowDrop = true;
+ this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelColor.Location = new System.Drawing.Point(19, 21);
+ this.labelColor.Name = "labelColor";
+ this.labelColor.Size = new System.Drawing.Size(113, 44);
+ this.labelColor.TabIndex = 5;
+ 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_DragDrop);
+ //
+ // ButtonOk
+ //
+ this.ButtonOk.Location = new System.Drawing.Point(813, 341);
+ this.ButtonOk.Name = "ButtonOk";
+ this.ButtonOk.Size = new System.Drawing.Size(131, 49);
+ this.ButtonOk.TabIndex = 2;
+ this.ButtonOk.Text = "Добавить";
+ this.ButtonOk.UseVisualStyleBackColor = true;
+ this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(1072, 341);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(131, 49);
+ this.buttonCancel.TabIndex = 3;
+ this.buttonCancel.Text = "Отмена";
+ 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(1219, 419);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.ButtonOk);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxObjectParameters);
this.Name = "FormLocomotiveConfig";
this.Text = "FormLocomotiveConfig";
this.groupBoxObjectParameters.ResumeLayout(false);
this.groupBoxObjectParameters.PerformLayout();
- this.groupBoxColors.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ this.groupBoxColors.ResumeLayout(false);
this.panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.ResumeLayout(false);
@@ -355,19 +374,20 @@
private CheckBox checkBoxHorns;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
- private FlowLayoutPanel flowLayoutPanel5;
- private FlowLayoutPanel flowLayoutPanel6;
- private FlowLayoutPanel flowLayoutPanel7;
- private FlowLayoutPanel flowLayoutPanel8;
- private FlowLayoutPanel flowLayoutPanel4;
- private FlowLayoutPanel flowLayoutPanel3;
- private FlowLayoutPanel flowLayoutPanel2;
- private FlowLayoutPanel flowLayoutPanel1;
+ private FlowLayoutPanel panelPastelViolet;
+ private FlowLayoutPanel panelPastelLilac;
+ private FlowLayoutPanel panelSkyBlue;
+ private FlowLayoutPanel panelPastelGreen;
+ private FlowLayoutPanel panelPastelYellow;
+ private FlowLayoutPanel panelPastelOrange;
+ private FlowLayoutPanel panelPastelPink;
+ private FlowLayoutPanel panelPastelRed;
private Panel panelObject;
private PictureBox pictureBoxObject;
private Label labelAddColor;
private Label labelColor;
- private Button button1;
- private Button button2;
+ private Button ButtonOk;
+ private Button buttonCancel;
+ private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}
\ No newline at end of file
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.cs
index e6b7812..e2b8330 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.cs
@@ -13,13 +13,6 @@ namespace ProjectElectricLocomotive
{
public partial class FormLocomotiveConfig : Form
{
-
- ///
- /// Делегат для передачи объекта-локомотив
- ///
- ///
- public delegate void LocoDelegate(DrawingLocomotive loco);
-
///
/// Переменная-выбранный локомотив
///
@@ -33,6 +26,33 @@ namespace ProjectElectricLocomotive
public FormLocomotiveConfig()
{
InitializeComponent();
+
+ panelPastelRed.MouseDown += PanelColor_MouseDown;
+ panelPastelPink.MouseDown += PanelColor_MouseDown;
+ panelPastelOrange.MouseDown += PanelColor_MouseDown;
+ panelPastelYellow.MouseDown += PanelColor_MouseDown;
+ panelSkyBlue.MouseDown += PanelColor_MouseDown;
+ panelPastelGreen.MouseDown += PanelColor_MouseDown;
+ panelPastelLilac.MouseDown += PanelColor_MouseDown;
+ panelPastelViolet.MouseDown += PanelColor_MouseDown;
+
+ buttonCancel.Click += (sender, e) => Close();
+ }
+
+ ///
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(LocoDelegate ev)
+ {
+ if (EventAddLoco == null)
+ {
+ EventAddLoco = ev;
+ }
+ else
+ {
+ EventAddLoco += ev;
+ }
}
///
@@ -42,7 +62,7 @@ namespace ProjectElectricLocomotive
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
- _loco?.SetPosition(5, 5);
+ _loco?.SetPosition(10, 10);
_loco?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
@@ -50,7 +70,7 @@ namespace ProjectElectricLocomotive
///
/// Передаем информацию при нажатии на Label
///
- ///
+ ///
///
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
@@ -87,8 +107,8 @@ namespace ProjectElectricLocomotive
case "labelSimpleObject":
_loco = new DrawingLocomotive(
(int)numericUpDownSpeed.Value,
- (int)numericUpDownWeight.Value,
- Color.White,
+ (int)numericUpDownWeight.Value,
+ Color.White,
pictureBoxObject.Width,
pictureBoxObject.Height
);
@@ -96,11 +116,11 @@ namespace ProjectElectricLocomotive
case "labelModifiedObject":
_loco = new DrawingElectricLocomotive(
(int)numericUpDownSpeed.Value,
- (int)numericUpDownWeight.Value,
- Color.White,
- Color.Black,
+ (int)numericUpDownWeight.Value,
+ Color.White,
+ Color.Black,
checkBoxHorns.Checked,
- checkBoxSeifBatteries.Checked,
+ checkBoxSeifBatteries.Checked,
pictureBoxObject.Width,
pictureBoxObject.Height
);
@@ -108,5 +128,58 @@ namespace ProjectElectricLocomotive
}
DrawLoco();
}
+
+
+ // НЕ УВЕРЕНА, ЧТО ВЕРНО
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
+ DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void LabelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
+ switch (((Label)sender).Name)
+ {
+ case "labelColor":
+ _loco.SetColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ case "labelAddColor":
+ if (_loco is not DrawingLocomotive) return;
+ else
+ {
+ (_loco as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ break;
+ }
+ DrawLoco();
+ }
+
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
+
+ ///
+ /// Добавление loco
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddLoco?.Invoke(_loco);
+ Close();
+ }
}
}
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.resx b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.resx
index f298a7b..8453790 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.resx
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveConfig.resx
@@ -57,4 +57,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file
diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs
index cb58d4b..ecb9eaf 100644
--- a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs
+++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericCollection.cs
@@ -84,7 +84,6 @@ namespace ProjectElectricLocomotive.Generics
private void DrawObjects(Graphics g)
{
int HeightObjCount = _pictureHeight / _placeSizeHeight;
- int WidthObjCount = _pictureWidth / _placeSizeWidth;
for (int i = 0; i < _collection.Count; i++)
{
T? type = _collection[i];