Event work
This commit is contained in:
parent
7002fa292a
commit
6c56275f1e
@ -67,5 +67,10 @@ namespace Warship
|
|||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 30 - 5, _startPosX + 20, _startPosY + 30 - 5);
|
g.DrawLine(pen, _startPosX + 10, _startPosY + 30 - 5, _startPosX + 20, _startPosY + 30 - 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetModifColor(Color modifColor)
|
||||||
|
{
|
||||||
|
((EntityAdvancedWarship)Warship).DopColor = modifColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,11 @@ namespace Warship
|
|||||||
_warshipHeight = warshipHeight;
|
_warshipHeight = warshipHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetColor(Color color)
|
||||||
|
{
|
||||||
|
Warship.BodyColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace Warship
|
|||||||
{
|
{
|
||||||
internal class EntityAdvancedWarship : EntityWarship
|
internal class EntityAdvancedWarship : EntityWarship
|
||||||
{
|
{
|
||||||
public Color DopColor { get; private set; }
|
public Color DopColor { get; set; }
|
||||||
public bool Helipad { get; private set; }
|
public bool Helipad { get; private set; }
|
||||||
public bool Antenna { get; private set; }
|
public bool Antenna { get; private set; }
|
||||||
public bool Missile { get; private set; }
|
public bool Missile { get; private set; }
|
||||||
|
@ -10,7 +10,7 @@ namespace Warship
|
|||||||
{
|
{
|
||||||
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 int Step => (int)(Speed * 2000 / Weight);
|
public int Step => (int)(Speed * 2000 / Weight);
|
||||||
|
|
||||||
public EntityWarship(int speed, float weight, Color bodyColor)
|
public EntityWarship(int speed, float weight, Color bodyColor)
|
||||||
|
@ -50,24 +50,26 @@ namespace Warship
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var formWarshipConfig = new FormWarshipConfig();
|
||||||
|
formWarshipConfig.AddEvent(AddWarshipOnMap);
|
||||||
|
formWarshipConfig.Show();
|
||||||
|
}
|
||||||
|
private void AddWarshipOnMap(DrawingWarship drawingWarship)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FormWarship form = new();
|
DrawingObjectWarship warship = new(drawingWarship);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
|
||||||
{
|
{
|
||||||
DrawingObjectWarship warship = new(form.SelectedWarship);
|
MessageBox.Show("Объект добавлен");
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
{
|
}
|
||||||
MessageBox.Show("Объект добавлен");
|
else
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
{
|
||||||
}
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user