From 559876c90b7393f77a97ee7e74b2bb5e22aadc61 Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 12 Nov 2023 23:04:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingElectricLocomotive.cs | 2 +- .../ElectricLocomotive/DrawingLocomotive.cs | 6 +++--- .../EntityElectricLocomotive.cs | 4 ++-- .../ElectricLocomotive/EntityLocomotive.cs | 4 ++-- .../FormLocomotiveConfig.cs | 20 +++++++++---------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs index f7e8831..0617c6e 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs @@ -46,7 +46,7 @@ namespace ProjectElectricLocomotive.DrawingObjects g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 60, _startPosY + 2); base.DrawTransport(g); } - public void SetAddColor(Color color) + public void SetAdditionalColor(Color color) { (EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color); } diff --git a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs index c16041b..e22cc39 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs @@ -13,7 +13,7 @@ namespace ProjectElectricLocomotive.DrawingObjects { public class DrawingLocomotive { - public EntityLocomotive? EntityLocomotive { get; protected set; } + public EntityLocomotive? EntityLocomotive { get; protected set;} public int _pictureWidth; public int _pictureHeight; @@ -166,9 +166,9 @@ namespace ProjectElectricLocomotive.DrawingObjects } public IMoveableObject GetMoveableObject => new DrawingObjectLocomotive(this); - public void SetColor(Color color) + public void SetBodyColor(Color color) { - (EntityLocomotive as EntityLocomotive).SetColor(color); + EntityLocomotive.SetBodyColor(color); } } } diff --git a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs index 0f7f96d..dbb6eaa 100644 --- a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs @@ -10,8 +10,8 @@ namespace ProjectElectricLocomotive.Entities public class EntityElectricLocomotive : EntityLocomotive { public Color AdditionalColor { get; private set; } - public bool Pantograph { get; private set; } - public bool Compartment { get; private set; } + public bool Pantograph { get; set; } + public bool Compartment { get; set; } /// Дополнительный цвет /// Признак наличия токоприемника diff --git a/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs index f469e77..aacfbfe 100644 --- a/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs @@ -10,7 +10,7 @@ namespace ProjectElectricLocomotive.Entities { public int Speed { get; private set; } public double Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; protected set; } public double Step => (double)Speed * 100 / Weight; /// Скорость @@ -22,7 +22,7 @@ namespace ProjectElectricLocomotive.Entities Weight = weight; BodyColor = bodyColor; } - public void SetColor(Color color) + public void SetBodyColor(Color color) { BodyColor = color; } diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs index cc162f7..162119a 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ProjectElectricLocomotive.Entities; namespace ProjectElectricLocomotive { @@ -28,8 +29,6 @@ namespace ProjectElectricLocomotive panelColorWhite.MouseDown += PanelColor_MouseDown; panelColorYellow.MouseDown += PanelColor_MouseDown; panelColorBlue.MouseDown += PanelColor_MouseDown; - labelSimpleObject.MouseDown += LabelObject_MouseDown; - labelAdvancedObject.MouseDown += LabelObject_MouseDown; buttonCancelObject.Click += (s, e) => Close(); @@ -81,8 +80,7 @@ namespace ProjectElectricLocomotive case "labelAdvancedObject": _locomotive = new DrawingElectricLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPantograph.Checked, - checkBoxCompartment.Checked, pictureBoxLoco.Width, - pictureBoxLoco.Height); + checkBoxCompartment.Checked, pictureBoxLoco.Width, pictureBoxLoco.Height); break; } DrawLocomotive(); @@ -102,18 +100,20 @@ namespace ProjectElectricLocomotive private void LabelColor_DragDrop(object sender, DragEventArgs e) { + if (_locomotive == null) + return; ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color)); switch (((Label)sender).Name) { - case "labelSimpleObject": - _locomotive.SetColor((Color)e.Data.GetData(typeof(Color))); + case "labelSimpleColor": + _locomotive.SetBodyColor((Color)e.Data.GetData(typeof(Color))); break; - case "labelAdvancedObject": - if (_locomotive is not DrawingLocomotive) return; - else + case "labelAdvancedColor": + if (!(_locomotive is DrawingElectricLocomotive)) { - (_locomotive as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color))); + return; } + (_locomotive as DrawingElectricLocomotive).SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); break; } DrawLocomotive();