2024-02-28 23:06:50 +04:00
|
|
|
|
using ProjectElectroTrans.MovementStrategy;
|
2024-03-13 19:49:07 +04:00
|
|
|
|
using ProjectElectroTrans.Drawnings;
|
2024-02-28 23:06:50 +04:00
|
|
|
|
|
|
|
|
|
namespace ProjectElectroTrans;
|
|
|
|
|
|
2024-03-13 19:49:07 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
/// </summary>
|
2024-02-28 23:06:50 +04:00
|
|
|
|
public partial class FormElectroTrans : Form
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
2024-03-13 19:49:07 +04:00
|
|
|
|
private DrawingTrans? _drawningTrans;
|
2024-02-28 23:06:50 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private AbstractStrategy? _strategy;
|
|
|
|
|
|
2024-03-13 19:49:07 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DrawingTrans SetCar
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_drawningTrans = value;
|
|
|
|
|
_drawningTrans.SetPictureSize(pictureBoxElectroTrans.Width, pictureBoxElectroTrans.Height);
|
|
|
|
|
comboBoxStrategy.Enabled = true;
|
|
|
|
|
_strategy = null;
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
2024-02-28 23:06:50 +04:00
|
|
|
|
public FormElectroTrans()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_strategy = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Draw()
|
|
|
|
|
{
|
2024-03-13 19:49:07 +04:00
|
|
|
|
if (_drawningTrans == null)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bitmap bmp = new(pictureBoxElectroTrans.Width, pictureBoxElectroTrans.Height);
|
|
|
|
|
Graphics gr = Graphics.FromImage(bmp);
|
2024-03-13 19:49:07 +04:00
|
|
|
|
_drawningTrans.DrawTransport(gr);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
pictureBoxElectroTrans.Image = bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-03-13 19:49:07 +04:00
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-03-13 19:49:07 +04:00
|
|
|
|
private void ButtonMove_Click(object sender, EventArgs e)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
{
|
2024-03-13 19:49:07 +04:00
|
|
|
|
if (_drawningTrans == null)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
bool result = false;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
2024-03-13 19:49:07 +04:00
|
|
|
|
result = _drawningTrans.MoveTransport(DirectionType.Up);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
2024-03-13 19:49:07 +04:00
|
|
|
|
result = _drawningTrans.MoveTransport(DirectionType.Down);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
2024-03-13 19:49:07 +04:00
|
|
|
|
result = _drawningTrans.MoveTransport(DirectionType.Left);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
2024-03-13 19:49:07 +04:00
|
|
|
|
result = _drawningTrans.MoveTransport(DirectionType.Right);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-13 19:49:07 +04:00
|
|
|
|
|
2024-02-28 23:06:50 +04:00
|
|
|
|
/// <summary>
|
2024-03-13 19:49:07 +04:00
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD>"
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
{
|
2024-03-13 19:49:07 +04:00
|
|
|
|
if (_drawningTrans == null)
|
2024-02-28 23:06:50 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (comboBoxStrategy.Enabled)
|
|
|
|
|
{
|
|
|
|
|
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
|
|
|
{
|
|
|
|
|
0 => new MoveToCenter(),
|
|
|
|
|
1 => new MoveToBorder(),
|
|
|
|
|
_ => null,
|
|
|
|
|
};
|
|
|
|
|
if (_strategy == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-13 19:49:07 +04:00
|
|
|
|
_strategy.SetData(new MoveableTrans(_drawningTrans), pictureBoxElectroTrans.Width, pictureBoxElectroTrans.Height);
|
2024-02-28 23:06:50 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_strategy == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
comboBoxStrategy.Enabled = false;
|
|
|
|
|
_strategy.MakeStep();
|
|
|
|
|
Draw();
|
|
|
|
|
|
|
|
|
|
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
|
|
|
|
{
|
|
|
|
|
comboBoxStrategy.Enabled = true;
|
|
|
|
|
_strategy = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-13 19:49:07 +04:00
|
|
|
|
}
|