последний вариант

This commit is contained in:
ikswi 2024-04-04 09:42:34 +04:00
parent 4909a7ffea
commit 12dd60db3f
4 changed files with 35 additions and 57 deletions

View File

@ -7,7 +7,7 @@ public class EntityAirFighter : EntityMilitaryAircraft
{
public Color AdditionalColor { get; private set; }
public void ChooseAdditionalColor(Color additionalColor)
public void SetAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}

View File

@ -11,7 +11,7 @@ public class EntityMilitaryAircraft
public Color BodyColor { get; private set; }
public void ChooseBodyColor(Color bodyColor)
public void SetBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}

View File

@ -163,21 +163,21 @@
// checkBoxRockets
//
checkBoxRockets.AutoSize = true;
checkBoxRockets.Location = new Point(12, 154);
checkBoxRockets.Location = new Point(6, 154);
checkBoxRockets.Name = "checkBoxRockets";
checkBoxRockets.Size = new Size(318, 24);
checkBoxRockets.Size = new Size(339, 24);
checkBoxRockets.TabIndex = 7;
checkBoxRockets.Text = "Признак наличия дополнительных ракет";
checkBoxRockets.Text = "Признак наличия дополнительных крыльев";
checkBoxRockets.UseVisualStyleBackColor = true;
//
// checkBoxWings
//
checkBoxWings.AutoSize = true;
checkBoxWings.Location = new Point(12, 124);
checkBoxWings.Location = new Point(6, 124);
checkBoxWings.Name = "checkBoxWings";
checkBoxWings.Size = new Size(339, 24);
checkBoxWings.Size = new Size(318, 24);
checkBoxWings.TabIndex = 6;
checkBoxWings.Text = "Признак наличия дополнительных крыльев";
checkBoxWings.Text = "Признак наличия дополнительных ракет";
checkBoxWings.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
@ -282,27 +282,29 @@
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(100, 12);
labelAdditionalColor.Location = new Point(100, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(88, 24);
labelAdditionalColor.Size = new Size(88, 36);
labelAdditionalColor.TabIndex = 2;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelColor_DragDrop;
labelAdditionalColor.DragEnter += LabelColor_DragEnter;
labelAdditionalColor.DragDrop += LabelColors_DragDrop;
labelAdditionalColor.DragEnter += LabelColors_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(3, 12);
labelBodyColor.Location = new Point(3, 9);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(88, 24);
labelBodyColor.Size = new Size(88, 36);
labelBodyColor.TabIndex = 1;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += LabelColor_DragDrop;
labelBodyColor.DragEnter += LabelColor_DragEnter;
labelBodyColor.DragDrop += LabelColors_DragDrop;
labelBodyColor.DragEnter += LabelColors_DragEnter;
//
// FormMilitaryAircraftConfig
//

View File

@ -40,16 +40,9 @@ public partial class FormMilitaryAircraftConfig : Form
/// </summary>
/// <param name="militaryAircraftDelegate"></param>
public void AddEvent(Action<DrawningMilitaryAircraft> militaryAircraftDelegate)
{
if (MilitaryAircraftDelegate == null)
{
MilitaryAircraftDelegate = militaryAircraftDelegate;
}
else
{
MilitaryAircraftDelegate += militaryAircraftDelegate;
}
}
/// <summary>
/// Прорисовка объекта
@ -71,8 +64,6 @@ public partial class FormMilitaryAircraftConfig : Form
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
//var label = sender as Label;
//label.DoDragDrop(label.Name, DragDropEffects.Move);
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
}
@ -83,14 +74,7 @@ public partial class FormMilitaryAircraftConfig : Form
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
/// <summary>
@ -118,7 +102,7 @@ public partial class FormMilitaryAircraftConfig : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>2
private void Panel_MouseDown(object? sender, MouseEventArgs e)
private void Panel_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
@ -132,17 +116,8 @@ public partial class FormMilitaryAircraftConfig : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColor_DragEnter(object sender, DragEventArgs e)
private void LabelColors_DragEnter(object sender, DragEventArgs e)
{
//if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
//{
// e.Effect = DragDropEffects.Copy;
//}
//else
//{
// e.Effect = DragDropEffects.None;
//}
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
@ -151,27 +126,28 @@ public partial class FormMilitaryAircraftConfig : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColor_DragDrop(object sender, DragEventArgs e)
private void LabelColors_DragDrop(object sender, DragEventArgs e)
{
if (_militaryAircraft == null)
{
return;
}
Label label = (Label)sender;
switch (((Label)sender).Name)
Color newColor = (Color)e.Data.GetData(typeof(Color).ToString());
switch (label.Name)
{
case "labelBodyColor":
_militaryAircraft.EntityMilitaryAircraft.ChooseBodyColor((Color)e.Data.GetData(typeof(Color)));
_militaryAircraft.EntityMilitaryAircraft.SetBodyColor(newColor);
DrawObject();
break;
case "labelAdditionalColor":
if (_militaryAircraft is DrawningAirFighter)
{
return;
(_militaryAircraft.EntityMilitaryAircraft as EntityAirFighter).SetAdditionalColor(newColor);
DrawObject();
}
(_militaryAircraft.EntityMilitaryAircraft as EntityAirFighter).ChooseAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawObject();
}