Compare commits

..

22 Commits

Author SHA1 Message Date
5e0834fb83 Ready lab 5 with formatting... everything seems to be in order 2023-11-14 00:43:34 +04:00
65f140055c Almost ready lab 5 for push 2023-11-07 12:45:40 +04:00
b66bd4fcba теперь-то, надеюсь, точно готовая лаба 5 2023-11-06 14:51:00 +04:00
a942074519 Almost ready lab 5 2023-11-04 00:14:41 +04:00
21b20cb0c9 Create FormCinfig 4 lab 2023-11-02 19:25:09 +04:00
7051e1850d Create LabWork05 2023-11-02 18:45:23 +04:00
31e2860de6 Ready LabWork04 for pull request 2023-10-24 13:43:09 +04:00
ede2388115 ready LabWork4 2023-10-23 10:36:41 +04:00
1d4d9c2d3a Add something whithout form's modofocations, 4 LabWork 2023-10-22 17:49:53 +04:00
5ade022f0c Create 4 branch 2023-10-22 10:17:30 +04:00
0e251a1527 All LabWork03 2023-10-13 17:02:10 +04:00
cf3945209c Добавлен комментарий 2023-10-10 14:27:22 +04:00
17cb3342de All lab 2 for push 2023-10-05 13:29:41 +04:00
0497411365 Created all classes, but without second moving method 2023-09-26 00:18:33 +04:00
9f2f1b0686 Created classes: ObjectsParam and Interface class 2023-09-24 11:11:39 +04:00
9bd4a33db6 Create class: drawing electroLocomotive 2023-09-24 09:33:25 +04:00
abc845461b Created class "DrawingLoco 2023-09-23 20:12:55 +04:00
9965a02c98 Created base class EntityLocomotive"" 2023-09-23 19:20:20 +04:00
1c87d04014 готовая к выгрузке 1 лаба 2023-09-13 19:58:42 +04:00
925981ec50 Изменено: рандомные провода и отсек 2023-09-13 09:29:33 +04:00
8a9112530c корректировка лабы 1 2023-09-12 20:51:58 +04:00
a8e887e77d Готовая лаб1 2023-09-12 19:25:56 +04:00
34 changed files with 2607 additions and 51 deletions

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ElectricLocomotive;
using ProjectElectricLocomotive.DrawingObjects;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace ProjectElectricLocomotive.MovementStrategy
{
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;
}
}
}

View File

@ -0,0 +1,16 @@
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,
}
}

View File

@ -0,0 +1,53 @@
using ProjectElectricLocomotive.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.DrawingObjects
{
public class DrawingElectricLocomotive : DrawingLocomotive
{
public DrawingElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor,
bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 85, 50)
{
if (EntityLocomotive != null)
{
EntityLocomotive = new EntityElectricLocomotive(speed, width, bodyColor, additionalColor, horns, seifBatteries);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityLocomotive is not EntityElectricLocomotive electricLocomotive)
{
return;
}
Pen pen = new Pen(electricLocomotive.AdditionalColor);
Brush blackBrush = new SolidBrush(Color.Black);
Brush additionalBrush = new SolidBrush(electricLocomotive.AdditionalColor);
if (electricLocomotive.Horns)
{
//horns
g.FillRectangle(additionalBrush, _startPosX + 30, _startPosY + 15, 20, 5);
g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 50, _startPosY + 10);
g.DrawLine(pen, _startPosX + 50, _startPosY + 10, _startPosX + 45, _startPosY);
g.DrawLine(pen, _startPosX + 45, _startPosY + 15, _startPosX + 50, _startPosY + 10);
g.DrawLine(pen, _startPosX + 50, _startPosY + 10, _startPosX + 40, _startPosY);
}
if (electricLocomotive.SeifBatteries)
{
g.FillRectangle(additionalBrush, _startPosX + 80, _startPosY + 30, 5, 10);
}
base.DrawTransport(g);
}
public void SetAddColor(Color color)
{
(EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color);
}
}
}

View File

@ -0,0 +1,205 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ElectricLocomotive;
using ProjectElectricLocomotive.Entities;
using ProjectElectricLocomotive.MovementStrategy;
using ProjectElectricLocomotive.Properties;
namespace ProjectElectricLocomotive.DrawingObjects
{
public class DrawingLocomotive
{
public EntityLocomotive? EntityLocomotive { get; protected set; }
public int _pictureWidth;
public int _pictureHeight;
protected int _startPosX;
protected int _startPosY;
protected readonly int _locoWidth = 85;
protected readonly int _locoHeight = 50;
public int GetPosX => _startPosX;
public int GetPosY => _startPosY;
public int GetWidth => _locoWidth;
public int GetHeight => _locoHeight;
public IMoveableObject GetMoveableObject => new DrawingObjectLocomotive(this);
public DrawingLocomotive(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 DrawingLocomotive(int speed, double weight, Color bodyColor, 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);
}
//Установка позиции
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;
}
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;
}
}
public virtual void DrawTransport(Graphics g)
{
{
if (EntityLocomotive == null) return;
}
Pen pen = new(Color.Black);
Brush blackBrush = new SolidBrush(Color.Black);
Brush windows = new SolidBrush(Color.LightBlue);
Brush bodyColor = new SolidBrush(EntityLocomotive.BodyColor);
//локомотив
g.FillPolygon(bodyColor, new Point[]
{
new Point(_startPosX, _startPosY + 40),
new Point(_startPosX, _startPosY + 30),
new Point(_startPosX + 20, _startPosY + 20),
new Point(_startPosX + 70, _startPosY + 20),
new Point(_startPosX +80, _startPosY + 30),
new Point(_startPosX +80, _startPosY + 40),
new Point(_startPosX +75, _startPosY + 45),
new Point(_startPosX +5, _startPosY + 45),
new Point(_startPosX, _startPosY + 40),
}
);
g.DrawPolygon(pen, new Point[]
{
new Point(_startPosX, _startPosY + 40),
new Point(_startPosX, _startPosY + 30),
new Point(_startPosX + 20, _startPosY + 20),
new Point(_startPosX + 70, _startPosY + 20),
new Point(_startPosX +80, _startPosY + 30),
new Point(_startPosX +80, _startPosY + 40),
new Point(_startPosX +75, _startPosY + 45),
new Point(_startPosX +5, _startPosY + 45),
new Point(_startPosX, _startPosY + 40),
}
);
//окошки
g.FillPolygon(windows, new Point[]
{
new Point(_startPosX + 10, _startPosY + 30),
new Point(_startPosX +15, _startPosY + 25),
new Point(_startPosX + 20, _startPosY + 25),
new Point(_startPosX + 20, _startPosY + 30),
new Point(_startPosX +10, _startPosY + 30),
}
);
g.DrawPolygon(pen, new Point[]
{
new Point(_startPosX + 10, _startPosY + 30),
new Point(_startPosX +15, _startPosY + 25),
new Point(_startPosX + 20, _startPosY + 25),
new Point(_startPosX + 20, _startPosY + 30),
new Point(_startPosX +10, _startPosY + 30),
}
);
g.FillRectangle(windows, _startPosX + 25, _startPosY + 25, 10, 5);
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 25, 10, 5);
//обязательные колеса
//loco
g.FillEllipse(blackBrush, _startPosX + 10, _startPosY + 45, 5, 5);
g.FillEllipse(blackBrush, _startPosX + 25, _startPosY + 45, 5, 5);
g.FillEllipse(blackBrush, _startPosX + 50, _startPosY + 45, 5, 5);
g.FillEllipse(blackBrush, _startPosX + 65, _startPosY + 45, 5, 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 void SetColor(Color color)
{
(EntityLocomotive as EntityLocomotive).SetColor(color);
}
}
}

View File

@ -0,0 +1,35 @@
using ElectricLocomotive;
using ProjectElectricLocomotive.DrawingObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
public class DrawingObjectLocomotive : IMoveableObject
{
private readonly DrawingLocomotive? _drawningLocomotive = null;
public DrawingObjectLocomotive(DrawingLocomotive 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);
}
}

View File

@ -0,0 +1,28 @@
using ProjectElectricLocomotive.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Entities
{
public class EntityElectricLocomotive : EntityLocomotive
{
public Color AdditionalColor { get; private set; }
public bool Horns { get; private set; }
public bool SeifBatteries { get; private set; }
public EntityElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool horns,
bool seifBatteries) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Horns = horns;
SeifBatteries = seifBatteries;
}
public void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Entities
{
public class EntityLocomotive
{
public int Speed { get; private set;}
public double Weight { get; private set;}
public Color BodyColor { get; private set;}
public double Step => (double) Speed * 100 / Weight;
public EntityLocomotive(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
public void SetColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -1,39 +0,0 @@
namespace ProjectElectricLocomotive
{
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
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectElectricLocomotive
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,211 @@
namespace ElectricLocomotive
{
partial class FormElectricLocomotive
{
/// <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.pictureBoxElectricLocomotive = new System.Windows.Forms.PictureBox();
this.buttonCreateElectricLocomotive = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
this.buttonCreateLocomotive = new System.Windows.Forms.Button();
this.buttonStep = new System.Windows.Forms.Button();
this.ButtonSelect_Locomotive = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxElectricLocomotive)).BeginInit();
this.SuspendLayout();
//
// pictureBoxElectricLocomotive
//
this.pictureBoxElectricLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxElectricLocomotive.Location = new System.Drawing.Point(0, 0);
this.pictureBoxElectricLocomotive.Margin = new System.Windows.Forms.Padding(2);
this.pictureBoxElectricLocomotive.Name = "pictureBoxElectricLocomotive";
this.pictureBoxElectricLocomotive.Size = new System.Drawing.Size(870, 572);
this.pictureBoxElectricLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxElectricLocomotive.TabIndex = 0;
this.pictureBoxElectricLocomotive.TabStop = false;
//
// buttonCreateElectricLocomotive
//
this.buttonCreateElectricLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateElectricLocomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.buttonCreateElectricLocomotive.Location = new System.Drawing.Point(11, 514);
this.buttonCreateElectricLocomotive.Margin = new System.Windows.Forms.Padding(2);
this.buttonCreateElectricLocomotive.Name = "buttonCreateElectricLocomotive";
this.buttonCreateElectricLocomotive.Size = new System.Drawing.Size(191, 48);
this.buttonCreateElectricLocomotive.TabIndex = 1;
this.buttonCreateElectricLocomotive.Text = "Создать электролокомотив";
this.buttonCreateElectricLocomotive.UseVisualStyleBackColor = true;
this.buttonCreateElectricLocomotive.Click += new System.EventHandler(this.buttonCreateElectricLocomotive_Click);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonLeft.Location = new System.Drawing.Point(768, 543);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(2);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(21, 18);
this.buttonLeft.TabIndex = 2;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowUP;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonUp.Location = new System.Drawing.Point(801, 514);
this.buttonUp.Margin = new System.Windows.Forms.Padding(2);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(21, 18);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonRight.Location = new System.Drawing.Point(831, 543);
this.buttonRight.Margin = new System.Windows.Forms.Padding(2);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(21, 18);
this.buttonRight.TabIndex = 4;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::ProjectElectricLocomotive.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonDown.Location = new System.Drawing.Point(801, 543);
this.buttonDown.Margin = new System.Windows.Forms.Padding(2);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(21, 18);
this.buttonDown.TabIndex = 5;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
//
// comboBoxStrategy
//
this.comboBoxStrategy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxStrategy.FormattingEnabled = true;
this.comboBoxStrategy.Items.AddRange(new object[] {
"MoveToCenter",
"MoveToRightCorner"});
this.comboBoxStrategy.Location = new System.Drawing.Point(740, 8);
this.comboBoxStrategy.Margin = new System.Windows.Forms.Padding(2);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(113, 23);
this.comboBoxStrategy.TabIndex = 6;
//
// buttonCreateLocomotive
//
this.buttonCreateLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateLocomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.buttonCreateLocomotive.Location = new System.Drawing.Point(233, 514);
this.buttonCreateLocomotive.Margin = new System.Windows.Forms.Padding(2);
this.buttonCreateLocomotive.Name = "buttonCreateLocomotive";
this.buttonCreateLocomotive.Size = new System.Drawing.Size(191, 48);
this.buttonCreateLocomotive.TabIndex = 7;
this.buttonCreateLocomotive.Text = "Создать локомотив";
this.buttonCreateLocomotive.UseVisualStyleBackColor = true;
this.buttonCreateLocomotive.Click += new System.EventHandler(this.buttonCreateLocomotive_Click);
//
// buttonStep
//
this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonStep.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.buttonStep.Location = new System.Drawing.Point(755, 39);
this.buttonStep.Margin = new System.Windows.Forms.Padding(2);
this.buttonStep.Name = "buttonStep";
this.buttonStep.Size = new System.Drawing.Size(88, 34);
this.buttonStep.TabIndex = 8;
this.buttonStep.Text = "Шаг";
this.buttonStep.UseVisualStyleBackColor = true;
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
//
// ButtonSelect_Locomotive
//
this.ButtonSelect_Locomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonSelect_Locomotive.Font = new System.Drawing.Font("Candara Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonSelect_Locomotive.Location = new System.Drawing.Point(755, 85);
this.ButtonSelect_Locomotive.Margin = new System.Windows.Forms.Padding(2);
this.ButtonSelect_Locomotive.Name = "ButtonSelect_Locomotive";
this.ButtonSelect_Locomotive.Size = new System.Drawing.Size(88, 46);
this.ButtonSelect_Locomotive.TabIndex = 9;
this.ButtonSelect_Locomotive.Text = "Выбор локо";
this.ButtonSelect_Locomotive.UseVisualStyleBackColor = true;
this.ButtonSelect_Locomotive.Click += new System.EventHandler(this.ButtonSelect_Locomotive_Click);
//
// FormElectricLocomotive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(870, 572);
this.Controls.Add(this.ButtonSelect_Locomotive);
this.Controls.Add(this.buttonStep);
this.Controls.Add(this.buttonCreateLocomotive);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonCreateElectricLocomotive);
this.Controls.Add(this.pictureBoxElectricLocomotive);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "FormElectricLocomotive";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ElectricLocomotive";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxElectricLocomotive)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxElectricLocomotive;
private Button buttonCreateElectricLocomotive;
private Button buttonLeft;
private Button buttonUp;
private Button buttonRight;
private Button buttonDown;
private ComboBox comboBoxStrategy;
private Button buttonCreateLocomotive;
private Button buttonStep;
private Button ButtonSelect_Locomotive;
}
}

View File

@ -0,0 +1,143 @@
using ProjectElectricLocomotive;
using ProjectElectricLocomotive.DrawingObjects;
using ProjectElectricLocomotive.MovementStrategy;
using System;
using System.Windows.Forms;
namespace ElectricLocomotive
{
public partial class FormElectricLocomotive : Form
{
private DrawingLocomotive? _drawingLocomotive;
private AbstractStrategy? _abstractStrategy;
public DrawingLocomotive? SelectedLocomotive { get; private set; }
public FormElectricLocomotive()
{
InitializeComponent();
_abstractStrategy = null;
SelectedLocomotive = null;
}
private void Draw()
{
if (_drawingLocomotive == null)
{
return;
}
Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingLocomotive.DrawTransport(gr);
pictureBoxElectricLocomotive.Image = bmp;
}
private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e)
{
Random random = new Random();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog colorDialog = new ColorDialog();
if(colorDialog.ShowDialog() == DialogResult.OK){
color = colorDialog.Color;
}
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
if (colorDialog.ShowDialog() == DialogResult.OK)
{
dopColor = colorDialog.Color;
}
_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);
_drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonCreateLocomotive_Click(object sender, EventArgs e)
{
Random rnd = new Random();
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog colorDialog = new ColorDialog();
if (colorDialog.ShowDialog() == DialogResult.OK)
{
color = colorDialog.Color;
}
_drawingLocomotive = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), color,
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
_drawingLocomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100));
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawingLocomotive == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawingLocomotive.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawingLocomotive.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawingLocomotive.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawingLocomotive.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
private void buttonStep_Click(object sender, EventArgs e)
{
if (_drawingLocomotive == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_abstractStrategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToRightCorner(),
_ => null,
};
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.SetData(_drawingLocomotive.GetMoveableObject, pictureBoxElectricLocomotive.Width,
pictureBoxElectricLocomotive.Height);
}
if (_abstractStrategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
_abstractStrategy.MakeStep();
Draw();
if (_abstractStrategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_abstractStrategy = null;
}
}
private void ButtonSelect_Locomotive_Click(object sender, EventArgs e)
{
SelectedLocomotive = _drawingLocomotive;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

View File

@ -0,0 +1,217 @@
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveCollections
{
/// <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.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
this.ButtonRemoveLocomotive = new System.Windows.Forms.Button();
this.ButtonAddLocomotive = new System.Windows.Forms.Button();
this.pictureBoxCollections = new System.Windows.Forms.PictureBox();
this.textBoxStorageName = new System.Windows.Forms.TextBox();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
this.bindingSource2 = new System.Windows.Forms.BindingSource(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listBoxStorage = new System.Windows.Forms.ListBox();
this.ButtonAddObject = new System.Windows.Forms.Button();
this.ButtonRemoveObject = new System.Windows.Forms.Button();
this.Instruments = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).BeginInit();
this.groupBox1.SuspendLayout();
this.Instruments.SuspendLayout();
this.SuspendLayout();
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.maskedTextBoxNumber.Location = new System.Drawing.Point(38, 532);
this.maskedTextBoxNumber.Mask = "0";
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(149, 27);
this.maskedTextBoxNumber.TabIndex = 4;
//
// ButtonRefreshCollection
//
this.ButtonRefreshCollection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRefreshCollection.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonRefreshCollection.Location = new System.Drawing.Point(38, 665);
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
this.ButtonRefreshCollection.Size = new System.Drawing.Size(150, 41);
this.ButtonRefreshCollection.TabIndex = 2;
this.ButtonRefreshCollection.Text = "Обновить все";
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
//
// ButtonRemoveLocomotive
//
this.ButtonRemoveLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRemoveLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonRemoveLocomotive.Location = new System.Drawing.Point(38, 592);
this.ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
this.ButtonRemoveLocomotive.Size = new System.Drawing.Size(150, 44);
this.ButtonRemoveLocomotive.TabIndex = 1;
this.ButtonRemoveLocomotive.Text = "Удалить локо";
this.ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
this.ButtonRemoveLocomotive.Click += new System.EventHandler(this.ButtonRemoveLocomotive_Click);
//
// ButtonAddLocomotive
//
this.ButtonAddLocomotive.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.ButtonAddLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonAddLocomotive.Location = new System.Drawing.Point(38, 461);
this.ButtonAddLocomotive.Name = "ButtonAddLocomotive";
this.ButtonAddLocomotive.Size = new System.Drawing.Size(150, 39);
this.ButtonAddLocomotive.TabIndex = 0;
this.ButtonAddLocomotive.Text = "Добавить локо";
this.ButtonAddLocomotive.UseVisualStyleBackColor = true;
this.ButtonAddLocomotive.Click += new System.EventHandler(this.ButtonAddLocomotive_Click);
//
// pictureBoxCollections
//
this.pictureBoxCollections.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxCollections.Location = new System.Drawing.Point(-1, 5);
this.pictureBoxCollections.Name = "pictureBoxCollections";
this.pictureBoxCollections.Size = new System.Drawing.Size(798, 721);
this.pictureBoxCollections.TabIndex = 1;
this.pictureBoxCollections.TabStop = false;
//
// textBoxStorageName
//
this.textBoxStorageName.Location = new System.Drawing.Point(31, 43);
this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.Size = new System.Drawing.Size(149, 27);
this.textBoxStorageName.TabIndex = 5;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.listBoxStorage);
this.groupBox1.Controls.Add(this.ButtonAddObject);
this.groupBox1.Controls.Add(this.ButtonRemoveObject);
this.groupBox1.Controls.Add(this.textBoxStorageName);
this.groupBox1.Location = new System.Drawing.Point(7, 29);
this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBox1.Size = new System.Drawing.Size(216, 395);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Наборы";
//
// listBoxStorage
//
this.listBoxStorage.FormattingEnabled = true;
this.listBoxStorage.ItemHeight = 20;
this.listBoxStorage.Location = new System.Drawing.Point(31, 163);
this.listBoxStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBoxStorage.Name = "listBoxStorage";
this.listBoxStorage.Size = new System.Drawing.Size(149, 124);
this.listBoxStorage.TabIndex = 9;
this.listBoxStorage.SelectedIndexChanged += new System.EventHandler(this.listBoxStorage_SelectedIndexChanged);
//
// ButtonAddObject
//
this.ButtonAddObject.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.ButtonAddObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonAddObject.Location = new System.Drawing.Point(31, 96);
this.ButtonAddObject.Name = "ButtonAddObject";
this.ButtonAddObject.Size = new System.Drawing.Size(150, 39);
this.ButtonAddObject.TabIndex = 7;
this.ButtonAddObject.Text = "Добавить набор";
this.ButtonAddObject.UseVisualStyleBackColor = true;
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
//
// ButtonRemoveObject
//
this.ButtonRemoveObject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRemoveObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ButtonRemoveObject.Location = new System.Drawing.Point(31, 325);
this.ButtonRemoveObject.Name = "ButtonRemoveObject";
this.ButtonRemoveObject.Size = new System.Drawing.Size(150, 44);
this.ButtonRemoveObject.TabIndex = 8;
this.ButtonRemoveObject.Text = "Удалить набор";
this.ButtonRemoveObject.UseVisualStyleBackColor = true;
this.ButtonRemoveObject.Click += new System.EventHandler(this.ButtonRemoveObject_Click);
//
// Instruments
//
this.Instruments.Controls.Add(this.ButtonRefreshCollection);
this.Instruments.Controls.Add(this.groupBox1);
this.Instruments.Controls.Add(this.maskedTextBoxNumber);
this.Instruments.Controls.Add(this.ButtonAddLocomotive);
this.Instruments.Controls.Add(this.ButtonRemoveLocomotive);
this.Instruments.Location = new System.Drawing.Point(797, 5);
this.Instruments.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Instruments.Name = "Instruments";
this.Instruments.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Instruments.Size = new System.Drawing.Size(229, 721);
this.Instruments.TabIndex = 6;
this.Instruments.TabStop = false;
this.Instruments.Text = "Инструменты";
//
// FormLocomotiveCollections
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1033, 724);
this.Controls.Add(this.Instruments);
this.Controls.Add(this.pictureBoxCollections);
this.Name = "FormLocomotiveCollections";
this.Text = "Набор локомотивов";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.Instruments.ResumeLayout(false);
this.Instruments.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Button ButtonRefreshCollection;
private Button ButtonRemoveLocomotive;
private Button ButtonAddLocomotive;
private PictureBox pictureBoxCollections;
private MaskedTextBox maskedTextBoxNumber;
private GroupBox groupBox1;
private TextBox textBoxStorageName;
private BindingSource bindingSource1;
private BindingSource bindingSource2;
private ListBox listBoxStorage;
private Button ButtonAddObject;
private Button ButtonRemoveObject;
private GroupBox Instruments;
}
}

View File

@ -0,0 +1,147 @@
using ElectricLocomotive;
using ProjectElectricLocomotive.DrawingObjects;
using ProjectElectricLocomotive.Generics;
using ProjectElectricLocomotive.MovementStrategy;
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 ProjectElectricLocomotive
{
public partial class FormLocomotiveCollections : Form
{
private readonly LocomotiveGenericStorage _storage;
public FormLocomotiveCollections()
{
InitializeComponent();
_storage = new LocomotiveGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
}
/// <summary>
/// Заполнение listBoxObjects
/// </summary>
private void ReloadObjects()
{
int index = listBoxStorage.SelectedIndex;
listBoxStorage.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorage.Items.Add(_storage.Keys[i]);
}
if (listBoxStorage.Items.Count > 0 && (index == -1 || index >= listBoxStorage.Items.Count))
{
listBoxStorage.SelectedIndex = 0;
}
else if (listBoxStorage.Items.Count > 0 && index > -1 && index < listBoxStorage.Items.Count)
{
listBoxStorage.SelectedIndex = index;
}
}
private void ButtonAddObject_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
}
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollections.Image = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowLocomotives();
}
private void ButtonRemoveObject_Click(object sender, EventArgs e)
{
if (listBoxStorage.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty);
ReloadObjects();
}
}
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
var formLocomotiveConfig = new FormLocomotiveConfig();
formLocomotiveConfig.AddEvent(addLoco);
formLocomotiveConfig.Show();
}
public void addLoco(DrawingLocomotive loco)
{
loco._pictureWidth = pictureBoxCollections.Width;
loco._pictureHeight = pictureBoxCollections.Height;
if (listBoxStorage.SelectedIndex == -1) return;
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
//проверяем, удалось ли нам загрузить объект
if (obj + loco > -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollections.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
{
if (listBoxStorage.SelectedIndex == -1) return;
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (obj - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollections.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
if (listBoxStorage.SelectedIndex == -1) return;
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollections.Image = obj.ShowLocomotives();
}
}
}

View File

@ -0,0 +1,69 @@
<root>
<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>
<metadata name="bindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="bindingSource2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>154, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@ -0,0 +1,394 @@
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveConfig
{
/// <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.groupBoxObjectParameters = new System.Windows.Forms.GroupBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.checkBoxSeifBatteries = new System.Windows.Forms.CheckBox();
this.checkBoxHorns = new System.Windows.Forms.CheckBox();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.labelWeight = new System.Windows.Forms.Label();
this.labelSpeed = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelPastelViolet = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelLilac = new System.Windows.Forms.FlowLayoutPanel();
this.panelSkyBlue = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelGreen = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelYellow = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelOrange = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelPink = new System.Windows.Forms.FlowLayoutPanel();
this.panelPastelRed = new System.Windows.Forms.FlowLayoutPanel();
this.panelObject = new System.Windows.Forms.Panel();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.labelAddColor = new System.Windows.Forms.Label();
this.labelColor = new System.Windows.Forms.Label();
this.ButtonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.groupBoxObjectParameters.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
this.groupBoxColors.SuspendLayout();
this.panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.SuspendLayout();
//
// groupBoxObjectParameters
//
this.groupBoxObjectParameters.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBoxObjectParameters.Controls.Add(this.numericUpDownWeight);
this.groupBoxObjectParameters.Controls.Add(this.numericUpDownSpeed);
this.groupBoxObjectParameters.Controls.Add(this.checkBoxSeifBatteries);
this.groupBoxObjectParameters.Controls.Add(this.checkBoxHorns);
this.groupBoxObjectParameters.Controls.Add(this.labelModifiedObject);
this.groupBoxObjectParameters.Controls.Add(this.labelSimpleObject);
this.groupBoxObjectParameters.Controls.Add(this.labelWeight);
this.groupBoxObjectParameters.Controls.Add(this.labelSpeed);
this.groupBoxObjectParameters.Controls.Add(this.groupBoxColors);
this.groupBoxObjectParameters.Location = new System.Drawing.Point(7, 12);
this.groupBoxObjectParameters.Name = "groupBoxObjectParameters";
this.groupBoxObjectParameters.Size = new System.Drawing.Size(792, 395);
this.groupBoxObjectParameters.TabIndex = 0;
this.groupBoxObjectParameters.TabStop = false;
this.groupBoxObjectParameters.Text = "Параметры";
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(108, 92);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
this.numericUpDownWeight.TabIndex = 8;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(108, 34);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(150, 27);
this.numericUpDownSpeed.TabIndex = 7;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// checkBoxSeifBatteries
//
this.checkBoxSeifBatteries.AutoSize = true;
this.checkBoxSeifBatteries.Location = new System.Drawing.Point(19, 259);
this.checkBoxSeifBatteries.Name = "checkBoxSeifBatteries";
this.checkBoxSeifBatteries.Size = new System.Drawing.Size(297, 24);
this.checkBoxSeifBatteries.TabIndex = 6;
this.checkBoxSeifBatteries.Text = "Признак наличия батарейного отсека";
this.checkBoxSeifBatteries.UseVisualStyleBackColor = true;
//
// checkBoxHorns
//
this.checkBoxHorns.AutoSize = true;
this.checkBoxHorns.Location = new System.Drawing.Point(19, 174);
this.checkBoxHorns.Name = "checkBoxHorns";
this.checkBoxHorns.Size = new System.Drawing.Size(199, 24);
this.checkBoxHorns.TabIndex = 5;
this.checkBoxHorns.Text = "Признак наличия рогов";
this.checkBoxHorns.UseVisualStyleBackColor = true;
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(655, 239);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(113, 44);
this.labelModifiedObject.TabIndex = 4;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(390, 239);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(113, 44);
this.labelSimpleObject.TabIndex = 3;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(19, 94);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(33, 20);
this.labelWeight.TabIndex = 2;
this.labelWeight.Text = "Вес";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(19, 36);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(73, 20);
this.labelSpeed.TabIndex = 1;
this.labelSpeed.Text = "Скорость";
//
// groupBoxColors
//
this.groupBoxColors.Controls.Add(this.panelPastelViolet);
this.groupBoxColors.Controls.Add(this.panelPastelLilac);
this.groupBoxColors.Controls.Add(this.panelSkyBlue);
this.groupBoxColors.Controls.Add(this.panelPastelGreen);
this.groupBoxColors.Controls.Add(this.panelPastelYellow);
this.groupBoxColors.Controls.Add(this.panelPastelOrange);
this.groupBoxColors.Controls.Add(this.panelPastelPink);
this.groupBoxColors.Controls.Add(this.panelPastelRed);
this.groupBoxColors.Location = new System.Drawing.Point(390, 22);
this.groupBoxColors.Name = "groupBoxColors";
this.groupBoxColors.Size = new System.Drawing.Size(378, 176);
this.groupBoxColors.TabIndex = 0;
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета";
//
// panelPastelViolet
//
this.panelPastelViolet.AllowDrop = true;
this.panelPastelViolet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.panelPastelViolet.Location = new System.Drawing.Point(281, 110);
this.panelPastelViolet.Name = "panelPastelViolet";
this.panelPastelViolet.Size = new System.Drawing.Size(40, 40);
this.panelPastelViolet.TabIndex = 3;
//
// panelPastelLilac
//
this.panelPastelLilac.AllowDrop = true;
this.panelPastelLilac.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.panelPastelLilac.Location = new System.Drawing.Point(207, 110);
this.panelPastelLilac.Name = "panelPastelLilac";
this.panelPastelLilac.Size = new System.Drawing.Size(40, 40);
this.panelPastelLilac.TabIndex = 4;
//
// panelSkyBlue
//
this.panelSkyBlue.AllowDrop = true;
this.panelSkyBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.panelSkyBlue.Location = new System.Drawing.Point(132, 110);
this.panelSkyBlue.Name = "panelSkyBlue";
this.panelSkyBlue.Size = new System.Drawing.Size(40, 40);
this.panelSkyBlue.TabIndex = 5;
//
// panelPastelGreen
//
this.panelPastelGreen.AllowDrop = true;
this.panelPastelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.panelPastelGreen.Location = new System.Drawing.Point(55, 110);
this.panelPastelGreen.Name = "panelPastelGreen";
this.panelPastelGreen.Size = new System.Drawing.Size(40, 40);
this.panelPastelGreen.TabIndex = 2;
//
// panelPastelYellow
//
this.panelPastelYellow.AllowDrop = true;
this.panelPastelYellow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.panelPastelYellow.Location = new System.Drawing.Point(281, 35);
this.panelPastelYellow.Name = "panelPastelYellow";
this.panelPastelYellow.Size = new System.Drawing.Size(40, 40);
this.panelPastelYellow.TabIndex = 1;
//
// panelPastelOrange
//
this.panelPastelOrange.AllowDrop = true;
this.panelPastelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.panelPastelOrange.Location = new System.Drawing.Point(207, 35);
this.panelPastelOrange.Name = "panelPastelOrange";
this.panelPastelOrange.Size = new System.Drawing.Size(40, 40);
this.panelPastelOrange.TabIndex = 1;
//
// panelPastelPink
//
this.panelPastelPink.AllowDrop = true;
this.panelPastelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.panelPastelPink.Location = new System.Drawing.Point(132, 35);
this.panelPastelPink.Name = "panelPastelPink";
this.panelPastelPink.Size = new System.Drawing.Size(40, 40);
this.panelPastelPink.TabIndex = 1;
//
// panelPastelRed
//
this.panelPastelRed.AllowDrop = true;
this.panelPastelRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.panelPastelRed.Location = new System.Drawing.Point(55, 35);
this.panelPastelRed.Name = "panelPastelRed";
this.panelPastelRed.Size = new System.Drawing.Size(40, 40);
this.panelPastelRed.TabIndex = 0;
this.panelPastelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelObject
//
this.panelObject.AllowDrop = true;
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Controls.Add(this.labelAddColor);
this.panelObject.Controls.Add(this.labelColor);
this.panelObject.Location = new System.Drawing.Point(812, 25);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(392, 300);
this.panelObject.TabIndex = 1;
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(19, 83);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(354, 198);
this.pictureBoxObject.TabIndex = 7;
this.pictureBoxObject.TabStop = false;
//
// labelAddColor
//
this.labelAddColor.AllowDrop = true;
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAddColor.Location = new System.Drawing.Point(260, 21);
this.labelAddColor.Name = "labelAddColor";
this.labelAddColor.Size = new System.Drawing.Size(113, 44);
this.labelAddColor.TabIndex = 6;
this.labelAddColor.Text = "Доп. Цвет";
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
//
// labelColor
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(19, 21);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(113, 44);
this.labelColor.TabIndex = 5;
this.labelColor.Text = "Цвет";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
//
// ButtonOk
//
this.ButtonOk.Location = new System.Drawing.Point(813, 341);
this.ButtonOk.Name = "ButtonOk";
this.ButtonOk.Size = new System.Drawing.Size(131, 49);
this.ButtonOk.TabIndex = 2;
this.ButtonOk.Text = "Добавить";
this.ButtonOk.UseVisualStyleBackColor = true;
// this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(1072, 341);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(131, 49);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormLocomotiveConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1219, 419);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.ButtonOk);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxObjectParameters);
this.Name = "FormLocomotiveConfig";
this.Text = "FormLocomotiveConfig";
this.groupBoxObjectParameters.ResumeLayout(false);
this.groupBoxObjectParameters.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
this.groupBoxColors.ResumeLayout(false);
this.panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxObjectParameters;
private Label labelModifiedObject;
private Label labelSimpleObject;
private Label labelWeight;
private Label labelSpeed;
private GroupBox groupBoxColors;
private CheckBox checkBoxSeifBatteries;
private CheckBox checkBoxHorns;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private FlowLayoutPanel panelPastelViolet;
private FlowLayoutPanel panelPastelLilac;
private FlowLayoutPanel panelSkyBlue;
private FlowLayoutPanel panelPastelGreen;
private FlowLayoutPanel panelPastelYellow;
private FlowLayoutPanel panelPastelOrange;
private FlowLayoutPanel panelPastelPink;
private FlowLayoutPanel panelPastelRed;
private Panel panelObject;
private PictureBox pictureBoxObject;
private Label labelAddColor;
private Label labelColor;
private Button ButtonOk;
private Button buttonCancel;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}

View File

@ -0,0 +1,186 @@
using ProjectElectricLocomotive.DrawingObjects;
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 ProjectElectricLocomotive
{
public partial class FormLocomotiveConfig : Form
{
/// <summary>
/// Переменная-выбранный локомотив
/// </summary>
DrawingLocomotive? _loco = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawingLocomotive>? EventAddLoco;
public FormLocomotiveConfig()
{
InitializeComponent();
panelPastelRed.MouseDown += PanelColor_MouseDown;
panelPastelPink.MouseDown += PanelColor_MouseDown;
panelPastelOrange.MouseDown += PanelColor_MouseDown;
panelPastelYellow.MouseDown += PanelColor_MouseDown;
panelSkyBlue.MouseDown += PanelColor_MouseDown;
panelPastelGreen.MouseDown += PanelColor_MouseDown;
panelPastelLilac.MouseDown += PanelColor_MouseDown;
panelPastelViolet.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawingLocomotive> ev)
{
if (EventAddLoco == null)
{
EventAddLoco = ev;
}
else
{
EventAddLoco += ev;
}
}
/// <summary>
/// Отрисовать Loco
/// </summary>
private void DrawLoco()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_loco?.SetPosition(10, 10);
_loco?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"><labelSimpleObject/param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_loco = new DrawingLocomotive(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
pictureBoxObject.Width,
pictureBoxObject.Height
);
break;
case "labelModifiedObject":
_loco = new DrawingElectricLocomotive(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
Color.Black,
checkBoxHorns.Checked,
checkBoxSeifBatteries.Checked,
pictureBoxObject.Width,
pictureBoxObject.Height
);
break;
}
DrawLoco();
}
// НЕ УВЕРЕНА, ЧТО ВЕРНО, драгдроп для цветов
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
switch (((Label)sender).Name)
{
case "labelColor":
_loco.SetColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAddColor":
if (_loco is not DrawingLocomotive) return;
else
{
(_loco as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color)));
}
break;
}
DrawLoco();
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Добавление loco
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddLoco?.Invoke(_loco);
Close();
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ElectricLocomotive;
using ProjectElectricLocomotive.DrawingObjects;
namespace ProjectElectricLocomotive.MovementStrategy
{
public interface IMoveableObject
{
ObjectParameters? GetObjectPosition { get; }
int GetStep { get; }
bool CheckCanMove(DirectionType direction);
void MoveObject(DirectionType direction);
}
}

View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawingObjects;
using ProjectElectricLocomotive.MovementStrategy;
namespace ProjectElectricLocomotive.Generics
{
internal class LocomotiveGenericCollection<T, U> where T : DrawingLocomotive where U : IMoveableObject
{
//ширина/высота окна
private readonly int _pictureWidth;
private readonly int _pictureHeight;
//ширина/высота занимаемого места
private readonly int _placeSizeWidth = 85;
private readonly int _placeSizeHeight = 50;
/// Набор объектов
private readonly SetGeneric<T> _collection;
public LocomotiveGenericCollection(int picWidth, int picHeight)
{
// немного странная логика, что-то я пока ее не особо понимаю, зачем нам ААААА дошло...
// высчитываем размер массива для setgeneric
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// Перегрузка оператора сложения
public static int operator +(LocomotiveGenericCollection<T, U> collect, T? loco)
{
if (loco == null)
{
return -1;
}
return collect._collection.Insert(loco);
}
/// Перегрузка оператора вычитания
public static T? operator -(LocomotiveGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection[pos];
if (obj != null)
{
collect._collection.Remove(pos);
}
return obj;
}
// получение объекта imoveableObj
public U? GetU(int pos)
{
return (U?)_collection[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 HeightObjCount = _pictureHeight / _placeSizeHeight;
for (int i = 0; i < _collection.Count; i++)
{
T? type = _collection[i];
if (type != null)
{
type.SetPosition(
(int)(i / HeightObjCount * _placeSizeWidth),
(HeightObjCount - 1) * _placeSizeHeight - (int)(i % HeightObjCount * _placeSizeHeight));
type?.DrawTransport(g);
}
}
}
}
}

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawingObjects;
using ProjectElectricLocomotive.MovementStrategy;
namespace ProjectElectricLocomotive.Generics
{
internal class LocomotiveGenericStorage
{
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> _locomotivesStorage;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
public List<string> Keys => _locomotivesStorage.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public LocomotiveGenericStorage(int pictureWidth, int pictureHeight)
{
_locomotivesStorage = new Dictionary<string, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление набора
/// </summary>
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
if (!_locomotivesStorage.ContainsKey(name))
{
_locomotivesStorage.Add(name, new LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(_pictureWidth, _pictureHeight));
}
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="name">Название набора</param>
public void DelSet(string name)
{
if (_locomotivesStorage.ContainsKey(name))
{
_locomotivesStorage.Remove(name);
}
}
/// <summary>
/// Доступ к набору
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>?
this[string ind]
{
get
{
if (_locomotivesStorage.ContainsKey(ind))
{
return _locomotivesStorage[ind];
}
return null;
}
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.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();
}
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.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();
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
/// Левая граница
public int LeftBorder => _x;
/// Верхняя граница
public int TopBorder => _y;
/// Правая граница
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;
}
}
}

View File

@ -1,4 +1,6 @@
namespace ProjectElectricLocomotive
using ProjectElectricLocomotive;
namespace ElectricLocomotive
{
internal static class Program
{
@ -11,7 +13,7 @@ namespace ProjectElectricLocomotive
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new FormLocomotiveCollections());
}
}
}

View File

@ -8,4 +8,19 @@
<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>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectElectricLocomotive.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("ProjectElectricLocomotive.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;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowDown {
get {
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowLeft {
get {
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight {
get {
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowUP {
get {
object obj = ResourceManager.GetObject("arrowUP", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowUP" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowUP.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,76 @@
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 List<T?> _places;
public int Count => _places.Count;
/// Максимальное количество объектов в списке
private readonly int _maxCount;
public SetGeneric(int count)
{
_maxCount = count;
_places = new List<T?>(count);
}
/// Добавление объекта в набор
public int Insert(T loco)
{
return Insert(loco, 0);
}
public int Insert(T loco, int position)
{
if (position < 0 || position >= _maxCount) return -1;
_places.Insert(position, loco);
return position;
}
public T? Remove(int position)
{
if (position >= Count || position < 0)
return null;
T? tmp = _places[position];
_places[position] = null;
return tmp;
}
public T? this[int position]
{
get
{
if (position < 0 || position >= Count) return null;
return _places[position];
}
set
{
if (position < 0 || position >= Count || Count == _maxCount) return;
_places.Insert(position, value);
}
}
/// <summary>
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetLocomotives(int? maxLocos = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxLocos.HasValue && i == maxLocos.Value)
{
yield break;
}
}
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
public enum Status
{
NotInit,
InProgress,
Finish
}
}