Настройка передачи цветов в FormPlaneConfig.

This commit is contained in:
devil_1nc 2022-11-22 14:42:28 +04:00
parent 23bc46fd64
commit b5f38d5a2a

View File

@ -76,10 +76,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;
}
@ -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();