Compare commits

..

No commits in common. "58872d7938e4bc75edec8d5b13f6ae054caff7e4" and "e9ec3ff774ff491c4368740251f5eda1afe4ee55" have entirely different histories.

View File

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