Добить как-нибудь применение доп цвета в форме

This commit is contained in:
Arklightning 2022-11-27 15:08:57 +04:00
parent 12ec39dd21
commit 92b5d17585
5 changed files with 147 additions and 60 deletions

View File

@ -12,16 +12,16 @@ namespace Trolleybus
/// <summary> /// <summary>
/// Дополнительный цвет /// Дополнительный цвет
/// </summary> /// </summary>
public Color DopColor { get; private set; } public Color DopColor { get; set; }
/// <summary> /// <summary>
/// Признак наличия обвеса /// Признак наличия обвеса
/// </summary> /// </summary>
public bool BodyKit { get; private set; } public bool BodyKit { get; set; }
/// <summary> /// <summary>
/// Признак наличия гоночной полосы /// Признак наличия гоночной полосы
/// </summary> /// </summary>
public bool Horns { get; private set; } public bool Horns { get; set; }
public bool Battary { get; private set; } public bool Battary { get; set; }
/// <summary> /// <summary>
/// Инициализация свойств /// Инициализация свойств
/// </summary> /// </summary>

View File

@ -23,7 +23,7 @@ namespace Trolleybus
/// <summary> /// <summary>
/// Цвет кузова /// Цвет кузова
/// </summary> /// </summary>
public Color BodyColor { get; private set; } public Color BodyColor { get; set; }
/// <summary> /// <summary>
/// Шаг перемещения троллейбуса /// Шаг перемещения троллейбуса
/// </summary> /// </summary>

View File

@ -107,12 +107,34 @@ namespace Trolleybus
_mapTrolleybusCollectionGeneric = null; _mapTrolleybusCollectionGeneric = null;
} }
} }
private void ButtonAddTrolleybus_Click(object sender, EventArgs e) private void AddTrolleybus(DrawingTrolleybus trolleybus)
{ {
if (listBoxMaps.SelectedIndex == -1) if (listBoxMaps.SelectedIndex == -1)
{ {
return; return;
} }
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectTrolleybus(trolleybus) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void ButtonAddTrolleybus_Click(object sender, EventArgs e)
{
var formTrolleybusConfig = new FormTrolleybusConfig();
formTrolleybusConfig.AddEvent(AddTrolleybus);
formTrolleybusConfig.Show();
/*if (listBoxMaps.SelectedIndex == -1)
{
return;
}
Form1 form = new(); Form1 form = new();
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
@ -126,7 +148,7 @@ namespace Trolleybus
{ {
MessageBox.Show("Не удалось добавить объект"); MessageBox.Show("Не удалось добавить объект");
} }
} }*/
} }
/// <summary> /// <summary>
/// Удаление объекта /// Удаление объекта

View File

@ -29,8 +29,9 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBoxConfig = new System.Windows.Forms.GroupBox(); this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
this.labelModifiedObject = new System.Windows.Forms.Label(); this.labelModifiedObject = new System.Windows.Forms.Label();
this.lebelSimpleObject = new System.Windows.Forms.Label(); this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox(); this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelPurple = new System.Windows.Forms.Panel(); this.panelPurple = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel(); this.panelBlack = new System.Windows.Forms.Panel();
@ -50,9 +51,8 @@
this.panelObject = new System.Windows.Forms.Panel(); this.panelObject = new System.Windows.Forms.Panel();
this.labelDopColor = new System.Windows.Forms.Label(); this.labelDopColor = new System.Windows.Forms.Label();
this.labelColor = new System.Windows.Forms.Label(); this.labelColor = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.buttonOk = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
this.groupBoxConfig.SuspendLayout(); this.groupBoxConfig.SuspendLayout();
this.groupBoxColors.SuspendLayout(); this.groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
@ -65,7 +65,7 @@
// //
this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit); this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit);
this.groupBoxConfig.Controls.Add(this.labelModifiedObject); this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
this.groupBoxConfig.Controls.Add(this.lebelSimpleObject); this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColors); this.groupBoxConfig.Controls.Add(this.groupBoxColors);
this.groupBoxConfig.Controls.Add(this.checkBoxBattary); this.groupBoxConfig.Controls.Add(this.checkBoxBattary);
this.groupBoxConfig.Controls.Add(this.checkBoxHorns); this.groupBoxConfig.Controls.Add(this.checkBoxHorns);
@ -80,6 +80,16 @@
this.groupBoxConfig.TabStop = false; this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры"; this.groupBoxConfig.Text = "Параметры";
// //
// checkBoxBodyKit
//
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(11, 224);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(89, 24);
this.checkBoxBodyKit.TabIndex = 10;
this.checkBoxBodyKit.Text = "BodyKit";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
//
// labelModifiedObject // labelModifiedObject
// //
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -88,16 +98,19 @@
this.labelModifiedObject.Size = new System.Drawing.Size(130, 34); this.labelModifiedObject.Size = new System.Drawing.Size(130, 34);
this.labelModifiedObject.TabIndex = 9; this.labelModifiedObject.TabIndex = 9;
this.labelModifiedObject.Text = "Продвинутый"; this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_Mouse_Down);
// //
// lebelSimpleObject // labelSimpleObject
// //
this.lebelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lebelSimpleObject.Location = new System.Drawing.Point(336, 214); this.labelSimpleObject.Location = new System.Drawing.Point(336, 214);
this.lebelSimpleObject.Name = "lebelSimpleObject"; this.labelSimpleObject.Name = "labelSimpleObject";
this.lebelSimpleObject.Size = new System.Drawing.Size(100, 34); this.labelSimpleObject.Size = new System.Drawing.Size(100, 34);
this.lebelSimpleObject.TabIndex = 8; this.labelSimpleObject.TabIndex = 8;
this.lebelSimpleObject.Text = "Простой"; this.labelSimpleObject.Text = "Простой";
this.lebelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelSimpleObject_Mouse_Down); this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_Mouse_Down);
// //
// groupBoxColors // groupBoxColors
// //
@ -115,7 +128,6 @@
this.groupBoxColors.TabIndex = 7; this.groupBoxColors.TabIndex = 7;
this.groupBoxColors.TabStop = false; this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета"; this.groupBoxColors.Text = "Цвета";
this.groupBoxColors.Enter += new System.EventHandler(this.groupBox2_Enter);
// //
// panelPurple // panelPurple
// //
@ -124,6 +136,7 @@
this.panelPurple.Name = "panelPurple"; this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(62, 49); this.panelPurple.Size = new System.Drawing.Size(62, 49);
this.panelPurple.TabIndex = 2; this.panelPurple.TabIndex = 2;
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelBlack // panelBlack
// //
@ -132,6 +145,7 @@
this.panelBlack.Name = "panelBlack"; this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(62, 49); this.panelBlack.Size = new System.Drawing.Size(62, 49);
this.panelBlack.TabIndex = 2; this.panelBlack.TabIndex = 2;
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelGrey // panelGrey
// //
@ -140,6 +154,7 @@
this.panelGrey.Name = "panelGrey"; this.panelGrey.Name = "panelGrey";
this.panelGrey.Size = new System.Drawing.Size(62, 49); this.panelGrey.Size = new System.Drawing.Size(62, 49);
this.panelGrey.TabIndex = 2; this.panelGrey.TabIndex = 2;
this.panelGrey.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelWhite // panelWhite
// //
@ -148,6 +163,7 @@
this.panelWhite.Name = "panelWhite"; this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(62, 49); this.panelWhite.Size = new System.Drawing.Size(62, 49);
this.panelWhite.TabIndex = 2; this.panelWhite.TabIndex = 2;
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelYellow // panelYellow
// //
@ -156,6 +172,7 @@
this.panelYellow.Name = "panelYellow"; this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(62, 49); this.panelYellow.Size = new System.Drawing.Size(62, 49);
this.panelYellow.TabIndex = 2; this.panelYellow.TabIndex = 2;
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelBlue // panelBlue
// //
@ -164,6 +181,7 @@
this.panelBlue.Name = "panelBlue"; this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(62, 49); this.panelBlue.Size = new System.Drawing.Size(62, 49);
this.panelBlue.TabIndex = 1; this.panelBlue.TabIndex = 1;
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelGreen // panelGreen
// //
@ -172,6 +190,7 @@
this.panelGreen.Name = "panelGreen"; this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(62, 50); this.panelGreen.Size = new System.Drawing.Size(62, 50);
this.panelGreen.TabIndex = 1; this.panelGreen.TabIndex = 1;
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// panelRed // panelRed
// //
@ -180,6 +199,7 @@
this.panelRed.Name = "panelRed"; this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(62, 49); this.panelRed.Size = new System.Drawing.Size(62, 49);
this.panelRed.TabIndex = 0; this.panelRed.TabIndex = 0;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
// //
// checkBoxBattary // checkBoxBattary
// //
@ -245,77 +265,78 @@
// //
// pictureBoxObject // pictureBoxObject
// //
this.pictureBoxObject.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBoxObject.Location = new System.Drawing.Point(27, 81); this.pictureBoxObject.Location = new System.Drawing.Point(27, 81);
this.pictureBoxObject.Name = "pictureBoxObject"; this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(218, 141); this.pictureBoxObject.Size = new System.Drawing.Size(346, 208);
this.pictureBoxObject.TabIndex = 1; this.pictureBoxObject.TabIndex = 1;
this.pictureBoxObject.TabStop = false; this.pictureBoxObject.TabStop = false;
// //
// panelObject // panelObject
// //
this.panelObject.AllowDrop = true;
this.panelObject.Controls.Add(this.labelDopColor); this.panelObject.Controls.Add(this.labelDopColor);
this.panelObject.Controls.Add(this.labelColor); this.panelObject.Controls.Add(this.labelColor);
this.panelObject.Controls.Add(this.pictureBoxObject); this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Location = new System.Drawing.Point(698, 39); this.panelObject.Location = new System.Drawing.Point(698, 39);
this.panelObject.Name = "panelObject"; this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(288, 245); this.panelObject.Size = new System.Drawing.Size(412, 316);
this.panelObject.TabIndex = 2; this.panelObject.TabIndex = 2;
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop); this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter); this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
// //
// labelDopColor // labelDopColor
// //
this.labelDopColor.AllowDrop = true;
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelDopColor.Location = new System.Drawing.Point(139, 26); this.labelDopColor.Location = new System.Drawing.Point(139, 26);
this.labelDopColor.Name = "labelDopColor"; this.labelDopColor.Name = "labelDopColor";
this.labelDopColor.Size = new System.Drawing.Size(106, 52); this.labelDopColor.Size = new System.Drawing.Size(106, 52);
this.labelDopColor.TabIndex = 3; this.labelDopColor.TabIndex = 3;
this.labelDopColor.Text = "Доп цвет"; this.labelDopColor.Text = "Доп цвет";
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
// //
// labelColor // labelColor
// //
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(27, 26); this.labelColor.Location = new System.Drawing.Point(27, 26);
this.labelColor.Name = "labelColor"; this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(106, 52); this.labelColor.Size = new System.Drawing.Size(106, 52);
this.labelColor.TabIndex = 2; this.labelColor.TabIndex = 2;
this.labelColor.Text = "Цвет"; this.labelColor.Text = "Цвет";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
// //
// button1 // buttonOk
// //
this.button1.Location = new System.Drawing.Point(725, 290); this.buttonOk.Location = new System.Drawing.Point(725, 361);
this.button1.Name = "button1"; this.buttonOk.Name = "buttonOk";
this.button1.Size = new System.Drawing.Size(106, 50); this.buttonOk.Size = new System.Drawing.Size(106, 50);
this.button1.TabIndex = 3; this.buttonOk.TabIndex = 3;
this.button1.Text = "Добваить"; this.buttonOk.Text = "Добваить";
this.button1.UseVisualStyleBackColor = true; this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
// //
// button2 // buttonCancel
// //
this.button2.Location = new System.Drawing.Point(837, 290); this.buttonCancel.Location = new System.Drawing.Point(837, 361);
this.button2.Name = "button2"; this.buttonCancel.Name = "buttonCancel";
this.button2.Size = new System.Drawing.Size(106, 50); this.buttonCancel.Size = new System.Drawing.Size(106, 50);
this.button2.TabIndex = 4; this.buttonCancel.TabIndex = 4;
this.button2.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.button2.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
//
// checkBoxBodyKit
//
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(11, 224);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(89, 24);
this.checkBoxBodyKit.TabIndex = 10;
this.checkBoxBodyKit.Text = "BodyKit";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
// //
// FormTrolleybusConfig // FormTrolleybusConfig
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1180, 482); this.ClientSize = new System.Drawing.Size(1180, 482);
this.Controls.Add(this.button2); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.button1); this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panelObject); this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxConfig); this.Controls.Add(this.groupBoxConfig);
this.Name = "FormTrolleybusConfig"; this.Name = "FormTrolleybusConfig";
@ -345,7 +366,7 @@
private System.Windows.Forms.Label labelWeight; private System.Windows.Forms.Label labelWeight;
private System.Windows.Forms.Label labelSpeed; private System.Windows.Forms.Label labelSpeed;
private System.Windows.Forms.Label labelModifiedObject; private System.Windows.Forms.Label labelModifiedObject;
private System.Windows.Forms.Label lebelSimpleObject; private System.Windows.Forms.Label labelSimpleObject;
private System.Windows.Forms.Panel panelPurple; private System.Windows.Forms.Panel panelPurple;
private System.Windows.Forms.Panel panelBlack; private System.Windows.Forms.Panel panelBlack;
private System.Windows.Forms.Panel panelGrey; private System.Windows.Forms.Panel panelGrey;
@ -355,8 +376,8 @@
private System.Windows.Forms.Panel panelObject; private System.Windows.Forms.Panel panelObject;
private System.Windows.Forms.Label labelDopColor; private System.Windows.Forms.Label labelDopColor;
private System.Windows.Forms.Label labelColor; private System.Windows.Forms.Label labelColor;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.CheckBox checkBoxBodyKit; private System.Windows.Forms.CheckBox checkBoxBodyKit;
} }
} }

View File

@ -17,13 +17,23 @@ namespace Trolleybus
public FormTrolleybusConfig() public FormTrolleybusConfig()
{ {
InitializeComponent(); InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelGrey.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelRed.MouseDown += PanelColor_MouseDown;
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (object sender, EventArgs e) => Close();
} }
private void DrawTrolleybus() private void DrawTrolleybus()
{ {
Bitmap btm = new(pictureBoxObject.Width, pictureBoxObject.Height); Bitmap btm = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(btm); Graphics gr = Graphics.FromImage(btm);
_trolleybus?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); _trolleybus?.SetPosition(25, 25, pictureBoxObject.Width, pictureBoxObject.Height);
_trolleybus?.DrawTransport(gr); _trolleybus?.DrawTransport(gr);
pictureBoxObject.Image = btm; pictureBoxObject.Image = btm;
} }
@ -40,12 +50,7 @@ namespace Trolleybus
} }
} }
private void groupBox2_Enter(object sender, EventArgs e) private void labelObject_Mouse_Down(object sender, MouseEventArgs e)
{
}
private void labelSimpleObject_Mouse_Down(object sender, MouseEventArgs e)
{ {
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
} }
@ -64,6 +69,7 @@ namespace Trolleybus
private void panelObject_DragDrop(object sender, DragEventArgs e) private void panelObject_DragDrop(object sender, DragEventArgs e)
{ {
//labelColor.BackColor = Color.Red;
switch (e.Data.GetData(DataFormats.Text).ToString()) switch (e.Data.GetData(DataFormats.Text).ToString())
{ {
case "labelSimpleObject": case "labelSimpleObject":
@ -71,11 +77,49 @@ namespace Trolleybus
break; break;
case "labelModifiedObject": case "labelModifiedObject":
_trolleybus = new DrawningSmallTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, _trolleybus = new DrawningSmallTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxHorns.Checked, checkBoxBattary.Checked, checkBoxBodyKit.Checked); checkBoxBodyKit.Checked, checkBoxHorns.Checked, checkBoxBattary.Checked);
break; break;
} }
DrawTrolleybus(); DrawTrolleybus();
} }
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
//проверка на пустоту объекта
if (_trolleybus != null)
{
_trolleybus.Trolleybus.BodyColor = (Color)e.Data.GetData(typeof(Color));
DrawTrolleybus();
}
}
private void LabelAddColor_DragDrop(object sender, DragEventArgs e)
{
//проверка на пустоту объекта и правильную сущноть
if (_trolleybus != null && _trolleybus.Trolleybus is EntitySmallTrolleybus smallTrolleybus)
{
smallTrolleybus.DopColor = (Color)e.Data.GetData(typeof(Color));
DrawTrolleybus();
}
}
private void ButtonOk_Click(object sender, EventArgs e) private void ButtonOk_Click(object sender, EventArgs e)
{ {
EventAddTrolleybus?.Invoke(_trolleybus); EventAddTrolleybus?.Invoke(_trolleybus);