diff --git a/HoistingCrane/HoistingCrane/CarDelegate.cs b/HoistingCrane/HoistingCrane/CarDelegate.cs
deleted file mode 100644
index 7383591..0000000
--- a/HoistingCrane/HoistingCrane/CarDelegate.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using HoistingCrane.Drawning;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HoistingCrane
-{
- public delegate void CarDelegate(DrawningTrackedVehicle car);
-
-}
diff --git a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs
index 674c373..3c6c8f9 100644
--- a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs
+++ b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs
@@ -10,16 +10,16 @@ public class EntityHoistingCrane : EntityTrackedVehicle
///
///
///
- public Color AdditionalColor { get; protected set; }
+ public Color AdditionalColor { get; private set; }
///
///
///
- public bool Counterweight { get; protected set; }
+ public bool Counterweight { get; private set; }
///
///
///
- public bool Platform { get; protected set; }
+ public bool Platform { get; private set; }
///
///
diff --git a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs
index 0a479d7..caef6bc 100644
--- a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs
+++ b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs
@@ -9,19 +9,19 @@
///
/// Скорость, которой обладает объект
///
- public int Speed { get; protected set; }
+ public int Speed { get; private set; }
///
/// Вес, которым обладает объект
///
- public double Weight { get; protected set; }
+ public double Weight { get; private set; }
///
/// Основной цвет объекта
///
- public Color BodyColor { get; protected set; }
+ public Color BodyColor { get; private set; }
///
diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs
index 9105a92..1908fc4 100644
--- a/HoistingCrane/HoistingCrane/FormCarConfig.cs
+++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs
@@ -16,8 +16,8 @@ namespace HoistingCrane
{
public partial class FormCarConfig : Form
{
- private DrawningTrackedVehicle? car = null;
- private event CarDelegate? _carDelegate;
+ private DrawningTrackedVehicle? drawningTrackedVehicle;
+ private event Action? _carDelegate;
public FormCarConfig()
{
InitializeComponent();
@@ -35,9 +35,17 @@ namespace HoistingCrane
/// Привязка метода к событию
///
///
- public void AddEvent(CarDelegate carDelegate)
+ public void AddEvent(Action carDelegate)
{
- _carDelegate += carDelegate;
+ if (carDelegate == null)
+ {
+ _carDelegate = carDelegate;
+ }
+ else
+ {
+ _carDelegate += carDelegate;
+ }
+
}
///
/// Отрисовка объекта
@@ -46,9 +54,9 @@ namespace HoistingCrane
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
- car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
- car?.SetPosition(25, 25);
- car?.DrawTransport(gr);
+ drawningTrackedVehicle?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ drawningTrackedVehicle?.SetPosition(25, 25);
+ drawningTrackedVehicle?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
///
@@ -79,10 +87,10 @@ namespace HoistingCrane
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
- car = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ drawningTrackedVehicle = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
- car = new DrawningHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCounterweight.Checked,
+ drawningTrackedVehicle = new DrawningHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCounterweight.Checked,
checkBoxPlatform.Checked);
break;
}
@@ -104,9 +112,9 @@ namespace HoistingCrane
///
private void buttonAdd_Click(object sender, EventArgs e)
{
- if (car != null)
+ if (drawningTrackedVehicle != null)
{
- _carDelegate?.Invoke(car);
+ _carDelegate?.Invoke(drawningTrackedVehicle);
Close();
}
}
@@ -117,9 +125,9 @@ namespace HoistingCrane
///
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
- if (car == null)
+ if (drawningTrackedVehicle == null)
return;
- car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ drawningTrackedVehicle.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
///
@@ -145,7 +153,7 @@ namespace HoistingCrane
///
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
- if (car?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane)
+ if (drawningTrackedVehicle?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane)
{
entityHoistingCrane.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
@@ -158,7 +166,7 @@ namespace HoistingCrane
///
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
- if (car is DrawningHoistingCrane)
+ if (drawningTrackedVehicle is DrawningHoistingCrane)
{
if (e.Data.GetDataPresent(typeof(Color)))
{