5 работа работает
This commit is contained in:
parent
26a589af93
commit
e5a45732e9
@ -42,5 +42,9 @@ namespace ProjectElectricLocomotive.Entities
|
||||
Battery = battery;
|
||||
}
|
||||
|
||||
public void ChangeAdditionalColor(Color additionalColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,5 +42,10 @@ namespace ProjectElectricLocomotive.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void ChangeBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
298
ElectricLocomotive/FormLocomotiveConfig.Designer.cs
generated
298
ElectricLocomotive/FormLocomotiveConfig.Designer.cs
generated
@ -29,17 +29,17 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
label4 = new Label();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBox2 = new GroupBox();
|
||||
panel8 = new Panel();
|
||||
panel7 = new Panel();
|
||||
panel6 = new Panel();
|
||||
panel5 = new Panel();
|
||||
panel4 = new Panel();
|
||||
panel3 = new Panel();
|
||||
panel2 = new Panel();
|
||||
panel1 = new Panel();
|
||||
panelPurple = new Panel();
|
||||
panelBlack = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxBattery = new CheckBox();
|
||||
checkBoxHorns = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
@ -47,21 +47,22 @@
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
label5 = new Label();
|
||||
label6 = new Label();
|
||||
label7 = new Label();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
labelBodyColor = new Label();
|
||||
labelAdditionalColor = new Label();
|
||||
buttonOK = new Button();
|
||||
buttonClose = new Button();
|
||||
panelObject = new Panel();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(label4);
|
||||
groupBox1.Controls.Add(labelModifiedObject);
|
||||
groupBox1.Controls.Add(labelSimpleObject);
|
||||
groupBox1.Controls.Add(groupBox2);
|
||||
groupBox1.Controls.Add(checkBoxBattery);
|
||||
@ -77,15 +78,16 @@
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Параметры";
|
||||
//
|
||||
// label4
|
||||
// labelModifiedObject
|
||||
//
|
||||
label4.BorderStyle = BorderStyle.FixedSingle;
|
||||
label4.Location = new Point(404, 219);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(113, 35);
|
||||
label4.TabIndex = 8;
|
||||
label4.Text = "Продвинутый";
|
||||
label4.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(397, 219);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(113, 35);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
@ -96,17 +98,18 @@
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(panel8);
|
||||
groupBox2.Controls.Add(panel7);
|
||||
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.Controls.Add(panelPurple);
|
||||
groupBox2.Controls.Add(panelBlack);
|
||||
groupBox2.Controls.Add(panelGray);
|
||||
groupBox2.Controls.Add(panelWhite);
|
||||
groupBox2.Controls.Add(panelYellow);
|
||||
groupBox2.Controls.Add(panelBlue);
|
||||
groupBox2.Controls.Add(panelGreen);
|
||||
groupBox2.Controls.Add(panelRed);
|
||||
groupBox2.Location = new Point(278, 57);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(239, 135);
|
||||
@ -114,69 +117,77 @@
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Цвета";
|
||||
//
|
||||
// panel8
|
||||
// panelPurple
|
||||
//
|
||||
panel8.BackColor = Color.Purple;
|
||||
panel8.Location = new Point(184, 81);
|
||||
panel8.Name = "panel8";
|
||||
panel8.Size = new Size(40, 40);
|
||||
panel8.TabIndex = 3;
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(184, 81);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(40, 40);
|
||||
panelPurple.TabIndex = 3;
|
||||
panelPurple.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel7
|
||||
// panelBlack
|
||||
//
|
||||
panel7.BackColor = Color.Black;
|
||||
panel7.Location = new Point(129, 81);
|
||||
panel7.Name = "panel7";
|
||||
panel7.Size = new Size(40, 40);
|
||||
panel7.TabIndex = 3;
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(129, 81);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(40, 40);
|
||||
panelBlack.TabIndex = 3;
|
||||
panelBlack.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel6
|
||||
// panelGray
|
||||
//
|
||||
panel6.BackColor = Color.Gray;
|
||||
panel6.Location = new Point(73, 81);
|
||||
panel6.Name = "panel6";
|
||||
panel6.Size = new Size(40, 40);
|
||||
panel6.TabIndex = 3;
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(73, 81);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(40, 40);
|
||||
panelGray.TabIndex = 3;
|
||||
panelGray.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel5
|
||||
// panelWhite
|
||||
//
|
||||
panel5.BackColor = Color.White;
|
||||
panel5.Location = new Point(15, 81);
|
||||
panel5.Name = "panel5";
|
||||
panel5.Size = new Size(40, 40);
|
||||
panel5.TabIndex = 4;
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(15, 81);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(40, 40);
|
||||
panelWhite.TabIndex = 4;
|
||||
panelWhite.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel4
|
||||
// panelYellow
|
||||
//
|
||||
panel4.BackColor = Color.Yellow;
|
||||
panel4.Location = new Point(184, 26);
|
||||
panel4.Name = "panel4";
|
||||
panel4.Size = new Size(40, 40);
|
||||
panel4.TabIndex = 3;
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(184, 26);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(40, 40);
|
||||
panelYellow.TabIndex = 3;
|
||||
panelYellow.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel3
|
||||
// panelBlue
|
||||
//
|
||||
panel3.BackColor = Color.Blue;
|
||||
panel3.Location = new Point(129, 26);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(40, 40);
|
||||
panel3.TabIndex = 2;
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(129, 26);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(40, 40);
|
||||
panelBlue.TabIndex = 2;
|
||||
panelBlue.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel2
|
||||
// panelGreen
|
||||
//
|
||||
panel2.BackColor = Color.Green;
|
||||
panel2.Location = new Point(73, 26);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(40, 40);
|
||||
panel2.TabIndex = 1;
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(73, 26);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(40, 40);
|
||||
panelGreen.TabIndex = 1;
|
||||
panelGreen.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// panel1
|
||||
// panelRed
|
||||
//
|
||||
panel1.BackColor = Color.Red;
|
||||
panel1.Location = new Point(15, 26);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(40, 40);
|
||||
panel1.TabIndex = 0;
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(15, 26);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(40, 40);
|
||||
panelRed.TabIndex = 0;
|
||||
panelRed.MouseDown += panelObject_MouseDown;
|
||||
//
|
||||
// checkBoxBattery
|
||||
//
|
||||
@ -238,70 +249,80 @@
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(608, 90);
|
||||
pictureBoxObject.Location = new Point(11, 60);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(244, 181);
|
||||
pictureBoxObject.Size = new Size(244, 194);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// label5
|
||||
// labelBodyColor
|
||||
//
|
||||
label5.BorderStyle = BorderStyle.FixedSingle;
|
||||
label5.Location = new Point(586, 42);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(287, 243);
|
||||
label5.TabIndex = 2;
|
||||
labelBodyColor.AllowDrop = true;
|
||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBodyColor.Location = new Point(11, 14);
|
||||
labelBodyColor.Name = "labelBodyColor";
|
||||
labelBodyColor.Size = new Size(113, 35);
|
||||
labelBodyColor.TabIndex = 8;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelObject_DragEnter;
|
||||
//
|
||||
// label6
|
||||
// labelAdditionalColor
|
||||
//
|
||||
label6.BorderStyle = BorderStyle.FixedSingle;
|
||||
label6.Location = new Point(608, 52);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(113, 35);
|
||||
label6.TabIndex = 8;
|
||||
label6.Text = "Цвет";
|
||||
label6.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(142, 14);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(113, 35);
|
||||
labelAdditionalColor.TabIndex = 9;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += labelObject_DragEnter;
|
||||
//
|
||||
// label7
|
||||
// buttonOK
|
||||
//
|
||||
label7.BorderStyle = BorderStyle.FixedSingle;
|
||||
label7.Location = new Point(739, 52);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(113, 35);
|
||||
label7.TabIndex = 9;
|
||||
label7.Text = "Доп. цвет";
|
||||
label7.TextAlign = ContentAlignment.MiddleCenter;
|
||||
buttonOK.Location = new Point(608, 295);
|
||||
buttonOK.Name = "buttonOK";
|
||||
buttonOK.Size = new Size(113, 29);
|
||||
buttonOK.TabIndex = 10;
|
||||
buttonOK.Text = "Добавить";
|
||||
buttonOK.UseVisualStyleBackColor = true;
|
||||
buttonOK.Click += buttonOk_Click;
|
||||
//
|
||||
// button1
|
||||
// buttonClose
|
||||
//
|
||||
button1.Location = new Point(608, 295);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(113, 29);
|
||||
button1.TabIndex = 10;
|
||||
button1.Text = "Добавить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
buttonClose.Location = new Point(739, 295);
|
||||
buttonClose.Name = "buttonClose";
|
||||
buttonClose.Size = new Size(113, 29);
|
||||
buttonClose.TabIndex = 11;
|
||||
buttonClose.Text = "Отмена";
|
||||
buttonClose.UseVisualStyleBackColor = true;
|
||||
buttonClose.Click += buttonClose_Click;
|
||||
//
|
||||
// button2
|
||||
// panelObject
|
||||
//
|
||||
button2.Location = new Point(739, 295);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(113, 29);
|
||||
button2.TabIndex = 11;
|
||||
button2.Text = "Отмена";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelAdditionalColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Controls.Add(labelBodyColor);
|
||||
panelObject.Location = new Point(597, 31);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(266, 254);
|
||||
panelObject.TabIndex = 12;
|
||||
panelObject.DragDrop += panelObject_DragDrop;
|
||||
panelObject.DragEnter += panelObject_DragEnter;
|
||||
//
|
||||
// FormLocomotiveConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1149, 339);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(label7);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(pictureBoxObject);
|
||||
ClientSize = new Size(911, 339);
|
||||
Controls.Add(buttonClose);
|
||||
Controls.Add(buttonOK);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(panelObject);
|
||||
Name = "FormLocomotiveConfig";
|
||||
Text = "FormLocomotiveConfig";
|
||||
groupBox1.ResumeLayout(false);
|
||||
@ -310,6 +331,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -323,21 +345,21 @@
|
||||
private CheckBox checkBoxBattery;
|
||||
private CheckBox checkBoxHorns;
|
||||
private GroupBox groupBox2;
|
||||
private Panel panel1;
|
||||
private Panel panel8;
|
||||
private Panel panel7;
|
||||
private Panel panel6;
|
||||
private Panel panel5;
|
||||
private Panel panel4;
|
||||
private Panel panel3;
|
||||
private Panel panel2;
|
||||
private Label label4;
|
||||
private Panel panelRed;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label label5;
|
||||
private Label label6;
|
||||
private Label label7;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Label labelBodyColor;
|
||||
private Label labelAdditionalColor;
|
||||
private Button buttonOK;
|
||||
private Button buttonClose;
|
||||
private Panel panelObject;
|
||||
}
|
||||
}
|
@ -12,5 +12,48 @@ namespace ProjectElectricLocomotive
|
||||
{
|
||||
public partial class FormLocomotiveConfig
|
||||
{
|
||||
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void panelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
PanelObject_DragEnter(sender, e);
|
||||
}
|
||||
private void labelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
LabelObject_DragEnter(sender, e);
|
||||
}
|
||||
|
||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
LabelBodyColor_DragDrop(sender, e);
|
||||
}
|
||||
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
LabelAdditionalColor_DragDrop(sender, e);
|
||||
}
|
||||
|
||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
PanelObject_DragDrop(sender, e);
|
||||
}
|
||||
|
||||
private void buttonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
ButtonOk_Click(sender, e);
|
||||
}
|
||||
|
||||
private void buttonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
ButtonClose_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,10 +105,34 @@ namespace ProjectElectricLocomotive
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formCarConfig = new FormLocomotiveConfig();
|
||||
// TODO Call method AddEvent from formCarConfig
|
||||
formCarConfig.Show();
|
||||
var formLocomotiveConfig = new FormLocomotiveConfig();
|
||||
formLocomotiveConfig.AddEvent(addLocomotive);
|
||||
formLocomotiveConfig.Show();
|
||||
}
|
||||
private void addLocomotive(DrawningLocomotive SelectedLocomotive)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedLocomotive.SetPictureSize(pictureBoxCollection.Size);
|
||||
if (obj + SelectedLocomotive > 0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
|
||||
pictureBoxCollection.Image = obj.ShowLocomotives();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
@ -131,7 +155,14 @@ namespace ProjectElectricLocomotive
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
int pos;
|
||||
try
|
||||
{
|
||||
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
} catch(System.FormatException ex)
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
if (obj - pos != -1)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectElectricLocomotive.DrawningObjects;
|
||||
using ProjectElectricLocomotive.Entities;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
@ -114,10 +116,75 @@ namespace ProjectElectricLocomotive
|
||||
break;
|
||||
}
|
||||
DrawLocomotive();
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
}
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
|
||||
private void LabelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Panel
|
||||
/// </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 LabelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_locomotive is null)
|
||||
{
|
||||
MessageBox.Show("Локомотив не задан");
|
||||
return;
|
||||
}
|
||||
Color bodyColor = (Color)e.Data?.GetData(typeof(Color));
|
||||
|
||||
_locomotive?.EntityLocomotive.ChangeBodyColor(bodyColor);
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передача дополнительного цвета цвета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_locomotive is null)
|
||||
{
|
||||
MessageBox.Show("Локомотив не задан");
|
||||
return;
|
||||
}
|
||||
Color addColor = (Color)e.Data?.GetData(typeof(Color));
|
||||
|
||||
if (_locomotive is DrawningElectricLocomotive)
|
||||
{
|
||||
(_locomotive?.EntityLocomotive as EntityElectricLocomotive).ChangeAdditionalColor(addColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Нельзя задать доп. цвет обычному локомотиву");
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление локомотива
|
||||
/// </summary>
|
||||
@ -129,5 +196,15 @@ namespace ProjectElectricLocomotive
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отмена Добавления локомотива
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddLocomotive?.Invoke(_locomotive);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user