Compare commits
No commits in common. "ISBd_21.GordeevI.V._LabWork_03" and "main" have entirely different histories.
ISBd_21.Go
...
main
@ -1,87 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ElectricLocomotive;
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
|
||||
namespace ProjectElectricLocomotive.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Абстрактный класс стратегии
|
||||
/// </summary>
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMoveableObject? _moveableObject;
|
||||
|
||||
private Status _state = Status.NotInit;
|
||||
protected int FieldWidth { get; private set; }
|
||||
protected int FieldHeight { get; private set; }
|
||||
public Status GetStatus() { return _state; }
|
||||
|
||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
_state = Status.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
|
||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||
|
||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||
|
||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||
|
||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||
|
||||
/// Параметры объекта
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
protected abstract void MoveToTarget();
|
||||
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
using ElectricLocomotive.DrawningObject;
|
||||
using ElectricLocomotive.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public class DrawningElectricLocomotive : DrawningLocomotive
|
||||
{
|
||||
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool Horns, int width, int height)
|
||||
: base (speed, weight, bodyColor, width , height)
|
||||
{
|
||||
if (EntityLocomotive != null)
|
||||
{
|
||||
EntityLocomotive = new EntityElectroLocomotive(speed, weight, bodyColor,
|
||||
additionalColor, Horns);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityLocomotive is not EntityElectroLocomotive electroLocomotive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(electroLocomotive.BodyColor) ;
|
||||
Brush brush = new SolidBrush(electroLocomotive.AdditionalColor);
|
||||
// обвесы
|
||||
if (electroLocomotive.Horns)
|
||||
{
|
||||
g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
|
||||
|
||||
Point[] horns =
|
||||
{
|
||||
new Point(_startPosX+25, _startPosY+10),
|
||||
new Point(_startPosX+25, _startPosY+5),
|
||||
new Point(_startPosX+33,_startPosY+5),
|
||||
new Point(_startPosX+50, _startPosY),
|
||||
new Point(_startPosX+33,_startPosY+5),
|
||||
new Point(_startPosX+40,_startPosY+5),
|
||||
new Point(_startPosX+40,_startPosY+10)
|
||||
};
|
||||
g.DrawPolygon(pen, horns);
|
||||
|
||||
g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
|
||||
Point[] horns2 =
|
||||
{
|
||||
new Point(_startPosX+65, _startPosY+10),
|
||||
new Point(_startPosX+65, _startPosY+5),
|
||||
new Point(_startPosX+73,_startPosY+5),
|
||||
new Point(_startPosX+90, _startPosY),
|
||||
new Point(_startPosX+73,_startPosY+5),
|
||||
new Point(_startPosX+80,_startPosY+5),
|
||||
new Point(_startPosX+80,_startPosY+10)
|
||||
};
|
||||
g.DrawPolygon(pen, horns2);
|
||||
}
|
||||
base.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,213 +0,0 @@
|
||||
using ElectricLocomotive.Entities;
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.DrawningObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningLocomotive
|
||||
{
|
||||
public EntityLocomotive? EntityLocomotive { get; protected set; }
|
||||
|
||||
protected int _pictureWidth;
|
||||
|
||||
protected int _pictureHeight;
|
||||
|
||||
protected int _startPosX;
|
||||
|
||||
protected int _startPosY;
|
||||
|
||||
protected readonly int _locoWidth = 95;
|
||||
|
||||
protected readonly int _locoHeight = 50;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _locoWidth;
|
||||
public int GetHeight => _locoHeight;
|
||||
|
||||
public DrawningLocomotive(int speed, double weight, Color bodyColor, int width, int heigth)
|
||||
{
|
||||
if (width < _locoWidth || heigth < _locoHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = heigth;
|
||||
EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
protected DrawningLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, int width,
|
||||
int height, int locoWidth, int locoHeight)
|
||||
{
|
||||
if (width < _locoWidth || height < _locoHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_locoWidth = locoWidth;
|
||||
_locoHeight = locoHeight;
|
||||
EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _locoWidth > _pictureWidth)
|
||||
{
|
||||
x = _pictureWidth - _locoWidth;
|
||||
}
|
||||
if (y < 0 || y + _locoHeight > _pictureHeight)
|
||||
{
|
||||
y = _pictureHeight - _locoHeight;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityLocomotive.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityLocomotive.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + EntityLocomotive.Step + _locoWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + EntityLocomotive.Step + _locoHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityLocomotive.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush brush = new SolidBrush(EntityLocomotive.BodyColor);
|
||||
///ВЛ60к-1595
|
||||
|
||||
///ходовая
|
||||
g.FillRectangle(brush, new Rectangle(_startPosX + 20, _startPosY + 45, 15, 5));
|
||||
g.FillRectangle(brush, new Rectangle(_startPosX + 65, _startPosY + 45, 15, 5));
|
||||
|
||||
g.FillEllipse(brush, _startPosX + 15, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(brush, _startPosX + 30, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(brush, _startPosX + 60, _startPosY + 45, 10, 10);
|
||||
g.FillEllipse(brush, _startPosX + 75, _startPosY + 45, 10, 10);
|
||||
PointF[] chassis =
|
||||
{
|
||||
new Point(_startPosX+10, _startPosY+50),
|
||||
new Point(_startPosX, _startPosY+50),
|
||||
new Point(_startPosX+10, _startPosY +40),
|
||||
new Point(_startPosX + 90, _startPosY+40),
|
||||
new Point(_startPosX+100, _startPosY+50),
|
||||
new Point(_startPosX+90,_startPosY+ 50),
|
||||
new Point(_startPosX+85, _startPosY+45),
|
||||
new Point(_startPosX+15, _startPosY+45),
|
||||
};
|
||||
g.FillPolygon(brush, chassis);
|
||||
|
||||
///обводка ходовой
|
||||
Point[] chassisCont =
|
||||
{
|
||||
new Point(_startPosX+10, _startPosY+50),
|
||||
new Point(_startPosX, _startPosY+50),
|
||||
new Point(_startPosX+10, _startPosY +40),
|
||||
new Point(_startPosX + 90, _startPosY+40),
|
||||
new Point(_startPosX+100, _startPosY+50),
|
||||
new Point(_startPosX+90,_startPosY+ 50),
|
||||
new Point(_startPosX+85, _startPosY+45),
|
||||
new Point(_startPosX+15, _startPosY+45),
|
||||
};
|
||||
g.DrawPolygon(pen, chassisCont);
|
||||
|
||||
///кабина
|
||||
Point[] cabin =
|
||||
{
|
||||
new Point(_startPosX+20, _startPosY+10),
|
||||
new Point(_startPosX+90,_startPosY+10),
|
||||
new Point(_startPosX+90,_startPosY + 40),
|
||||
new Point(_startPosX+10,_startPosY+40),
|
||||
new Point(_startPosX+10,_startPosY+25)
|
||||
};
|
||||
g.DrawPolygon(pen, cabin);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 25, _startPosX + 90, _startPosY + 25);
|
||||
|
||||
///окна
|
||||
g.FillRectangle(brush, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
g.FillRectangle(brush, _startPosX + 35, _startPosY + 15, 10, 10);
|
||||
|
||||
g.FillRectangle(brush, _startPosX + 75, _startPosY + 15, 10, 10);
|
||||
|
||||
///дверь
|
||||
g.FillRectangle(brush, _startPosX + 50, _startPosY + 15, 10, 25);
|
||||
|
||||
///Батарея
|
||||
g.FillRectangle(brush, _startPosX + 45, _startPosY + 5, 15, 5);
|
||||
|
||||
}
|
||||
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityLocomotive == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
//влево
|
||||
DirectionType.Left => _startPosX - EntityLocomotive.Step > 0,
|
||||
//вверх
|
||||
DirectionType.Up => _startPosY - EntityLocomotive.Step > 0,
|
||||
// вправо
|
||||
DirectionType.Right => _startPosX + EntityLocomotive.Step < _pictureWidth,
|
||||
//вниз
|
||||
DirectionType.Down => _startPosY + EntityLocomotive.Step < _pictureHeight,
|
||||
};
|
||||
}
|
||||
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectLocomotive(this);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using ElectricLocomotive.DrawningObject;
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public class DrawningObjectLocomotive : IMoveableObject
|
||||
{
|
||||
private readonly DrawningLocomotive? _drawningLocomotive = null;
|
||||
public DrawningObjectLocomotive(DrawningLocomotive drawningLocomotive)
|
||||
{
|
||||
_drawningLocomotive = drawningLocomotive;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningLocomotive == null || _drawningLocomotive.EntityLocomotive == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningLocomotive.GetPosX,_drawningLocomotive.GetPosY, _drawningLocomotive.GetWidth, _drawningLocomotive.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningLocomotive?.EntityLocomotive?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>_drawningLocomotive?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>_drawningLocomotive?.MoveTransport(direction);
|
||||
}
|
||||
}
|
||||
|
@ -1,196 +0,0 @@
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
partial class ElectricLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ElectricLocomotive));
|
||||
pictureBoxElectroLocomotiv = new PictureBox();
|
||||
buttonUp = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonCreateElectricLocomotive = new Button();
|
||||
buttonCreateLocomotive = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStep = new Button();
|
||||
buttonChoiceLocomotive = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxElectroLocomotiv).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxElectroLocomotiv
|
||||
//
|
||||
pictureBoxElectroLocomotiv.AccessibleRole = AccessibleRole.Client;
|
||||
pictureBoxElectroLocomotiv.Dock = DockStyle.Fill;
|
||||
pictureBoxElectroLocomotiv.Location = new Point(0, 0);
|
||||
pictureBoxElectroLocomotiv.Name = "pictureBoxElectroLocomotiv";
|
||||
pictureBoxElectroLocomotiv.Size = new Size(854, 467);
|
||||
pictureBoxElectroLocomotiv.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxElectroLocomotiv.TabIndex = 5;
|
||||
pictureBoxElectroLocomotiv.TabStop = false;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(777, 389);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 10;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(813, 425);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 9;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(777, 425);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 8;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(741, 425);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 7;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreateElectricLocomotive
|
||||
//
|
||||
buttonCreateElectricLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateElectricLocomotive.Location = new Point(13, 425);
|
||||
buttonCreateElectricLocomotive.Name = "buttonCreateElectricLocomotive";
|
||||
buttonCreateElectricLocomotive.Size = new Size(208, 34);
|
||||
buttonCreateElectricLocomotive.TabIndex = 6;
|
||||
buttonCreateElectricLocomotive.Text = "Нарисовать Электролокомотив";
|
||||
buttonCreateElectricLocomotive.UseVisualStyleBackColor = true;
|
||||
buttonCreateElectricLocomotive.Click += PaintElectricLocoButton_click;
|
||||
//
|
||||
// buttonCreateLocomotive
|
||||
//
|
||||
buttonCreateLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateLocomotive.Location = new Point(227, 425);
|
||||
buttonCreateLocomotive.Name = "buttonCreateLocomotive";
|
||||
buttonCreateLocomotive.Size = new Size(197, 34);
|
||||
buttonCreateLocomotive.TabIndex = 11;
|
||||
buttonCreateLocomotive.Text = "Нарисовать локомотив";
|
||||
buttonCreateLocomotive.UseVisualStyleBackColor = true;
|
||||
buttonCreateLocomotive.Click += PaintLocoButton_click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToRightCorner" });
|
||||
comboBoxStrategy.Location = new Point(730, 11);
|
||||
comboBoxStrategy.Margin = new Padding(2);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(113, 23);
|
||||
comboBoxStrategy.TabIndex = 12;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonStep.Font = new Font("Candara Light", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonStep.Location = new Point(741, 49);
|
||||
buttonStep.Margin = new Padding(2);
|
||||
buttonStep.Name = "buttonStep";
|
||||
buttonStep.Size = new Size(88, 34);
|
||||
buttonStep.TabIndex = 13;
|
||||
buttonStep.Text = "Шаг";
|
||||
buttonStep.UseVisualStyleBackColor = true;
|
||||
buttonStep.Click += buttonStep_Click;
|
||||
//
|
||||
// buttonChoiceLocomotive
|
||||
//
|
||||
buttonChoiceLocomotive.Location = new Point(430, 425);
|
||||
buttonChoiceLocomotive.Name = "buttonChoiceLocomotive";
|
||||
buttonChoiceLocomotive.Size = new Size(206, 34);
|
||||
buttonChoiceLocomotive.TabIndex = 14;
|
||||
buttonChoiceLocomotive.Text = "Выбрать локомотив";
|
||||
buttonChoiceLocomotive.UseVisualStyleBackColor = true;
|
||||
buttonChoiceLocomotive.Click += ButtonSelectLocomotive_Click;
|
||||
//
|
||||
// ElectricLocomotive
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(854, 467);
|
||||
Controls.Add(buttonChoiceLocomotive);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateLocomotive);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreateElectricLocomotive);
|
||||
Controls.Add(pictureBoxElectroLocomotiv);
|
||||
Name = "ElectricLocomotive";
|
||||
Text = "ElectricLocomotive";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxElectroLocomotiv).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxElectroLocomotiv;
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonCreateElectricLocomotive;
|
||||
private Button buttonCreateLocomotive;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStep;
|
||||
private Button buttonChoiceLocomotive;
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
using ElectricLocomotive.DrawningObject;
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
using ProjectElectricLocomotive;
|
||||
using ProjectElectricLocomotive.MovementStrategy;
|
||||
using System;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public partial class ElectricLocomotive : Form
|
||||
{
|
||||
|
||||
private DrawningLocomotive? _drawningLocomotive;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawningLocomotive? SelectedLocomotive { get; private set; }
|
||||
|
||||
public ElectricLocomotive()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
SelectedLocomotive = null;
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningLocomotive.DrawTransport(gr);
|
||||
pictureBoxElectroLocomotiv.Image = bmp;
|
||||
}
|
||||
|
||||
private void PaintLocoButton_click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
color = dialog.Color;
|
||||
_drawningLocomotive = new DrawningLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
|
||||
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void PaintElectricLocoButton_click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
bool Horns = Convert.ToBoolean(random.Next(0, 2));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
color = dialog.Color;
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
dopColor = dialog.Color;
|
||||
_drawningLocomotive = new DrawningElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Horns, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
|
||||
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningLocomotive.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningLocomotive.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningLocomotive.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningLocomotive.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLocomotive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToRightCorner(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new
|
||||
DrawningObjectLocomotive(_drawningLocomotive), pictureBoxElectroLocomotiv.Width,
|
||||
pictureBoxElectroLocomotiv.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedLocomotive = _drawningLocomotive;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,19 +8,4 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,234 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAX1JREFUaEPt
|
||||
2T0rhXEcxvHjqbwGg+IVyMxIJpOyGEweFpPYZbBQMpmYFEViZGWR1yJi8Ox71bnr390lHbq5f/l/61P6
|
||||
36dzX4fOGZxGLpfL5epaL+Ywix4dRGocd3hvusEYQjSJJxTjC4+YQK2bwjPK4wsvmEYtm8cr3PDUGxZQ
|
||||
q5bhxn5GL2IRtajV8ak1/FltWIcb1oot6Ll+Nd1QN3aDvmMb7fiVOrALN+Qn9tCJStMNDuEGFM7NWeHM
|
||||
nKX03PoFVdZXb9hTdJfOUrp2UjorW0JlXcLdVA7QBeWui9Jj9uGuywUq6xjupnpPpH969xgp0mN34B5z
|
||||
hMoaxAPSG+rTqPwJkl5PpemTbBPp9XsMoNL6sQrdfFQHpnRUyjWCDaygTwd1yI2XMLnxEiY3XsLkxkuY
|
||||
3HgJkxsvYXLjJUxuvITJjZcwufESJjdewuTGS5jceAmTGy9hcv9e1FmYrlF+AVcI0zBuUYzXz0MIlb7U
|
||||
mGkK9wVHLpfL/YsajQ+TA0YtgOqCtwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAEZ5JREFUeF7t
|
||||
3Ymv5WV9x/GZYZhhXwQRcWFRwWIEBbdUFDXVqNSorbiBojVqca1FSqgkWmtJCorFtRqhRLCgRSyRWhQF
|
||||
64KmUrFiVJSoA7KIAgNlBgZmpv08qQmtfIGZ3+/euc855/VK3v/A5Dnzufee37IIAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACASbBZekJ6S/pI+nL6abom
|
||||
3ZxuSdemK9JF6WPpqHRQ2jwBABNiq3RYOje1kf/vgd2azk9/krZLAECHHpE+ntpv9dWgj2l1Oj3tlwCA
|
||||
DuydPpXWpmq857L16Z/T/gkAWADtO/pj0m2pGuv57M50cvLVAABsQo9Nl6dqnDdlV6WDEwAwz16ZVqVq
|
||||
kBei9tXDu9KSBADMsTawH0rVCPfQmWlZAgDmSLuf/9RUDW9P/UvaMgEAI7Xf/D+TqsHtsfZAofYsAgBg
|
||||
hJNSNbQ9d0HaIgEAA7whVQM7CbXnBXicMABspHar35pUjeukdHZq1y8AABug/fn8slSN6qR1WnKLIABs
|
||||
gPemakwntQ8kAOBePCxN+p/+q9rFjADAPWiv8a0GdBp6RwIAfsfjUzWc09SfJQDg//jHVI3mNNVeKfz6
|
||||
BADEg9IdqRrNaWtdOiwBwMz7y1SN5bTW3iL44gQAM+17qRrKaa7d7XBIAoCZtHeqBnIWWp2elgBg5rwp
|
||||
VeM4K61KByUAmClnpmoYZ6mV6cAEADNjRapGcda6Pu2bAGDqbZeqMZzVrkv7JACYagekaghnuSvTHgkA
|
||||
ptahqRrBWe/ytGsCgKn0xlQNoBYtuiztlABg6vxFqsZP/9ulaccEAFPlr1I1fLqri9M2CQCmhh8ANqyv
|
||||
pC0SAEwFXwFseOen5QkAJp6LADeuz6alCQAmmtsAN77T0pIEABPLg4CGdUpanABgInkU8PDenwBgYv0i
|
||||
VQOn++6dCQAm0qdSNW7asI5JADBx3pCqYdOGtT4dmQBgojwiVcOmDW9dOiIBwET5bqqGTRve2vTSBAAT
|
||||
49hUjZo2rjvS8xIATITd0ppUjZo2rvbv+OwEABPhjFQNmja+VempCQC6d2CqxkzDWpnavykAdO+cVI2Z
|
||||
hnVTekwCgK7tlW5P1ZhpWL9Kj0wA0LUTUzVkGt6KtHsCgG4tT99P1ZBpeFekdrcFAHSrfW/ttsC57/L0
|
||||
gAQA3WrPt69GTONqT13cIQFAt96XqhHTuL6dtk0A0KUl6exUjZjGdWHaMgFAl5al81I1YhrXl1K76BIA
|
||||
utR+U22/sVYjpnF9Li1NANClrdLXUjViGtfpqX3dAgBd2j5dkqoR07hOTYsTAHRp5/SD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||
IAEAHWoP4Dk0fTaNeZTwqvSl9Lq0QwIAJkS7Mr/91v7G1P460Ab98vTL1O4k+K90bboifTV9PB2dnpqW
|
||||
JwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgGEW
|
||||
Lfof8qiDQ1mFN78AAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
DAAACwwBP0AiyAAAASRJREFUaEPtmL0KwjAURiv4AK6Co6KCoDgr/ryKvoSb7+Tk4mu46CIiooKDOut3
|
||||
ay+EklQXexO5Bw4kaYac0hYxUhR/qcJNIo2DYwafiTQOjjnkABoHhwZIowHSaIA0GiCNBkijAdJogDQa
|
||||
II0GSKMB0miANBogjQb8khKcwkY8s/NtQBlOYCWe5cQC0sHucEALFr4JqMM9pD1rWsiLFeTDuSI+BTTh
|
||||
AfKeHcwN+r+f7xxpi8gKaMEj5Os32IO5UoNmxAOOIeMKaMMT5GsUP4QiZEXYAjrwDM39YodnXBHpgC68
|
||||
GGu0bwS9IB1Bj8XSmNNX62rM6ZnvQ69IR7j06s6n+RTh9eEZV0QQh2dsL3Ywh2coYgvpy+P6ueE9BVh8
|
||||
D5V/JIpe+j/GQF3wLqYAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAMNJREFUaEPt
|
||||
1T0OAVEUhuGbWAYW4GcBGksgbIZSSWxKBDugwgZmBWh4T6K4ubmmUMg98T3J20wyyXeamSAiIiIi/6VN
|
||||
ezpR1x54YuMv9Hy3JjfS8Q8akgu58RNyoUWux59J438tN35KLrge36R4vLWheSHNqE8fbSkeX2IVNShr
|
||||
R7mXSqr2APthXSl+4UCrQlpQj2qlf907jcgVHVEKHVGK3BFjcsWOiD+xNxqQK+kRS3LHjrA/9pE69kBE
|
||||
RERE5AshvACI8cWowOkNEgAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ElectricLocomotive.Entities;
|
||||
|
||||
namespace ElectricLocomotive.Entities
|
||||
{
|
||||
public class EntityElectroLocomotive : EntityLocomotive
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
public bool Horns { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) roga
|
||||
/// </summary>
|
||||
public EntityElectroLocomotive(int Speed, double weight, Color bodyColor, Color additionalColor, bool horns) : base(Speed,weight,bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Horns = horns;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.Entities
|
||||
{
|
||||
public class EntityLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Конструктор с параметрами
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public EntityLocomotive(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
39
ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs
generated
Normal file
39
ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
10
ElectricLocomotive/ElectricLocomotive/Form1.cs
Normal file
10
ElectricLocomotive/ElectricLocomotive/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
partial class FormLocomotiveCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
CollectionPictureBox = new PictureBox();
|
||||
ToolsBox = new GroupBox();
|
||||
Input = new TextBox();
|
||||
RefreshCollection = new Button();
|
||||
DelLocomotive = new Button();
|
||||
AddLocomotive = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)CollectionPictureBox).BeginInit();
|
||||
ToolsBox.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// CollectionPictureBox
|
||||
//
|
||||
CollectionPictureBox.Location = new Point(3, 0);
|
||||
CollectionPictureBox.Name = "CollectionPictureBox";
|
||||
CollectionPictureBox.Size = new Size(634, 457);
|
||||
CollectionPictureBox.TabIndex = 0;
|
||||
CollectionPictureBox.TabStop = false;
|
||||
//
|
||||
// ToolsBox
|
||||
//
|
||||
ToolsBox.Controls.Add(Input);
|
||||
ToolsBox.Controls.Add(RefreshCollection);
|
||||
ToolsBox.Controls.Add(DelLocomotive);
|
||||
ToolsBox.Controls.Add(AddLocomotive);
|
||||
ToolsBox.Location = new Point(643, 0);
|
||||
ToolsBox.Name = "ToolsBox";
|
||||
ToolsBox.Size = new Size(200, 457);
|
||||
ToolsBox.TabIndex = 1;
|
||||
ToolsBox.TabStop = false;
|
||||
ToolsBox.Text = "Инструменты";
|
||||
//
|
||||
// Input
|
||||
//
|
||||
Input.Location = new Point(7, 91);
|
||||
Input.Name = "Input";
|
||||
Input.Size = new Size(186, 23);
|
||||
Input.TabIndex = 3;
|
||||
//
|
||||
// RefreshCollection
|
||||
//
|
||||
RefreshCollection.Location = new Point(7, 240);
|
||||
RefreshCollection.Name = "RefreshCollection";
|
||||
RefreshCollection.Size = new Size(187, 46);
|
||||
RefreshCollection.TabIndex = 2;
|
||||
RefreshCollection.Text = "Обновить коллекцию";
|
||||
RefreshCollection.UseVisualStyleBackColor = true;
|
||||
RefreshCollection.Click += refreshCollection_Click;
|
||||
//
|
||||
// DelLocomotive
|
||||
//
|
||||
DelLocomotive.Location = new Point(7, 134);
|
||||
DelLocomotive.Name = "DelLocomotive";
|
||||
DelLocomotive.Size = new Size(187, 46);
|
||||
DelLocomotive.TabIndex = 1;
|
||||
DelLocomotive.Text = "Удалить локомотив";
|
||||
DelLocomotive.UseVisualStyleBackColor = true;
|
||||
DelLocomotive.Click += deleteLoco_Click;
|
||||
//
|
||||
// AddLocomotive
|
||||
//
|
||||
AddLocomotive.Location = new Point(6, 22);
|
||||
AddLocomotive.Name = "AddLocomotive";
|
||||
AddLocomotive.Size = new Size(187, 46);
|
||||
AddLocomotive.TabIndex = 0;
|
||||
AddLocomotive.Text = "Добавить локомотив";
|
||||
AddLocomotive.UseVisualStyleBackColor = true;
|
||||
AddLocomotive.Click += addLocomotiv_Click;
|
||||
//
|
||||
// FormLocomotiveCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(848, 469);
|
||||
Controls.Add(ToolsBox);
|
||||
Controls.Add(CollectionPictureBox);
|
||||
Name = "FormLocomotiveCollection";
|
||||
Text = "Коллекция";
|
||||
((System.ComponentModel.ISupportInitialize)CollectionPictureBox).EndInit();
|
||||
ToolsBox.ResumeLayout(false);
|
||||
ToolsBox.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox CollectionPictureBox;
|
||||
private GroupBox ToolsBox;
|
||||
private TextBox Input;
|
||||
private Button RefreshCollection;
|
||||
private Button DelLocomotive;
|
||||
private Button AddLocomotive;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
using ElectricLocomotive.DrawningObject;
|
||||
using ElectricLocomotive.Generics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public partial class FormLocomotiveCollection : Form
|
||||
{
|
||||
private readonly LocomotivesGenericCollection<DrawningLocomotive, DrawningObjectLocomotive> _locos;
|
||||
public FormLocomotiveCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_locos = new(CollectionPictureBox.Width, CollectionPictureBox.Height);
|
||||
}
|
||||
|
||||
private void addLocomotiv_Click(object sender, EventArgs e)
|
||||
{
|
||||
ElectricLocomotive form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_locos + form.SelectedLocomotive != null)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
CollectionPictureBox.Image = _locos.ShowLocomotives();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteLoco_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(Input.Text);
|
||||
if (_locos - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
CollectionPictureBox.Image = _locos.ShowLocomotives();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
CollectionPictureBox.Image = _locos.ShowLocomotives();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
|
||||
int GetStep { get; }
|
||||
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ElectricLocomotive.DrawningObject;
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
using ProjectElectricLocomotive.Generics;
|
||||
|
||||
namespace ElectricLocomotive.Generics
|
||||
{
|
||||
internal class LocomotivesGenericCollection<T, U>
|
||||
where T : DrawningLocomotive
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 200;
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
public LocomotivesGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static int operator +(LocomotivesGenericCollection<T, U> collect, T? locomotive)
|
||||
{
|
||||
if (locomotive == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return collect?._collection.Insert(locomotive) ?? -1;
|
||||
}
|
||||
public static bool operator -(LocomotivesGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? locomotive = collect._collection.Get(pos);
|
||||
if (locomotive != null)
|
||||
return collect._collection.Remove(pos);
|
||||
return false;
|
||||
}
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowLocomotives()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int HLoco = _pictureHeight / _placeSizeHeight;
|
||||
int Wloco = _pictureWidth / _placeSizeWidth;
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
{
|
||||
T? type = _collection.Get(i);
|
||||
if (type != null)
|
||||
{
|
||||
type.SetPosition(
|
||||
(int)(i / HLoco * _placeSizeWidth),
|
||||
(HLoco - 1) * _placeSizeHeight - (int)(i % HLoco * _placeSizeHeight)
|
||||
);
|
||||
type?.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
using ElectricLocomotive.MovementStrategy;
|
||||
using ProjectElectricLocomotive.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.MovementStrategy
|
||||
{
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
using ProjectElectricLocomotive.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.MovementStrategy
|
||||
{
|
||||
public class MoveToRightCorner : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return false;
|
||||
|
||||
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null) return;
|
||||
|
||||
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
|
||||
if (objParams.DownBorder < FieldHeight - GetStep()) MoveDown();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
public int RightBorder => _x + _width;
|
||||
public int DownBorder => _y + _height;
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
using ProjectElectricLocomotive;
|
||||
|
||||
namespace ElectricLocomotive
|
||||
{
|
||||
internal static class Program
|
||||
@ -13,7 +11,7 @@ namespace ElectricLocomotive
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormLocomotiveCollection());
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ElectricLocomotive.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ElectricLocomotive.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly T?[] _places;
|
||||
public int Count => _places.Length;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
public int Insert(T locomotive)
|
||||
{
|
||||
return Insert(locomotive, 0);
|
||||
}
|
||||
public int Insert(T locomotive, int position)
|
||||
{
|
||||
int Full = 0;
|
||||
int temp = 0;
|
||||
for (int i = position; i < Count; i++)
|
||||
{
|
||||
if (_places[i] != null) Full++;
|
||||
}
|
||||
if (Full == Count - position - 1)
|
||||
return -1;
|
||||
if (position < Count && position >= 0)
|
||||
{
|
||||
for (int j = position; j < Count; j++)
|
||||
{
|
||||
if (_places[j] == null)
|
||||
{
|
||||
temp = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = temp; i > position; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[position] = locomotive;
|
||||
return position;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position >= Count || position < 0)
|
||||
if (!(position >= 0 && position < Count) || _places[position] == null)
|
||||
return false;
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
public T Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count) return null;
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectricLocomotive.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user