pibd-12 Tangatarov.I.A. LabWork05 Base #19

Closed
sqdselo wants to merge 11 commits from LabWork05 into LabWork04
4 changed files with 29 additions and 33 deletions
Showing only changes of commit 242fad7ac8 - Show all commits

View File

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

View File

@ -10,16 +10,16 @@ public class EntityHoistingCrane : EntityTrackedVehicle
/// <summary>
/// Дополнительный цвет объекта
/// </summary>
public Color AdditionalColor { get; protected set; }
public Color AdditionalColor { get; private set; }
/// <summary>
/// Наличие противовеса
/// </summary>
public bool Counterweight { get; protected set; }
public bool Counterweight { get; private set; }
/// <summary>
/// Наличие платформы
/// </summary>
public bool Platform { get; protected set; }
public bool Platform { get; private set; }
/// <summary>
/// Метод задачи параметров

View File

@ -9,19 +9,19 @@
/// <summary>
/// Скорость, которой обладает объект
/// </summary>
public int Speed { get; protected set; }
public int Speed { get; private set; }
/// <summary>
/// Вес, которым обладает объект
/// </summary>
public double Weight { get; protected set; }
public double Weight { get; private set; }
/// <summary>
/// Основной цвет объекта
/// </summary>
public Color BodyColor { get; protected set; }
public Color BodyColor { get; private set; }
/// <summary>

View File

@ -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<DrawningTrackedVehicle>? _carDelegate;
public FormCarConfig()
{
InitializeComponent();
@ -35,9 +35,17 @@ namespace HoistingCrane
/// Привязка метода к событию
/// </summary>
/// <param name="carDelegate"></param>
public void AddEvent(CarDelegate carDelegate)
public void AddEvent(Action<DrawningTrackedVehicle> carDelegate)
{
_carDelegate += carDelegate;
if (carDelegate == null)
{
_carDelegate = carDelegate;
}
else
{
_carDelegate += carDelegate;
}
}
/// <summary>
/// Отрисовка объекта
@ -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;
}
/// <summary>
@ -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
/// <param name="e"></param>
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
/// <param name="e"></param>
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();
}
/// <summary>
@ -145,7 +153,7 @@ namespace HoistingCrane
/// <param name="e"></param>
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
/// <param name="e"></param>
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (car is DrawningHoistingCrane)
if (drawningTrackedVehicle is DrawningHoistingCrane)
{
if (e.Data.GetDataPresent(typeof(Color)))
{