продолжение работы

This commit is contained in:
ALINA_KURBANOVA 2023-11-14 17:16:57 +04:00
parent b055a7964c
commit 39c5d85bda
6 changed files with 499 additions and 315 deletions

View File

@ -1,284 +0,0 @@
namespace WarmlyLocomotive
{
partial class FormCarConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
groupBox1 = new GroupBox();
label1 = new Label();
label2 = new Label();
numericUpDown1 = new NumericUpDown();
numericUpDown2 = new NumericUpDown();
checkBox1 = new CheckBox();
checkBox2 = new CheckBox();
groupBox2 = new GroupBox();
panel1 = new Panel();
panel2 = new Panel();
panel3 = new Panel();
panel4 = new Panel();
panel5 = new Panel();
panel6 = new Panel();
panel7 = new Panel();
panel8 = new Panel();
pictureBox1 = new PictureBox();
label3 = new Label();
label4 = new Label();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(label3);
groupBox1.Controls.Add(label4);
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(checkBox2);
groupBox1.Controls.Add(checkBox1);
groupBox1.Controls.Add(numericUpDown2);
groupBox1.Controls.Add(numericUpDown1);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(label1);
groupBox1.Location = new Point(33, 27);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(404, 283);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Параметры";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 53);
label1.Name = "label1";
label1.Size = new Size(29, 15);
label1.TabIndex = 0;
label1.Text = "Вес:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(6, 92);
label2.Name = "label2";
label2.Size = new Size(62, 15);
label2.TabIndex = 1;
label2.Text = "Скорость:";
label2.Click += label2_Click;
//
// numericUpDown1
//
numericUpDown1.Location = new Point(82, 45);
numericUpDown1.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDown1.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDown1.Name = "numericUpDown1";
numericUpDown1.Size = new Size(70, 23);
numericUpDown1.TabIndex = 2;
numericUpDown1.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDown2
//
numericUpDown2.Location = new Point(82, 90);
numericUpDown2.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDown2.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDown2.Name = "numericUpDown2";
numericUpDown2.Size = new Size(70, 23);
numericUpDown2.TabIndex = 3;
numericUpDown2.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// checkBox1
//
checkBox1.AutoSize = true;
checkBox1.Location = new Point(15, 168);
checkBox1.Name = "checkBox1";
checkBox1.Size = new Size(160, 19);
checkBox1.TabIndex = 4;
checkBox1.Text = "Признак наличия трубы";
checkBox1.UseVisualStyleBackColor = true;
//
// checkBox2
//
checkBox2.AutoSize = true;
checkBox2.Location = new Point(15, 193);
checkBox2.Name = "checkBox2";
checkBox2.Size = new Size(173, 19);
checkBox2.TabIndex = 5;
checkBox2.Text = "Признак наличия прицепа";
checkBox2.UseVisualStyleBackColor = true;
//
// groupBox2
//
groupBox2.Controls.Add(panel7);
groupBox2.Controls.Add(panel8);
groupBox2.Controls.Add(panel6);
groupBox2.Controls.Add(panel5);
groupBox2.Controls.Add(panel4);
groupBox2.Controls.Add(panel3);
groupBox2.Controls.Add(panel2);
groupBox2.Controls.Add(panel1);
groupBox2.Location = new Point(203, 45);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(189, 100);
groupBox2.TabIndex = 6;
groupBox2.TabStop = false;
groupBox2.Text = "Цвета";
//
// panel1
//
panel1.BackColor = Color.Red;
panel1.Location = new Point(6, 22);
panel1.Name = "panel1";
panel1.Size = new Size(32, 31);
panel1.TabIndex = 0;
//
// panel2
//
panel2.BackColor = Color.White;
panel2.Location = new Point(6, 61);
panel2.Name = "panel2";
panel2.Size = new Size(32, 31);
panel2.TabIndex = 1;
//
// panel3
//
panel3.BackColor = Color.Green;
panel3.Location = new Point(53, 22);
panel3.Name = "panel3";
panel3.Size = new Size(32, 31);
panel3.TabIndex = 1;
//
// panel4
//
panel4.BackColor = SystemColors.ControlDark;
panel4.Location = new Point(53, 63);
panel4.Name = "panel4";
panel4.Size = new Size(32, 31);
panel4.TabIndex = 1;
//
// panel5
//
panel5.BackColor = Color.Black;
panel5.Location = new Point(101, 63);
panel5.Name = "panel5";
panel5.Size = new Size(32, 31);
panel5.TabIndex = 1;
//
// panel6
//
panel6.BackColor = Color.Blue;
panel6.Location = new Point(101, 22);
panel6.Name = "panel6";
panel6.Size = new Size(32, 31);
panel6.TabIndex = 1;
//
// panel7
//
panel7.BackColor = Color.Yellow;
panel7.Location = new Point(149, 22);
panel7.Name = "panel7";
panel7.Size = new Size(32, 31);
panel7.TabIndex = 1;
//
// panel8
//
panel8.BackColor = Color.Violet;
panel8.Location = new Point(149, 63);
panel8.Name = "panel8";
panel8.Size = new Size(32, 31);
panel8.TabIndex = 1;
//
// pictureBox1
//
pictureBox1.Location = new Point(496, 42);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(187, 268);
pictureBox1.TabIndex = 1;
pictureBox1.TabStop = false;
//
// label3
//
label3.BorderStyle = BorderStyle.FixedSingle;
label3.Location = new Point(209, 172);
label3.Name = "label3";
label3.Size = new Size(80, 30);
label3.TabIndex = 2;
label3.Text = "Простой";
label3.TextAlign = ContentAlignment.MiddleCenter;
label3.Click += label3_Click;
//
// label4
//
label4.BorderStyle = BorderStyle.FixedSingle;
label4.Location = new Point(304, 172);
label4.Name = "label4";
label4.Size = new Size(85, 30);
label4.TabIndex = 3;
label4.Text = "Продвинутый";
label4.TextAlign = ContentAlignment.MiddleCenter;
//
// FormCarConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 345);
Controls.Add(pictureBox1);
Controls.Add(groupBox1);
Name = "FormCarConfig";
Text = "Создание объекта";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit();
groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private NumericUpDown numericUpDown2;
private NumericUpDown numericUpDown1;
private Label label2;
private Label label1;
private GroupBox groupBox2;
private CheckBox checkBox2;
private CheckBox checkBox1;
private Panel panel7;
private Panel panel8;
private Panel panel6;
private Panel panel5;
private Panel panel4;
private Panel panel3;
private Panel panel2;
private Panel panel1;
private Label label4;
private PictureBox pictureBox1;
private Label label3;
}
}

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WarmlyLocomotive
{
public partial class FormCarConfig : Form
{
public FormCarConfig()
{
InitializeComponent();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -80,6 +80,9 @@ namespace WarmlyLocomotive
/// <param name="e"></param>
private void buttonAdd_Click(object sender, EventArgs e)
{
var formWarmlyLocomotiveConfig = new FormWarmlyLocomotiveConfig();
formWarmlyLocomotiveConfig.AddEvent(Addwarmlylocomotive);
formWarmlyLocomotiveConfig.Show();
if (listBoxStorages.SelectedIndex == -1)
{
return;
@ -103,7 +106,6 @@ namespace WarmlyLocomotive
MessageBox.Show("Не удалось добавить объект");
}
}
}
/// <summary>
/// Удаление объекта из набора

View File

@ -0,0 +1,358 @@
namespace WarmlyLocomotive
{
partial class FormWarmlyLocomotiveConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
groupBoxOptions = new GroupBox();
labelSimpleObject = new Label();
labelModifiedObject = new Label();
groupBoxColor = new GroupBox();
panelYellow = new Panel();
panelPurple = new Panel();
panelBlue = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelRed = new Panel();
checkBoxLuggage = new CheckBox();
checkBoxTrumpet = new CheckBox();
numericUpDownSpeed = new NumericUpDown();
numericUpDownWeight = new NumericUpDown();
label2 = new Label();
label1 = new Label();
pictureBoxObject = new PictureBox();
PanelColor = new Panel();
buttonCancel = new Button();
buttonOk = new Button();
label6 = new Label();
label5 = new Label();
groupBoxOptions.SuspendLayout();
groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
PanelColor.SuspendLayout();
SuspendLayout();
//
// groupBoxOptions
//
groupBoxOptions.Controls.Add(labelSimpleObject);
groupBoxOptions.Controls.Add(labelModifiedObject);
groupBoxOptions.Controls.Add(groupBoxColor);
groupBoxOptions.Controls.Add(checkBoxLuggage);
groupBoxOptions.Controls.Add(checkBoxTrumpet);
groupBoxOptions.Controls.Add(numericUpDownSpeed);
groupBoxOptions.Controls.Add(numericUpDownWeight);
groupBoxOptions.Controls.Add(label2);
groupBoxOptions.Controls.Add(label1);
groupBoxOptions.Location = new Point(33, 27);
groupBoxOptions.Name = "groupBoxOptions";
groupBoxOptions.Size = new Size(404, 283);
groupBoxOptions.TabIndex = 0;
groupBoxOptions.TabStop = false;
groupBoxOptions.Text = "Параметры";
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(209, 172);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(80, 30);
labelSimpleObject.TabIndex = 2;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(304, 172);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(85, 30);
labelModifiedObject.TabIndex = 3;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
//
// groupBoxColor
//
groupBoxColor.Controls.Add(panelYellow);
groupBoxColor.Controls.Add(panelPurple);
groupBoxColor.Controls.Add(panelBlue);
groupBoxColor.Controls.Add(panelBlack);
groupBoxColor.Controls.Add(panelGray);
groupBoxColor.Controls.Add(panelGreen);
groupBoxColor.Controls.Add(panelWhite);
groupBoxColor.Controls.Add(panelRed);
groupBoxColor.Location = new Point(203, 45);
groupBoxColor.Name = "groupBoxColor";
groupBoxColor.Size = new Size(189, 115);
groupBoxColor.TabIndex = 6;
groupBoxColor.TabStop = false;
groupBoxColor.Text = "Цвета";
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(149, 22);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(32, 31);
panelYellow.TabIndex = 1;
panelYellow.MouseDown += LabelObject_MouseDown;
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(149, 63);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(32, 31);
panelPurple.TabIndex = 1;
panelPurple.MouseDown += LabelObject_MouseDown;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(101, 22);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(32, 31);
panelBlue.TabIndex = 1;
panelBlue.MouseDown += LabelObject_MouseDown;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(101, 63);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(32, 31);
panelBlack.TabIndex = 1;
panelBlack.MouseDown += LabelObject_MouseDown;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(53, 63);
panelGray.Name = "panelGray";
panelGray.Size = new Size(32, 29);
panelGray.TabIndex = 1;
panelGray.MouseDown += LabelObject_MouseDown;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(53, 22);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(32, 31);
panelGreen.TabIndex = 1;
panelGreen.MouseDown += LabelObject_MouseDown;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(6, 61);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(32, 31);
panelWhite.TabIndex = 1;
panelWhite.MouseDown += LabelObject_MouseDown;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(6, 22);
panelRed.Name = "panelRed";
panelRed.Size = new Size(32, 31);
panelRed.TabIndex = 0;
panelRed.MouseDown += LabelObject_MouseDown;
//
// checkBoxLuggage
//
checkBoxLuggage.AutoSize = true;
checkBoxLuggage.Location = new Point(15, 193);
checkBoxLuggage.Name = "checkBoxLuggage";
checkBoxLuggage.Size = new Size(173, 19);
checkBoxLuggage.TabIndex = 5;
checkBoxLuggage.Text = "Признак наличия прицепа";
checkBoxLuggage.UseVisualStyleBackColor = true;
//
// checkBoxTrumpet
//
checkBoxTrumpet.AutoSize = true;
checkBoxTrumpet.Location = new Point(15, 168);
checkBoxTrumpet.Name = "checkBoxTrumpet";
checkBoxTrumpet.Size = new Size(160, 19);
checkBoxTrumpet.TabIndex = 4;
checkBoxTrumpet.Text = "Признак наличия трубы";
checkBoxTrumpet.UseVisualStyleBackColor = true;
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(82, 90);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(70, 23);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(82, 45);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(70, 23);
numericUpDownWeight.TabIndex = 2;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(6, 92);
label2.Name = "label2";
label2.Size = new Size(62, 15);
label2.TabIndex = 1;
label2.Text = "Скорость:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 53);
label1.Name = "label1";
label1.Size = new Size(29, 15);
label1.TabIndex = 0;
label1.Text = "Вес:";
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(26, 51);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(195, 158);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// PanelColor
//
PanelColor.AllowDrop = true;
PanelColor.Controls.Add(buttonCancel);
PanelColor.Controls.Add(buttonOk);
PanelColor.Controls.Add(label6);
PanelColor.Controls.Add(label5);
PanelColor.Controls.Add(pictureBoxObject);
PanelColor.Location = new Point(512, 30);
PanelColor.Name = "PanelColor";
PanelColor.Size = new Size(245, 280);
PanelColor.TabIndex = 2;
PanelColor.DragDrop += PanelObject_DragDrop;
PanelColor.DragEnter += PanelObject_DragEnter;
PanelColor.MouseDown += LabelObject_MouseDown;
//
// buttonCancel
//
buttonCancel.Location = new Point(146, 235);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// buttonOk
//
buttonOk.Location = new Point(40, 235);
buttonOk.Name = "buttonOk";
buttonOk.Size = new Size(75, 23);
buttonOk.TabIndex = 4;
buttonOk.Text = "Добавить";
buttonOk.UseVisualStyleBackColor = true;
buttonOk.Click += buttonOk_Click_1;
//
// label6
//
label6.BorderStyle = BorderStyle.FixedSingle;
label6.Location = new Point(129, 13);
label6.Name = "label6";
label6.Size = new Size(80, 30);
label6.TabIndex = 3;
label6.Text = "Доп. цвет";
label6.TextAlign = ContentAlignment.MiddleCenter;
//
// label5
//
label5.BorderStyle = BorderStyle.FixedSingle;
label5.Location = new Point(26, 13);
label5.Name = "label5";
label5.Size = new Size(80, 30);
label5.TabIndex = 2;
label5.Text = "Цвет";
label5.TextAlign = ContentAlignment.MiddleCenter;
//
// FormWarmlyLocomotiveConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 345);
Controls.Add(PanelColor);
Controls.Add(groupBoxOptions);
Name = "FormWarmlyLocomotiveConfig";
Text = "Создание объекта";
groupBoxOptions.ResumeLayout(false);
groupBoxOptions.PerformLayout();
groupBoxColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
PanelColor.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxOptions;
private NumericUpDown numericUpDownSpeed;
private NumericUpDown numericUpDownWeight;
private Label label2;
private Label label1;
private GroupBox groupBoxColor;
private CheckBox checkBoxLuggage;
private CheckBox checkBoxTrumpet;
private Panel panelYellow;
private Panel panelPurple;
private Panel panelBlue;
private Panel panelBlack;
private Panel panelGray;
private Panel panelGreen;
private Panel panelWhite;
private Panel panelRed;
private Label labelModifiedObject;
private PictureBox pictureBoxObject;
private Label labelSimpleObject;
private Label label6;
private Label label5;
private Button buttonCancel;
private Button buttonOk;
public Panel PanelColor;
}
}

View File

@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Tracing;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WarmlyLocomotive.DrawningObjects;
namespace WarmlyLocomotive
{
/// <summary>
/// Делегат для передачи объекта-тепловоза
/// </summary>
/// <param name="warmlylocomotive"></param>
public delegate void CarDelegate(DrawningWarmlyLocomotive warmlylocomotive);
public partial class FormWarmlyLocomotiveConfig : Form
{
/// <summary>
/// Переменная-выбранная машина
/// </summary>
DrawningWarmlyLocomotive? _warmlylocomotive = null;
/// <summary>
/// Событие
/// </summary>
private event CarDelegate? EventAddWarmlyLocomotive;
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(CarDelegate ev)
{
if (EventAddWarmlyLocomotive == null)
{
EventAddWarmlyLocomotive = ev;
}
else
{
EventAddWarmlyLocomotive += ev;
}
}
/// <summary>
/// Конструктор
/// </summary>
public FormWarmlyLocomotiveConfig()
{
InitializeComponent();
panelBlack.MouseDown += PanelColor;
panelPurple.MouseDown += PanelColor;
panelGray.MouseDown += PanelColor;
panelGreen.MouseDown += PanelColor;
panelRed.MouseDown += PanelColor;
panelWhite.MouseDown += PanelColor;
panelYellow.MouseDown += PanelColor;
panelBlue.MouseDown += PanelColor;
buttonCancel.Click += (s, e) => Close();
}
/// <summary>
/// Отрисовать машину
/// </summary>
private void DrawCar()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_warmlylocomotive?.SetPosition(5, 5);
_warmlylocomotive?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <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) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
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())
{
case "labelSimpleObject":
_warmlylocomotive = new DrawningWarmlyLocomotive((int)numericUpDownWeight.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_warmlylocomotive = new DrawningWarmlyLocomotiveWithTrumpet((int)numericUpDownWeight.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxTrumpet.Checked,
checkBoxLuggage.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
}
DrawCar();
}
// TODO Реализовать логику смены цветов: основного и дополнительного(для продвинутого объекта)
/// <summary>
/// Добавление машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddWarmlyLocomotive?.Invoke(_warmlylocomotive);
Close();
}
private void buttonOk_Click_1(object sender, EventArgs e)
{
}
}
}