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,15 +50,18 @@ 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)
|
|
||||||
{
|
|
||||||
DrawingObjectWarship warship = new(form.SelectedWarship);
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
@ -69,7 +72,6 @@ namespace Warship
|
|||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user