Правки. Сданная Лабораторная №5

This commit is contained in:
Данила Мочалов 2022-10-25 15:44:49 +04:00
parent 6b7a6625db
commit 75190e8594
6 changed files with 19 additions and 46 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -14,13 +14,13 @@ namespace Locomotive
{
DrawningLocomotive _locomotive = null;
private event LocomotiveDelegate eventAddLocomotive;
private event Action<DrawningLocomotive> eventAddLocomotive;
public void AddEvent(LocomotiveDelegate ev)
public void AddEvent(Action<DrawningLocomotive> ev)
{
if (eventAddLocomotive == null)
{
eventAddLocomotive = new LocomotiveDelegate(ev);
eventAddLocomotive = new Action<DrawningLocomotive>(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;

View File

@ -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();
}

View File

@ -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);
}