Добавление комментариев, удаление неиспользуемых методов

This commit is contained in:
Мельников Игорь 2022-11-09 19:07:16 +04:00
parent cd3c8b9b6d
commit 722d1769ac
3 changed files with 64 additions and 12 deletions

View File

@ -267,7 +267,6 @@
this.checkBoxHasFuelTank.TabIndex = 5;
this.checkBoxHasFuelTank.Text = "Наличие топливного бака";
this.checkBoxHasFuelTank.UseVisualStyleBackColor = true;
this.checkBoxHasFuelTank.CheckedChanged += new System.EventHandler(this.CheckBoxexAdditionalElements_CheckedChanged);
//
// checkBoxHasPipe
//
@ -278,7 +277,6 @@
this.checkBoxHasPipe.TabIndex = 4;
this.checkBoxHasPipe.Text = "Наличие трубы";
this.checkBoxHasPipe.UseVisualStyleBackColor = true;
this.checkBoxHasPipe.CheckedChanged += new System.EventHandler(this.CheckBoxexAdditionalElements_CheckedChanged);
//
// numericUpDownWeight
//

View File

@ -1,9 +1,21 @@
namespace Locomotives
{
/// <summary>
/// Форма создания объекта
/// </summary>
public partial class FormLocomotiveConfig : Form
{
/// <summary>
/// Переменная - выбранный локомотив
/// </summary>
DrawningLocomotive _locomotive = null;
/// <summary>
/// Событие
/// </summary>
private event LocomotiveDelegate EventAddLocomotive;
/// <summary>
/// Конструктор
/// </summary>
public FormLocomotiveConfig()
{
InitializeComponent();
@ -15,8 +27,12 @@
panelRed.MouseDown += PanelColor_MouseDown;
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
//Лямбда-выражение для закрытия окна
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Отрисовка локомотива
/// </summary>
private void DrawLocomotive()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
@ -25,6 +41,10 @@
_locomotive?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev"></param>
public void AddEvent(LocomotiveDelegate ev)
{
if (EventAddLocomotive == null)
@ -36,11 +56,20 @@
EventAddLocomotive += ev;
}
}
/// <summary>
/// Передаём информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
@ -52,6 +81,11 @@
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действие при приёме получаемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data.GetData(DataFormats.Text).ToString())
@ -65,11 +99,20 @@
}
DrawLocomotive();
}
/// <summary>
/// Отправляем цвет с панели
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel).DoDragDrop((sender as Panel).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
@ -81,13 +124,21 @@
e.Effect= DragDropEffects.None;
}
}
/// <summary>
/// Принимаем основной цвет
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
_locomotive.Locomotive.BodyColor = (Color)e.Data.GetData(typeof(Color));
DrawLocomotive();
}
/// <summary>
/// Принимаем дополнительный цвет
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_locomotive.Locomotive is EntityWarmlyLocomotive warmlyLocomotive)
@ -96,16 +147,15 @@
}
DrawLocomotive();
}
/// <summary>
/// Добавление локомотива
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddLocomotive?.Invoke(_locomotive);
Close();
}
private void CheckBoxexAdditionalElements_CheckedChanged(object sender, EventArgs e)
{
DrawLocomotive();
}
}
}

View File

@ -1,4 +1,8 @@
namespace Locomotives
{
/// <summary>
/// Делегат для передачи объекта-локомотива
/// </summary>
/// <param name="locomotive"></param>
public delegate void LocomotiveDelegate(DrawningLocomotive locomotive);
}