Fix
This commit is contained in:
parent
ab9fdf006d
commit
2bdfda9ce9
@ -26,6 +26,10 @@ namespace AirPlaneWithRadar
|
|||||||
this.plainWidth = plainWidth;
|
this.plainWidth = plainWidth;
|
||||||
this.plainHeight = plainHeight;
|
this.plainHeight = plainHeight;
|
||||||
}
|
}
|
||||||
|
public void ReColor(Color col)
|
||||||
|
{
|
||||||
|
Plain.BodyColor = col;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y, int width, int height)
|
public void setPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,11 @@ namespace AirPlaneWithRadar
|
|||||||
{
|
{
|
||||||
Plain = new RadioPlane(speed, weight, bodyColor, dopColor, radar, oilBox);
|
Plain = new RadioPlane(speed, weight, bodyColor, dopColor, radar, oilBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReColorDop(Color dopCol)
|
||||||
|
{
|
||||||
|
(Plain as RadioPlane).DopColor = dopCol;
|
||||||
|
}
|
||||||
public override void DrawTransoprt(Graphics g)
|
public override void DrawTransoprt(Graphics g)
|
||||||
{
|
{
|
||||||
if (Plain is not RadioPlane radioPlane)
|
if (Plain is not RadioPlane radioPlane)
|
||||||
|
@ -11,7 +11,7 @@ namespace AirPlaneWithRadar
|
|||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; set; }
|
||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
public EntetyPlain(int speed, float weight, Color bodyColor)
|
public EntetyPlain(int speed, float weight, Color bodyColor)
|
||||||
@ -22,6 +22,5 @@ namespace AirPlaneWithRadar
|
|||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,26 @@ namespace AirPlaneWithRadar
|
|||||||
{
|
{
|
||||||
|
|
||||||
var formPlainConfig = new FormPlaneConfig();
|
var formPlainConfig = new FormPlaneConfig();
|
||||||
|
formPlainConfig.AddEvent(ReactEv);
|
||||||
formPlainConfig.Show();
|
formPlainConfig.Show();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ReactEv(DrawingPlain dp)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectPlane(dp)) >= 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ButtonRemovePlain_Click(object sender, EventArgs e)
|
private void ButtonRemovePlain_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace AirPlaneWithRadar
|
|||||||
{
|
{
|
||||||
DrawingPlain _Plane = null;
|
DrawingPlain _Plane = null;
|
||||||
|
|
||||||
private event PlainDelegate EventAddPlane;
|
private event Action<DrawingPlain> EventAddPlane;
|
||||||
|
|
||||||
public FormPlaneConfig()
|
public FormPlaneConfig()
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ namespace AirPlaneWithRadar
|
|||||||
pictureBoxObject.Image = bmp;
|
pictureBoxObject.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddEvent(PlainDelegate ev)
|
public void AddEvent(Action<DrawingPlain> ev)
|
||||||
{
|
{
|
||||||
if (EventAddPlane == null)
|
if (EventAddPlane == null)
|
||||||
{
|
{
|
||||||
@ -120,12 +120,24 @@ namespace AirPlaneWithRadar
|
|||||||
|
|
||||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_Plane is null) return;
|
||||||
|
var col = e.Data.GetData(typeof(Color));
|
||||||
|
Color newCol = (Color)col;
|
||||||
|
labelBaseColor.BackColor = newCol;
|
||||||
|
_Plane?.ReColor(newCol);
|
||||||
|
DrawPlane();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_Plane is DrawingRadarPlane)
|
||||||
|
{
|
||||||
|
var col = e.Data.GetData(typeof(Color));
|
||||||
|
Color newCol = (Color)col;
|
||||||
|
labelDopColor.BackColor = newCol;
|
||||||
|
(_Plane as DrawingRadarPlane).ReColorDop(newCol);
|
||||||
|
DrawPlane();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user