Compare commits

..

3 Commits

Author SHA1 Message Date
58872d7938 fix 2023-10-15 23:01:17 +04:00
6e4ffe95d8 Fix 2023-10-15 22:58:40 +04:00
d5b447bf0f Fixed 2023-10-15 20:34:13 +04:00

View File

@ -6,7 +6,7 @@ namespace AntiAircraftGun
{
public partial class FormAntiAirCraftGun : Form
{
private BaseDrawingAntiAirCraftGun _drawing;
private BaseDrawingAntiAirCraftGun _drawingAntiAirCraftGun;
private AbstractStrategy? _abstractStrategy;
@ -20,7 +20,7 @@ namespace AntiAircraftGun
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawing == null)
if (_drawingAntiAirCraftGun == null)
{
return;
}
@ -28,29 +28,29 @@ namespace AntiAircraftGun
switch (name)
{
case "buttonUp":
_drawing.MoveTransport(DirectionType.Up);
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawing.MoveTransport(DirectionType.Down);
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawing.MoveTransport(DirectionType.Left);
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawing.MoveTransport(DirectionType.Right);
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
private void Draw()
{
if (_drawing == null)
if (_drawingAntiAirCraftGun == null)
{
return;
}
Bitmap bmp = new Bitmap(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawing.DrawTransport(gr);
_drawingAntiAirCraftGun.DrawTransport(gr);
pictureBoxAntiAircraftGun.Image = bmp;
}
@ -75,7 +75,7 @@ namespace AntiAircraftGun
pictureBoxAntiAircraftGun.Height
);
_drawing.SetPosition(random.Next(10, 100), random.Next(10, 100));
_drawingAntiAirCraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
@ -97,13 +97,13 @@ namespace AntiAircraftGun
pictureBoxAntiAircraftGun.Height
);
_drawing.SetPosition(random.Next(10, 100), random.Next(10, 100));
_drawingAntiAirCraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void ButtonStep_Click(object sender, EventArgs e)
{
if (_drawing == null)
if (_drawingAntiAirCraftGun == null)
{
return;
}
@ -121,7 +121,7 @@ namespace AntiAircraftGun
return;
}
_abstractStrategy.SetData(new
DrawingObjectAntiAirCraftGun(_drawing), pictureBoxAntiAircraftGun.Width,
DrawingObjectAntiAirCraftGun(_drawingAntiAirCraftGun), pictureBoxAntiAircraftGun.Width,
pictureBoxAntiAircraftGun.Height);
comboBoxStrategy.Enabled = false;
}