diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 17241ff..7acb9c9 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -52,6 +52,8 @@ namespace Airbus EventAddPlane += ev; } } + + //передаем информацию при нажатии на Label private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -76,10 +78,10 @@ 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, + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -96,7 +98,7 @@ namespace Airbus //проверка получаемой информации (её типа на соответсвие требуемому) 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 +111,82 @@ 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 "panelBlue": + labelBaseColor.BackColor = Color.Blue; + break; + case "panelYellow": + labelBaseColor.BackColor = Color.Yellow; + break; + case "panelPurple": + labelBaseColor.BackColor = Color.Purple; + break; + case "panelWhite": + labelBaseColor.BackColor = Color.White; + break; + case "panelGray": + labelBaseColor.BackColor = Color.DarkGray; + break; + } + + DrawPlane(); + } + + //проверка получаемой информации (её типа на соответсвие требуемому) + 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) + 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 "panelBlue": + labelAddColor.BackColor = Color.Blue; + break; + case "panelYellow": + labelAddColor.BackColor = Color.Yellow; + break; + case "panelPurple": + labelAddColor.BackColor = Color.Purple; + break; + case "panelWhite": + labelAddColor.BackColor = Color.White; + break; + case "panelGray": + labelAddColor.BackColor = Color.DarkGray; + break; + } + + DrawPlane(); } //добавление самолета