Небольшие исправления опечаток.
This commit is contained in:
parent
f7feca445e
commit
144100d479
@ -10,26 +10,26 @@ namespace ProjectElectricLocomotive.MovementStrategy
|
||||
{
|
||||
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
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningLocomotive == null || _drawningLocomotive.EntityLocomotive == null)
|
||||
if (_drawingLocomotive == null || _drawingLocomotive.EntityLocomotive == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningLocomotive.GetPosX,
|
||||
_drawningLocomotive.GetPosY, _drawningLocomotive.GetWidth, _drawningLocomotive.GetHeight);
|
||||
return new ObjectParameters(_drawingLocomotive.GetPosX,
|
||||
_drawingLocomotive.GetPosY, _drawingLocomotive.GetWidth, _drawingLocomotive.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningLocomotive?.EntityLocomotive?.Step ?? 0);
|
||||
public bool CheckCanMove(Direction direction) => _drawningLocomotive?.CanMove(direction) ?? false;
|
||||
public void MoveObject(Direction direction) => _drawningLocomotive?.MoveTransport(direction);
|
||||
public int GetStep => (int)(_drawingLocomotive?.EntityLocomotive?.Step ?? 0);
|
||||
public bool CheckCanMove(Direction direction) => _drawingLocomotive?.CanMove(direction) ?? false;
|
||||
public void MoveObject(Direction direction) => _drawingLocomotive?.MoveTransport(direction);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace ElectricLocomotive
|
||||
{
|
||||
public partial class FormElectricLocomotive : Form
|
||||
{
|
||||
private DrawingLocomotive? _drawningLocomotive;
|
||||
private DrawingLocomotive? _drawingLocomotive;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawingLocomotive? SelectedLocomotive { get; private set; }
|
||||
public FormElectricLocomotive()
|
||||
@ -19,13 +19,13 @@ namespace ElectricLocomotive
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
if (_drawingLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningLocomotive.DrawTransport(gr);
|
||||
_drawingLocomotive.DrawTransport(gr);
|
||||
pictureBoxElectricLocomotive.Image = bmp;
|
||||
}
|
||||
private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e)
|
||||
@ -42,10 +42,10 @@ namespace ElectricLocomotive
|
||||
{
|
||||
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)),
|
||||
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();
|
||||
}
|
||||
private void buttonCreateLocomotive_Click(object sender, EventArgs e)
|
||||
@ -58,17 +58,17 @@ namespace ElectricLocomotive
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_drawningLocomotive = new DrawingLocomotive(random.Next(100, 300),
|
||||
_drawingLocomotive = new DrawingLocomotive(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color,
|
||||
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
|
||||
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10,
|
||||
_drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10,
|
||||
100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
if (_drawingLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -76,23 +76,23 @@ namespace ElectricLocomotive
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningLocomotive.MoveTransport(Direction.Up);
|
||||
_drawingLocomotive.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningLocomotive.MoveTransport(Direction.Down);
|
||||
_drawingLocomotive.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningLocomotive.MoveTransport(Direction.Left);
|
||||
_drawingLocomotive.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningLocomotive.MoveTransport(Direction.Right);
|
||||
_drawingLocomotive.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
if (_drawingLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace ElectricLocomotive
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new DrawingObjectLocomotive(_drawningLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
|
||||
_abstractStrategy.SetData(new DrawingObjectLocomotive(_drawingLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
@ -137,7 +137,7 @@ namespace ElectricLocomotive
|
||||
}
|
||||
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedLocomotive = _drawningLocomotive;
|
||||
SelectedLocomotive = _drawingLocomotive;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user