diff --git a/ProjectLocomotive/ProjectLocomotive/DrawningElectroLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/DrawningElectroLocomotive.cs index 07ffd1b..db8f44f 100644 --- a/ProjectLocomotive/ProjectLocomotive/DrawningElectroLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/DrawningElectroLocomotive.cs @@ -24,6 +24,15 @@ namespace ProjectLocomotive Locomotivе = new EntityElectricLocomotive(speed, weight, bodyColor, dopColor, electroLines, electroBattery); } + public void SetExtraColor(Color color) + { + var LocomotiveElectro = Locomotivе as EntityElectricLocomotive; + if (LocomotiveElectro is not null) + { + LocomotiveElectro = new EntityElectricLocomotive(LocomotiveElectro.Speed, LocomotiveElectro.Weight, LocomotiveElectro.BodyColor, color, LocomotiveElectro.ElectroLines, LocomotiveElectro.ElectroBattery); + Locomotivе = LocomotiveElectro; + } + } public override void DrawTransport(Graphics g) { if (Locomotivе is not EntityElectricLocomotive elLocc) @@ -31,7 +40,7 @@ namespace ProjectLocomotive return; } Pen pen = new(Color.Black); - Brush dopBrush = new SolidBrush(elLocc.DopColor); + if (elLocc.ElectroLines) { g.DrawLine(pen, _startPosX + 20, _startPosY, _startPosX + 5, _startPosY - 12); @@ -43,10 +52,10 @@ namespace ProjectLocomotive base.DrawTransport(g); if (elLocc.ElectroBattery) { - Brush brblack = new SolidBrush(Color.Black); - g.FillRectangle(brblack, _startPosX + 40, _startPosY + 25, 15, 5); - g.FillRectangle(brblack, _startPosX + 60, _startPosY + 25, 15, 5); - g.FillRectangle(brblack, _startPosX + 5, _startPosY + 25, 15, 5); + Brush dopBrush = new SolidBrush(elLocc.DopColor); + g.FillRectangle(dopBrush, _startPosX + 40, _startPosY + 25, 15, 5); + g.FillRectangle(dopBrush, _startPosX + 60, _startPosY + 25, 15, 5); + g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 25, 15, 5); } } } diff --git a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs index 0797b22..48ccbf7 100644 --- a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs @@ -64,6 +64,18 @@ namespace ProjectLocomotive _LocWidth = carWidth; _LocHeight = carHeight; } + public void SetBaseColor(Color color) + { + if (Locomotivе is EntityElectricLocomotive) + { + Locomotivе = (EntityElectricLocomotive)Locomotivе; + if (Locomotivе is not null) + { + Locomotivе = new EntityElectricLocomotive(Locomotivе.Speed, Locomotivе.Weight, color, (Locomotivе as EntityElectricLocomotive).DopColor, (Locomotivе as EntityElectricLocomotive).ElectroLines, (Locomotivе as EntityElectricLocomotive).ElectroBattery); + return; + } + } + } /// /// Установка позиции автомобиля /// diff --git a/ProjectLocomotive/ProjectLocomotive/EntityElectricLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/EntityElectricLocomotive.cs index 096cbc9..9edc44c 100644 --- a/ProjectLocomotive/ProjectLocomotive/EntityElectricLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/EntityElectricLocomotive.cs @@ -11,7 +11,7 @@ namespace ProjectLocomotive /// /// Дополнительный цвет /// - public Color DopColor { get; private set; } + public Color DopColor { get; set; } /// /// Признак наличия "рогов" для подключения /// @@ -34,8 +34,8 @@ namespace ProjectLocomotive base(speed, weight, bodyColor) { DopColor = dopColor; - ElectroLines = electroLines = true; - ElectroBattery = electroBattery = true; + ElectroLines = electroLines; + ElectroBattery = electroBattery; } } } diff --git a/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs index add3955..4782ac2 100644 --- a/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs @@ -19,7 +19,7 @@ namespace ProjectLocomotive /// /// Цвет кузова /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг передвижения локомотива /// diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs index 63c3771..bd67b24 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs @@ -188,9 +188,7 @@ this.ResumeLayout(false); this.PerformLayout(); } - #endregion - private PictureBox pictureBoxLocomotive; private Button buttonCreate; private Button buttonUp; diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.Designer.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.Designer.cs index 502b92d..9057d41 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.Designer.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.Designer.cs @@ -6,7 +6,6 @@ /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - /// /// Clean up any resources being used. /// @@ -19,9 +18,7 @@ } 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. @@ -71,32 +68,36 @@ 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.Location = new System.Drawing.Point(15, 15); + this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(4); this.groupBoxConfig.Name = "groupBoxConfig"; - this.groupBoxConfig.Size = new System.Drawing.Size(453, 260); + this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(4); + this.groupBoxConfig.Size = new System.Drawing.Size(566, 325); this.groupBoxConfig.TabIndex = 0; this.groupBoxConfig.TabStop = false; - this.groupBoxConfig.Text = "Configuration"; + this.groupBoxConfig.Text = "Конфигурация"; // // labelModifiedObject // this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelModifiedObject.Location = new System.Drawing.Point(312, 200); + this.labelModifiedObject.Location = new System.Drawing.Point(390, 250); + this.labelModifiedObject.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelModifiedObject.Name = "labelModifiedObject"; - this.labelModifiedObject.Size = new System.Drawing.Size(115, 45); + this.labelModifiedObject.Size = new System.Drawing.Size(143, 56); this.labelModifiedObject.TabIndex = 8; - this.labelModifiedObject.Text = "Modified"; + 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(179, 200); + this.labelSimpleObject.Location = new System.Drawing.Point(224, 250); + this.labelSimpleObject.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelSimpleObject.Name = "labelSimpleObject"; - this.labelSimpleObject.Size = new System.Drawing.Size(115, 45); + this.labelSimpleObject.Size = new System.Drawing.Size(143, 56); this.labelSimpleObject.TabIndex = 7; - this.labelSimpleObject.Text = "Simple"; + this.labelSimpleObject.Text = "Простой"; this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown); // @@ -110,102 +111,123 @@ 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.Location = new System.Drawing.Point(224, 32); + this.groupBoxColors.Margin = new System.Windows.Forms.Padding(4); this.groupBoxColors.Name = "groupBoxColors"; - this.groupBoxColors.Size = new System.Drawing.Size(248, 156); + this.groupBoxColors.Padding = new System.Windows.Forms.Padding(4); + this.groupBoxColors.Size = new System.Drawing.Size(310, 195); this.groupBoxColors.TabIndex = 6; this.groupBoxColors.TabStop = false; - this.groupBoxColors.Text = "Colors"; + this.groupBoxColors.Text = "Цвета"; // // panelPurple // this.panelPurple.BackColor = System.Drawing.Color.Fuchsia; - this.panelPurple.Location = new System.Drawing.Point(193, 102); + this.panelPurple.Location = new System.Drawing.Point(241, 128); + this.panelPurple.Margin = new System.Windows.Forms.Padding(4); this.panelPurple.Name = "panelPurple"; - this.panelPurple.Size = new System.Drawing.Size(43, 40); + this.panelPurple.Size = new System.Drawing.Size(54, 50); this.panelPurple.TabIndex = 3; + this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelBlack // this.panelBlack.BackColor = System.Drawing.Color.Black; - this.panelBlack.Location = new System.Drawing.Point(132, 102); + this.panelBlack.Location = new System.Drawing.Point(165, 128); + this.panelBlack.Margin = new System.Windows.Forms.Padding(4); this.panelBlack.Name = "panelBlack"; - this.panelBlack.Size = new System.Drawing.Size(43, 40); + this.panelBlack.Size = new System.Drawing.Size(54, 50); this.panelBlack.TabIndex = 2; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelGray // this.panelGray.BackColor = System.Drawing.Color.Gray; - this.panelGray.Location = new System.Drawing.Point(72, 102); + this.panelGray.Location = new System.Drawing.Point(90, 128); + this.panelGray.Margin = new System.Windows.Forms.Padding(4); this.panelGray.Name = "panelGray"; - this.panelGray.Size = new System.Drawing.Size(43, 40); + this.panelGray.Size = new System.Drawing.Size(54, 50); this.panelGray.TabIndex = 3; + this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelWhite // this.panelWhite.BackColor = System.Drawing.Color.White; - this.panelWhite.Location = new System.Drawing.Point(11, 102); + this.panelWhite.Location = new System.Drawing.Point(14, 128); + this.panelWhite.Margin = new System.Windows.Forms.Padding(4); this.panelWhite.Name = "panelWhite"; - this.panelWhite.Size = new System.Drawing.Size(43, 40); + this.panelWhite.Size = new System.Drawing.Size(54, 50); this.panelWhite.TabIndex = 2; + this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelYellow // this.panelYellow.BackColor = System.Drawing.Color.Yellow; - this.panelYellow.Location = new System.Drawing.Point(193, 31); + this.panelYellow.Location = new System.Drawing.Point(241, 39); + this.panelYellow.Margin = new System.Windows.Forms.Padding(4); this.panelYellow.Name = "panelYellow"; - this.panelYellow.Size = new System.Drawing.Size(43, 40); + this.panelYellow.Size = new System.Drawing.Size(54, 50); this.panelYellow.TabIndex = 1; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // 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.Location = new System.Drawing.Point(90, 39); + this.panelGreen.Margin = new System.Windows.Forms.Padding(4); this.panelGreen.Name = "panelGreen"; - this.panelGreen.Size = new System.Drawing.Size(43, 40); + this.panelGreen.Size = new System.Drawing.Size(54, 50); this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelBlue // this.panelBlue.BackColor = System.Drawing.Color.Blue; - this.panelBlue.Location = new System.Drawing.Point(133, 31); + this.panelBlue.Location = new System.Drawing.Point(166, 39); + this.panelBlue.Margin = new System.Windows.Forms.Padding(4); this.panelBlue.Name = "panelBlue"; - this.panelBlue.Size = new System.Drawing.Size(43, 40); + this.panelBlue.Size = new System.Drawing.Size(54, 50); this.panelBlue.TabIndex = 1; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // panelRed // this.panelRed.BackColor = System.Drawing.Color.Red; - this.panelRed.Location = new System.Drawing.Point(11, 31); + this.panelRed.Location = new System.Drawing.Point(14, 39); + this.panelRed.Margin = new System.Windows.Forms.Padding(4); this.panelRed.Name = "panelRed"; - this.panelRed.Size = new System.Drawing.Size(43, 40); + this.panelRed.Size = new System.Drawing.Size(54, 50); this.panelRed.TabIndex = 0; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); // // checkBoxFuelStorage // this.checkBoxFuelStorage.AutoSize = true; - this.checkBoxFuelStorage.Location = new System.Drawing.Point(7, 158); + this.checkBoxFuelStorage.Location = new System.Drawing.Point(9, 198); + this.checkBoxFuelStorage.Margin = new System.Windows.Forms.Padding(4); this.checkBoxFuelStorage.Name = "checkBoxFuelStorage"; - this.checkBoxFuelStorage.Size = new System.Drawing.Size(146, 24); + this.checkBoxFuelStorage.Size = new System.Drawing.Size(207, 29); this.checkBoxFuelStorage.TabIndex = 5; - this.checkBoxFuelStorage.Text = "Add Fuel Storage"; + this.checkBoxFuelStorage.Text = "Добавление батарей"; this.checkBoxFuelStorage.UseVisualStyleBackColor = true; // // checkBoxPipe // this.checkBoxPipe.AutoSize = true; - this.checkBoxPipe.Location = new System.Drawing.Point(7, 128); + this.checkBoxPipe.Location = new System.Drawing.Point(9, 160); + this.checkBoxPipe.Margin = new System.Windows.Forms.Padding(4); this.checkBoxPipe.Name = "checkBoxPipe"; - this.checkBoxPipe.Size = new System.Drawing.Size(92, 24); + this.checkBoxPipe.Size = new System.Drawing.Size(192, 29); this.checkBoxPipe.TabIndex = 4; - this.checkBoxPipe.Text = "Add Pipe"; + this.checkBoxPipe.Text = "Добавление рогов"; this.checkBoxPipe.UseVisualStyleBackColor = true; // // numericUpDownWeight // - this.numericUpDownWeight.Location = new System.Drawing.Point(75, 75); + this.numericUpDownWeight.Location = new System.Drawing.Point(94, 94); + this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(4); this.numericUpDownWeight.Name = "numericUpDownWeight"; - this.numericUpDownWeight.Size = new System.Drawing.Size(68, 27); + this.numericUpDownWeight.Size = new System.Drawing.Size(85, 31); this.numericUpDownWeight.TabIndex = 3; this.numericUpDownWeight.Value = new decimal(new int[] { 100, @@ -216,17 +238,19 @@ // labelWeight // this.labelWeight.AutoSize = true; - this.labelWeight.Location = new System.Drawing.Point(7, 77); + this.labelWeight.Location = new System.Drawing.Point(9, 96); + this.labelWeight.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelWeight.Name = "labelWeight"; - this.labelWeight.Size = new System.Drawing.Size(63, 20); + this.labelWeight.Size = new System.Drawing.Size(48, 25); this.labelWeight.TabIndex = 2; - this.labelWeight.Text = "Weight: "; + this.labelWeight.Text = "Вес: "; // // numericUpDownSpeed // - this.numericUpDownSpeed.Location = new System.Drawing.Point(74, 31); + this.numericUpDownSpeed.Location = new System.Drawing.Point(92, 39); + this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(4); this.numericUpDownSpeed.Name = "numericUpDownSpeed"; - this.numericUpDownSpeed.Size = new System.Drawing.Size(69, 27); + this.numericUpDownSpeed.Size = new System.Drawing.Size(86, 31); this.numericUpDownSpeed.TabIndex = 1; this.numericUpDownSpeed.Value = new decimal(new int[] { 100, @@ -237,11 +261,12 @@ // labelSpeed // this.labelSpeed.AutoSize = true; - this.labelSpeed.Location = new System.Drawing.Point(6, 33); + this.labelSpeed.Location = new System.Drawing.Point(8, 41); + this.labelSpeed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelSpeed.Name = "labelSpeed"; - this.labelSpeed.Size = new System.Drawing.Size(62, 20); + this.labelSpeed.Size = new System.Drawing.Size(98, 25); this.labelSpeed.TabIndex = 0; - this.labelSpeed.Text = " Speed: "; + this.labelSpeed.Text = "Скорость: "; // // panelObject // @@ -249,9 +274,10 @@ 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.Location = new System.Drawing.Point(589, 28); + this.panelObject.Margin = new System.Windows.Forms.Padding(4); this.panelObject.Name = "panelObject"; - this.panelObject.Size = new System.Drawing.Size(419, 250); + this.panelObject.Size = new System.Drawing.Size(524, 312); 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); @@ -260,62 +286,70 @@ // this.labelDopColor.AllowDrop = true; this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelDopColor.Location = new System.Drawing.Point(232, 16); + this.labelDopColor.Location = new System.Drawing.Point(290, 20); + this.labelDopColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelDopColor.Name = "labelDopColor"; - this.labelDopColor.Size = new System.Drawing.Size(115, 45); + this.labelDopColor.Size = new System.Drawing.Size(143, 56); this.labelDopColor.TabIndex = 9; - this.labelDopColor.Text = "Extra Color"; + 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.LabelColor_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.Location = new System.Drawing.Point(86, 20); + this.labelBaseColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelBaseColor.Name = "labelBaseColor"; - this.labelBaseColor.Size = new System.Drawing.Size(115, 45); + this.labelBaseColor.Size = new System.Drawing.Size(143, 56); this.labelBaseColor.TabIndex = 8; - this.labelBaseColor.Text = "Base Color"; + this.labelBaseColor.Text = "Базовый цвет"; 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); + this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop); + this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); // // pictureBoxObject // - this.pictureBoxObject.Location = new System.Drawing.Point(16, 67); + this.pictureBoxObject.Location = new System.Drawing.Point(20, 84); + this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(4); this.pictureBoxObject.Name = "pictureBoxObject"; - this.pictureBoxObject.Size = new System.Drawing.Size(386, 168); + this.pictureBoxObject.Size = new System.Drawing.Size(482, 210); this.pictureBoxObject.TabIndex = 0; this.pictureBoxObject.TabStop = false; // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(487, 278); + this.buttonAdd.Location = new System.Drawing.Point(609, 348); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(4); this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(168, 29); + this.buttonAdd.Size = new System.Drawing.Size(210, 36); this.buttonAdd.TabIndex = 2; - this.buttonAdd.Text = "Add"; + this.buttonAdd.Text = "Добавить"; 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.Location = new System.Drawing.Point(879, 348); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(4); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(170, 29); + this.buttonCancel.Size = new System.Drawing.Size(212, 36); this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; + this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; // // FormLocomotiveConfig // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(902, 315); + this.ClientSize = new System.Drawing.Size(1128, 394); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonAdd); this.Controls.Add(this.panelObject); this.Controls.Add(this.groupBoxConfig); + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "FormLocomotiveConfig"; this.Text = "Object Creation"; this.groupBoxConfig.ResumeLayout(false); @@ -328,9 +362,7 @@ this.ResumeLayout(false); } - #endregion - private GroupBox groupBoxConfig; private NumericUpDown numericUpDownSpeed; private Label labelSpeed; diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.cs index 7010123..b53d43c 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotiveConfig.cs @@ -13,7 +13,23 @@ namespace ProjectLocomotive 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(); @@ -25,13 +41,12 @@ namespace ProjectLocomotive 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)) @@ -43,7 +58,6 @@ namespace ProjectLocomotive e.Effect = DragDropEffects.None; } } - private void panelObject_DragDrop(object sender, DragEventArgs e) { switch (e.Data.GetData(DataFormats.Text).ToString()) @@ -59,12 +73,10 @@ namespace ProjectLocomotive } 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); @@ -73,8 +85,17 @@ namespace ProjectLocomotive _locomotive?.DrawTransport(gr); pictureBoxObject.Image = bmp; } - - private void labelBaseColor_DragEnter(object sender, DragEventArgs e) + private void labelDopColor_DragDrop(object sender, DragEventArgs e) + { + // ! - TODO + if (_locomotive is DrawningElectroLocomotive) + { + var locomotive = _locomotive as DrawningElectroLocomotive; + locomotive.SetExtraColor((Color)e.Data.GetData(typeof(Color))); + } + DrawLocomotive(); + } + private void LabelColor_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Color))) { @@ -85,15 +106,19 @@ namespace ProjectLocomotive e.Effect = DragDropEffects.None; } } - - private void labelBaseColor_DragDrop(object sender, DragEventArgs e) + private void LabelColor_DragDrop(object sender, DragEventArgs e) { - // ! - TODO - } - - private void labelDopColor_DragDrop(object sender, DragEventArgs e) - { - // ! - TODO + var color = e.Data.GetData(typeof(Color)); + if (color != null) + { + (sender as Label).BackColor = (Color)color; + } + DrawLocomotive(); + if (_locomotive != null) + { + _locomotive.Locomotivе.BodyColor = (Color)color; + DrawLocomotive(); + } } } } diff --git a/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.Designer.cs b/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.Designer.cs index b0207a1..bb232b1 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.Designer.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.Designer.cs @@ -262,9 +262,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); } - #endregion - private GroupBox groupBoxTools; private PictureBox pictureBox; private ComboBox comboBoxSelectorMap; diff --git a/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.cs b/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.cs index 2a9b9cd..5385cb3 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormMapWithSetLocomotives.cs @@ -54,25 +54,28 @@ namespace ProjectLocomotive } /// Добавление объекта 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 DrawningObject(locomotive) != -1) { - DrawningObject locomotive = new(form.SelectedLocomotive); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + locomotive != -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 buttonRemoveLocomotive_Click(object sender, EventArgs e)