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