Novopolcev A.A. LabWork05 #5

Closed
A.Novopoltsev wants to merge 2 commits from LabWork05 into LabWork04
5 changed files with 26 additions and 14 deletions
Showing only changes of commit 6c56275f1e - Show all commits

View File

@ -67,5 +67,10 @@ namespace Warship
g.DrawLine(pen, _startPosX + 10, _startPosY + 30 - 5, _startPosX + 20, _startPosY + 30 - 5);
}
}
public void SetModifColor(Color modifColor)
{
((EntityAdvancedWarship)Warship).DopColor = modifColor;
}
}
}

View File

@ -27,6 +27,11 @@ namespace Warship
_warshipHeight = warshipHeight;
}
public void SetColor(Color color)
{
Warship.BodyColor = color;
}
public void SetPosition(int x, int y, int width, int height)
{

View File

@ -8,7 +8,7 @@ namespace Warship
{
internal class EntityAdvancedWarship : EntityWarship
{
public Color DopColor { get; private set; }
public Color DopColor { get; set; }
public bool Helipad { get; private set; }
public bool Antenna { get; private set; }
public bool Missile { get; private set; }

View File

@ -10,7 +10,7 @@ namespace Warship
{
public int Speed { 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 EntityWarship(int speed, float weight, Color bodyColor)

View File

@ -50,24 +50,26 @@ namespace Warship
}
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)
{
return;
}
FormWarship form = new();
if (form.ShowDialog() == DialogResult.OK)
DrawingObjectWarship warship = new(drawingWarship);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
{
DrawingObjectWarship warship = new(form.SelectedWarship);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}