Готовая лабораторная работа 5
This commit is contained in:
parent
68f321a652
commit
242fad7ac8
@ -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);
|
|
||||||
|
|
||||||
}
|
|
@ -10,16 +10,16 @@ public class EntityHoistingCrane : EntityTrackedVehicle
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дополнительный цвет объекта
|
/// Дополнительный цвет объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color AdditionalColor { get; protected set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наличие противовеса
|
/// Наличие противовеса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Counterweight { get; protected set; }
|
public bool Counterweight { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наличие платформы
|
/// Наличие платформы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Platform { get; protected set; }
|
public bool Platform { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Метод задачи параметров
|
/// Метод задачи параметров
|
||||||
|
@ -9,19 +9,19 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость, которой обладает объект
|
/// Скорость, которой обладает объект
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Speed { get; protected set; }
|
public int Speed { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вес, которым обладает объект
|
/// Вес, которым обладает объект
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Weight { get; protected set; }
|
public double Weight { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Основной цвет объекта
|
/// Основной цвет объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color BodyColor { get; protected set; }
|
public Color BodyColor { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,8 +16,8 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
public partial class FormCarConfig : Form
|
public partial class FormCarConfig : Form
|
||||||
{
|
{
|
||||||
private DrawningTrackedVehicle? car = null;
|
private DrawningTrackedVehicle? drawningTrackedVehicle;
|
||||||
private event CarDelegate? _carDelegate;
|
private event Action<DrawningTrackedVehicle>? _carDelegate;
|
||||||
public FormCarConfig()
|
public FormCarConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -35,9 +35,17 @@ namespace HoistingCrane
|
|||||||
/// Привязка метода к событию
|
/// Привязка метода к событию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="carDelegate"></param>
|
/// <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>
|
/// <summary>
|
||||||
/// Отрисовка объекта
|
/// Отрисовка объекта
|
||||||
@ -46,9 +54,9 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
drawningTrackedVehicle?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
car?.SetPosition(25, 25);
|
drawningTrackedVehicle?.SetPosition(25, 25);
|
||||||
car?.DrawTransport(gr);
|
drawningTrackedVehicle?.DrawTransport(gr);
|
||||||
pictureBoxObject.Image = bmp;
|
pictureBoxObject.Image = bmp;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -79,10 +87,10 @@ namespace HoistingCrane
|
|||||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
{
|
{
|
||||||
case "labelSimpleObject":
|
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;
|
break;
|
||||||
case "labelModifiedObject":
|
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);
|
checkBoxPlatform.Checked);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -104,9 +112,9 @@ namespace HoistingCrane
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (car != null)
|
if (drawningTrackedVehicle != null)
|
||||||
{
|
{
|
||||||
_carDelegate?.Invoke(car);
|
_carDelegate?.Invoke(drawningTrackedVehicle);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,9 +125,9 @@ namespace HoistingCrane
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (car == null)
|
if (drawningTrackedVehicle == null)
|
||||||
return;
|
return;
|
||||||
car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
drawningTrackedVehicle.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
DrawObject();
|
DrawObject();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -145,7 +153,7 @@ namespace HoistingCrane
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
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)));
|
entityHoistingCrane.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
}
|
}
|
||||||
@ -158,7 +166,7 @@ namespace HoistingCrane
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (car is DrawningHoistingCrane)
|
if (drawningTrackedVehicle is DrawningHoistingCrane)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user