Laba5 PIbd-22 Kalyshev Y V #8
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-автомобиля
|
||||
/// </summary>
|
||||
/// <param name="car"></param>
|
||||
public delegate void BoatDelegate(DrawningBoat boat);
|
||||
}
|
@ -22,7 +22,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event BoatDelegate EventAddBoat;
|
||||
private event Action<DrawningBoat> EventAddBoat;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -38,7 +38,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
// TODO buttonCancel.Click with lambda
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать машину
|
||||
@ -55,11 +55,11 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev"></param>
|
||||
public void AddEvent(BoatDelegate ev)
|
||||
public void AddEvent(Action<DrawningBoat> ev)
|
||||
{
|
||||
if (EventAddBoat == null)
|
||||
{
|
||||
EventAddBoat = new BoatDelegate(ev);
|
||||
EventAddBoat = new Action<DrawningBoat>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -142,7 +142,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_boat == null)
|
||||
if (_boat == null || !e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -156,11 +156,14 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_boat == null || _boat.GetType() != typeof(DrawningSpeedboat))
|
||||
if (_boat == null || _boat.GetType() != typeof(DrawningSpeedboat) || !e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//TODO
|
||||
if (_boat.Boat is EntitySpeedboat advboat)
|
||||
{
|
||||
advboat.DopColor = (Color)e.Data.GetData(typeof(Color));
|
||||
}
|
||||
DrawBoat();
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -103,9 +103,26 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
private void ButtonAddBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formBoatConfig = new FormBoatConfig();
|
||||
//TODO Call method AddEvent from formBoatConfig
|
||||
formBoatConfig.AddEvent(AddBoat);
|
||||
formBoatConfig.Show();
|
||||
}
|
||||
private void AddBoat(DrawningBoat drawingBoats)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawningObjectBoat boat = new DrawningObjectBoat(drawingBoats);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat != -1)
|
||||
{
|
||||
MessageBox.Show("Object added");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Cant add object");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user