diff --git a/Locomotive/Locomotive/DrawningLocomotive.cs b/Locomotive/Locomotive/DrawningLocomotive.cs index 9df50a5..9615e6e 100644 --- a/Locomotive/Locomotive/DrawningLocomotive.cs +++ b/Locomotive/Locomotive/DrawningLocomotive.cs @@ -42,11 +42,10 @@ namespace Locomotive { if (Locomotive is EntityWarmlyLocomotive) { - var locomotive = Locomotive as EntityWarmlyLocomotive; - if (locomotive is not null) + Locomotive = (EntityWarmlyLocomotive)Locomotive; + if (Locomotive is not null) { - locomotive = new EntityWarmlyLocomotive(locomotive.Speed, locomotive.Weight, color, locomotive.ExtraColor, locomotive.Pipe, locomotive.FuelStorage); - Locomotive = locomotive; + Locomotive = new EntityWarmlyLocomotive(Locomotive.Speed, Locomotive.Weight, color, (Locomotive as EntityWarmlyLocomotive).ExtraColor, (Locomotive as EntityWarmlyLocomotive).Pipe, (Locomotive as EntityWarmlyLocomotive).FuelStorage); return; } } diff --git a/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs b/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs index ca5c0d5..0f3af01 100644 --- a/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs +++ b/Locomotive/Locomotive/DrawningWarmlyLocomotive.cs @@ -16,11 +16,10 @@ namespace Locomotive public void SetExtraColor(Color color) { - var LocomotiveWarmly = Locomotive as EntityWarmlyLocomotive; - if (LocomotiveWarmly is not null) + Locomotive = Locomotive as EntityWarmlyLocomotive; + if (Locomotive is not null) { - LocomotiveWarmly = new EntityWarmlyLocomotive(LocomotiveWarmly.Speed, LocomotiveWarmly.Weight, LocomotiveWarmly.BodyColor, color, LocomotiveWarmly.Pipe, LocomotiveWarmly.FuelStorage); - Locomotive = LocomotiveWarmly; + Locomotive = new EntityWarmlyLocomotive(Locomotive.Speed, Locomotive.Weight, Locomotive.BodyColor, color, (Locomotive as EntityWarmlyLocomotive).Pipe, (Locomotive as EntityWarmlyLocomotive).FuelStorage); } } diff --git a/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs b/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs index b17967a..77cf4bf 100644 --- a/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs +++ b/Locomotive/Locomotive/FormLocomotiveConfig.Designer.cs @@ -204,6 +204,11 @@ // 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; @@ -225,6 +230,11 @@ // 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; diff --git a/Locomotive/Locomotive/FormLocomotiveConfig.cs b/Locomotive/Locomotive/FormLocomotiveConfig.cs index 98cebd5..f016a97 100644 --- a/Locomotive/Locomotive/FormLocomotiveConfig.cs +++ b/Locomotive/Locomotive/FormLocomotiveConfig.cs @@ -14,13 +14,13 @@ namespace Locomotive { DrawningLocomotive _locomotive = null; - private event LocomotiveDelegate eventAddLocomotive; + private event Action eventAddLocomotive; - public void AddEvent(LocomotiveDelegate ev) + public void AddEvent(Action ev) { if (eventAddLocomotive == null) { - eventAddLocomotive = new LocomotiveDelegate(ev); + eventAddLocomotive = new Action(ev); } else { @@ -45,7 +45,6 @@ namespace Locomotive panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; - // ! - TODO buttonCancel.Click with lambda buttonCancel.Click += (object sender, EventArgs e) => Close(); } @@ -110,15 +109,12 @@ namespace Locomotive private void labelBaseColor_DragDrop(object sender, DragEventArgs e) { - // ! - TODO Call method from object _car and set color - _locomotive.SetBaseColor((Color)e.Data.GetData(typeof(Color))); DrawLocomotive(); } private void labelDopColor_DragEnter(object sender, DragEventArgs e) { - // ! - TODO if (e.Data.GetDataPresent(typeof(Color))) { @@ -132,7 +128,6 @@ namespace Locomotive private void labelDopColor_DragDrop(object sender, DragEventArgs e) { - // ! - TODO if (_locomotive is DrawningWarmlyLocomotive) { var locomotive = _locomotive as DrawningWarmlyLocomotive; diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs index b8b342b..4c9a0ad 100644 --- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs +++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs @@ -87,27 +87,7 @@ namespace Locomotive /// Добавление объекта private void buttonAddLocomotive_Click(object sender, EventArgs e) { - /*if (listBoxMaps.SelectedIndex == -1) - { - return; - } - FormLocomotive form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - 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"); - } - }*/ - var formCarConfig = new FormLocomotiveConfig(); - // TODO Call method AddEvent from formCarConfig formCarConfig.AddEvent(new (AddLocomotive)); formCarConfig.Show(); } diff --git a/Locomotive/Locomotive/LocomotiveDelegate.cs b/Locomotive/Locomotive/LocomotiveDelegate.cs deleted file mode 100644 index 813f2bc..0000000 --- a/Locomotive/Locomotive/LocomotiveDelegate.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Locomotive -{ - public delegate void LocomotiveDelegate(DrawningLocomotive locomotive); -}