Сделанная 5 лаба (не проверена)
This commit is contained in:
parent
38ae601acc
commit
498ce0d89b
@ -19,7 +19,7 @@ namespace WarmlyLocomotive
|
||||
/// <summary>
|
||||
/// Цвет кузова
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения локомотива
|
||||
/// </summary>
|
||||
|
@ -12,7 +12,7 @@ namespace WarmlyLocomotive
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
public Color DopColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак наличия трубы
|
||||
/// </summary>
|
||||
|
@ -121,6 +121,7 @@
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.AllowDrop = true;
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
this.panelPurple.Location = new System.Drawing.Point(157, 68);
|
||||
this.panelPurple.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -130,6 +131,7 @@
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.AllowDrop = true;
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(111, 68);
|
||||
this.panelBlack.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -139,6 +141,7 @@
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.AllowDrop = true;
|
||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
this.panelGray.Location = new System.Drawing.Point(65, 68);
|
||||
this.panelGray.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -148,6 +151,7 @@
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.AllowDrop = true;
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(19, 68);
|
||||
this.panelWhite.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -157,6 +161,7 @@
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.AllowDrop = true;
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(157, 22);
|
||||
this.panelYellow.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -166,6 +171,7 @@
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.AllowDrop = true;
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(111, 22);
|
||||
this.panelBlue.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -175,6 +181,7 @@
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.AllowDrop = true;
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(65, 22);
|
||||
this.panelGreen.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -184,6 +191,7 @@
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.AllowDrop = true;
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(19, 22);
|
||||
this.panelRed.MaximumSize = new System.Drawing.Size(30, 30);
|
||||
@ -295,6 +303,7 @@
|
||||
this.labelDopColor.Text = "Доп. цвет";
|
||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter);
|
||||
//
|
||||
// labelBaseColor
|
||||
//
|
||||
|
@ -16,7 +16,7 @@ namespace WarmlyLocomotive
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event LocomotiveDelegate EventAddLocomotive;
|
||||
private event Action<DrawningLocomotive> EventAddLocomotive;
|
||||
public FormLocomotiveConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -28,7 +28,7 @@ namespace WarmlyLocomotive
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||
// TODO buttonCancel.Click with lambda
|
||||
}
|
||||
/// <summary>
|
||||
@ -46,11 +46,11 @@ namespace WarmlyLocomotive
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev"></param>
|
||||
public void AddEvent(LocomotiveDelegate ev)
|
||||
public void AddEvent(Action<DrawningLocomotive> ev)
|
||||
{
|
||||
if (EventAddLocomotive == null)
|
||||
{
|
||||
EventAddLocomotive = new LocomotiveDelegate(ev);
|
||||
EventAddLocomotive = new Action<DrawningLocomotive>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -134,6 +134,29 @@ namespace WarmlyLocomotive
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car and set color
|
||||
if(_locomotive != null)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color))) {
|
||||
_locomotive.Locomotive.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
@ -143,6 +166,17 @@ namespace WarmlyLocomotive
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
|
||||
if (_locomotive != null && _locomotive is DrawningWarmlyLocomotive warmlyLocomotive)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
if(warmlyLocomotive.Locomotive is EntityWarmlyLocomotive entityWarmlyLocomotive)
|
||||
{
|
||||
entityWarmlyLocomotive.DopColor = (Color)e.Data.GetData(typeof(Color));
|
||||
}
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление локомотива
|
||||
|
@ -68,8 +68,26 @@ namespace WarmlyLocomotive
|
||||
{
|
||||
var formLocomotiveConfig = new FormLocomotiveConfig();
|
||||
// TODO Call method AddEvent from formCarConfig
|
||||
formLocomotiveConfig.AddEvent(AddLocomotive);
|
||||
formLocomotiveConfig.Show();
|
||||
}
|
||||
private void AddLocomotive(DrawningLocomotive drawningLocomotive)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawningObjectLocomotive locomotive = new DrawningObjectLocomotive(drawningLocomotive);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + locomotive != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-локомотива
|
||||
/// </summary>
|
||||
/// <param name="locomotive"></param>
|
||||
public delegate void LocomotiveDelegate(DrawningLocomotive locomotive);
|
||||
}
|
Loading…
Reference in New Issue
Block a user