Небольшие исправления опечаток.

This commit is contained in:
Андрей Байгулов 2023-10-15 23:07:02 +04:00
parent f7feca445e
commit 144100d479
2 changed files with 24 additions and 24 deletions

View File

@ -10,26 +10,26 @@ namespace ProjectElectricLocomotive.MovementStrategy
{ {
public class DrawingObjectLocomotive : IMoveableObject public class DrawingObjectLocomotive : IMoveableObject
{ {
private readonly DrawingLocomotive? _drawningLocomotive = null; private readonly DrawingLocomotive? _drawingLocomotive = null;
public DrawingObjectLocomotive(DrawingLocomotive drawningLocomotive) public DrawingObjectLocomotive(DrawingLocomotive drawingLocomotive)
{ {
_drawningLocomotive = drawningLocomotive; _drawingLocomotive = drawingLocomotive;
} }
public ObjectParameters? GetObjectPosition public ObjectParameters? GetObjectPosition
{ {
get get
{ {
if (_drawningLocomotive == null || _drawningLocomotive.EntityLocomotive == null) if (_drawingLocomotive == null || _drawingLocomotive.EntityLocomotive == null)
{ {
return null; return null;
} }
return new ObjectParameters(_drawningLocomotive.GetPosX, return new ObjectParameters(_drawingLocomotive.GetPosX,
_drawningLocomotive.GetPosY, _drawningLocomotive.GetWidth, _drawningLocomotive.GetHeight); _drawingLocomotive.GetPosY, _drawingLocomotive.GetWidth, _drawingLocomotive.GetHeight);
} }
} }
public int GetStep => (int)(_drawningLocomotive?.EntityLocomotive?.Step ?? 0); public int GetStep => (int)(_drawingLocomotive?.EntityLocomotive?.Step ?? 0);
public bool CheckCanMove(Direction direction) => _drawningLocomotive?.CanMove(direction) ?? false; public bool CheckCanMove(Direction direction) => _drawingLocomotive?.CanMove(direction) ?? false;
public void MoveObject(Direction direction) => _drawningLocomotive?.MoveTransport(direction); public void MoveObject(Direction direction) => _drawingLocomotive?.MoveTransport(direction);
} }
} }

View File

@ -8,7 +8,7 @@ namespace ElectricLocomotive
{ {
public partial class FormElectricLocomotive : Form public partial class FormElectricLocomotive : Form
{ {
private DrawingLocomotive? _drawningLocomotive; private DrawingLocomotive? _drawingLocomotive;
private AbstractStrategy? _abstractStrategy; private AbstractStrategy? _abstractStrategy;
public DrawingLocomotive? SelectedLocomotive { get; private set; } public DrawingLocomotive? SelectedLocomotive { get; private set; }
public FormElectricLocomotive() public FormElectricLocomotive()
@ -19,13 +19,13 @@ namespace ElectricLocomotive
} }
private void Draw() private void Draw()
{ {
if (_drawningLocomotive == null) if (_drawingLocomotive == null)
{ {
return; return;
} }
Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp); Graphics gr = Graphics.FromImage(bmp);
_drawningLocomotive.DrawTransport(gr); _drawingLocomotive.DrawTransport(gr);
pictureBoxElectricLocomotive.Image = bmp; pictureBoxElectricLocomotive.Image = bmp;
} }
private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e) private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e)
@ -42,10 +42,10 @@ namespace ElectricLocomotive
{ {
dopColor = colorDialog.Color; dopColor = colorDialog.Color;
} }
_drawningLocomotive = new DrawingElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, _drawingLocomotive = new DrawingElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();
} }
private void buttonCreateLocomotive_Click(object sender, EventArgs e) private void buttonCreateLocomotive_Click(object sender, EventArgs e)
@ -58,17 +58,17 @@ namespace ElectricLocomotive
{ {
color = dialog.Color; color = dialog.Color;
} }
_drawningLocomotive = new DrawingLocomotive(random.Next(100, 300), _drawingLocomotive = new DrawingLocomotive(random.Next(100, 300),
random.Next(1000, 3000), color, random.Next(1000, 3000), color,
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, _drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10,
100)); 100));
Draw(); Draw();
} }
private void buttonMove_Click(object sender, EventArgs e) private void buttonMove_Click(object sender, EventArgs e)
{ {
if (_drawningLocomotive == null) if (_drawingLocomotive == null)
{ {
return; return;
} }
@ -76,23 +76,23 @@ namespace ElectricLocomotive
switch (name) switch (name)
{ {
case "buttonUp": case "buttonUp":
_drawningLocomotive.MoveTransport(Direction.Up); _drawingLocomotive.MoveTransport(Direction.Up);
break; break;
case "buttonDown": case "buttonDown":
_drawningLocomotive.MoveTransport(Direction.Down); _drawingLocomotive.MoveTransport(Direction.Down);
break; break;
case "buttonLeft": case "buttonLeft":
_drawningLocomotive.MoveTransport(Direction.Left); _drawingLocomotive.MoveTransport(Direction.Left);
break; break;
case "buttonRight": case "buttonRight":
_drawningLocomotive.MoveTransport(Direction.Right); _drawingLocomotive.MoveTransport(Direction.Right);
break; break;
} }
Draw(); Draw();
} }
private void buttonStrategyStep_Click(object sender, EventArgs e) private void buttonStrategyStep_Click(object sender, EventArgs e)
{ {
if (_drawningLocomotive == null) if (_drawingLocomotive == null)
{ {
return; return;
} }
@ -108,7 +108,7 @@ namespace ElectricLocomotive
{ {
return; return;
} }
_abstractStrategy.SetData(new DrawingObjectLocomotive(_drawningLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); _abstractStrategy.SetData(new DrawingObjectLocomotive(_drawingLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
comboBoxStrategy.Enabled = false; comboBoxStrategy.Enabled = false;
} }
if (_abstractStrategy == null) if (_abstractStrategy == null)
@ -137,7 +137,7 @@ namespace ElectricLocomotive
} }
private void ButtonSelectLocomotive_Click(object sender, EventArgs e) private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
{ {
SelectedLocomotive = _drawningLocomotive; SelectedLocomotive = _drawingLocomotive;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} }
} }