From b5f38d5a2a128ab2b36bb223c87494278a51502c Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 22 Nov 2022 14:42:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B8?= =?UTF-8?q?=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20FormPlaneCon?= =?UTF-8?q?fig.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormPlaneConfig.cs | 80 +++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 17241ff..b863e89 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -76,11 +76,11 @@ namespace Airbus switch (e.Data.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); break; case "labelModifiedObject": - _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, - checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, + checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -90,13 +90,13 @@ namespace Airbus //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Control).DoDragDrop((sender as Control).Name, DragDropEffects.Move | DragDropEffects.Copy); } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(typeof(Color))) + if (e.Data.GetDataPresent(DataFormats.Text)) { e.Effect = DragDropEffects.Copy; } @@ -109,13 +109,78 @@ namespace Airbus //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane and set Color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelBaseColor.BackColor = Color.Red; + break; + case "panelBlack": + labelBaseColor.BackColor = Color.Black; + break; + case "panelGreen": + labelBaseColor.BackColor = Color.Green; + break; + case "panelYellow": + labelBaseColor.BackColor = Color.Yellow; + break; + case "panelBlue": + labelBaseColor.BackColor = Color.Blue; + break; + case "panelPurple": + labelBaseColor.BackColor = Color.Purple; + break; + case "panelGray": + labelBaseColor.BackColor = Color.DarkGray; + break; + case "panelWhite": + labelBaseColor.BackColor = Color.White; + break; + } + } + + //проверка получаемой информации (её типа на соответсвие требуемому) + private void LabelAddColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } } //принимаем дополнительный цвет private void labelAddColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane is DrawningSuperAirbus and set add color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelAddColor.BackColor = Color.Red; + break; + case "panelBlack": + labelAddColor.BackColor = Color.Black; + break; + case "panelGreen": + labelAddColor.BackColor = Color.Green; + break; + case "panelYellow": + labelAddColor.BackColor = Color.Yellow; + break; + case "panelBlue": + labelAddColor.BackColor = Color.Blue; + break; + case "panelPurple": + labelAddColor.BackColor = Color.Purple; + break; + case "panelGray": + labelAddColor.BackColor = Color.DarkGray; + break; + case "panelWhite": + labelAddColor.BackColor = Color.White; + break; + } } //добавление самолета @@ -125,6 +190,7 @@ namespace Airbus Close(); } + //закрытие формы конфигурации private void ButtonCancel_Click(object sender, EventArgs e) { Close();