Eliseev E.E. LabWork05 #6

Merged
eegov merged 11 commits from LabWork05 into LabWork04 2022-11-07 10:02:56 +04:00
2 changed files with 84 additions and 15 deletions
Showing only changes of commit 969ab084ec - Show all commits

View File

@ -283,6 +283,7 @@
this.labelAddColor.Text = "Доп. цвет";
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop);
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter);
//
// labelBaseColor
//

View File

@ -79,10 +79,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;
}
@ -93,32 +93,97 @@ 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)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
//принимаем основной цвет
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;
}
}
//добавление машины
@ -128,9 +193,12 @@ namespace Airbus
Close();
}
//закрытие формы конфигурации
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
}
}