Compare commits
No commits in common. "LabWork08" and "main" have entirely different histories.
@ -1,85 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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,53 +0,0 @@
|
||||
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, weight, 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ProjectElectricLocomotive.Entities;
|
||||
|
||||
namespace ProjectElectricLocomotive.Generics
|
||||
{
|
||||
internal class DrawingLocoEqutables : IEqualityComparer<DrawingLocomotive?>
|
||||
{
|
||||
public bool Equals(DrawingLocomotive? x, DrawingLocomotive? y)
|
||||
{
|
||||
if (x == null || x.EntityLocomotive == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityLocomotive == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
return false;
|
||||
if (x.EntityLocomotive.Speed != y.EntityLocomotive.Speed)
|
||||
return false;
|
||||
if (x.EntityLocomotive.Weight != y.EntityLocomotive.Weight)
|
||||
return false;
|
||||
if (x.EntityLocomotive.BodyColor != y.EntityLocomotive.BodyColor)
|
||||
return false;
|
||||
// to do logic for "сравнения" additional parameters :)
|
||||
if (x is DrawingElectricLocomotive && y is DrawingElectricLocomotive)
|
||||
{
|
||||
if ((x.EntityLocomotive as EntityElectricLocomotive).AdditionalColor != (y.EntityLocomotive as EntityElectricLocomotive).AdditionalColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((x.EntityLocomotive as EntityElectricLocomotive).Horns != (y.EntityLocomotive as EntityElectricLocomotive).Horns)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((x.EntityLocomotive as EntityElectricLocomotive).SeifBatteries != (y.EntityLocomotive as EntityElectricLocomotive).SeifBatteries)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode([DisallowNull] DrawingLocomotive obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using ProjectElectricLocomotive.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Расширение для класса EntityLocomotive
|
||||
/// </summary>
|
||||
public static class ExtentionDrawingLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawingLocomotive? CreateDrawingLocomotive(this string info, char
|
||||
separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingLocomotive(
|
||||
Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]),
|
||||
width,
|
||||
height
|
||||
);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawingElectricLocomotive(
|
||||
Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]),
|
||||
Color.FromName(strs[3]),
|
||||
Convert.ToBoolean(strs[4]),
|
||||
Convert.ToBoolean(strs[5]),
|
||||
width,
|
||||
height
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningLoco">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawingLocomotive drawningLoco, char separatorForObject)
|
||||
{
|
||||
var loco = drawningLoco.EntityLocomotive;
|
||||
if (loco == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str =
|
||||
$"{loco.Speed}{separatorForObject}{loco.Weight}{separatorForObject}{loco.BodyColor.Name}";
|
||||
if (loco is not EntityElectricLocomotive electroLoco)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
$"{str}{separatorForObject}{electroLoco.AdditionalColor.Name}{separatorForObject}" +
|
||||
$"{electroLoco.Horns}{separatorForObject}{electroLoco.SeifBatteries}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
39
ProjectElectricLocomotive/ProjectElectricLocomotive/Form1.Designer.cs
generated
Normal file
39
ProjectElectricLocomotive/ProjectElectricLocomotive/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
||||
}
|
10
ProjectElectricLocomotive/ProjectElectricLocomotive/Form1.cs
Normal file
10
ProjectElectricLocomotive/ProjectElectricLocomotive/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,211 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,307 +0,0 @@
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
maskedTextBoxNumber = new MaskedTextBox();
|
||||
ButtonRefreshCollection = new Button();
|
||||
ButtonRemoveLocomotive = new Button();
|
||||
ButtonAddLocomotive = new Button();
|
||||
pictureBoxCollections = new PictureBox();
|
||||
textBoxStorageName = new TextBox();
|
||||
bindingSource1 = new BindingSource(components);
|
||||
bindingSource2 = new BindingSource(components);
|
||||
groupBox1 = new GroupBox();
|
||||
listBoxStorage = new ListBox();
|
||||
ButtonAddObject = new Button();
|
||||
ButtonRemoveObject = new Button();
|
||||
Instruments = new GroupBox();
|
||||
buttonSortByType = new Button();
|
||||
buttonSortByColor = new Button();
|
||||
menuStrip1 = new MenuStrip();
|
||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)bindingSource2).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
Instruments.SuspendLayout();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBoxNumber.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
maskedTextBoxNumber.Location = new Point(38, 417);
|
||||
maskedTextBoxNumber.Mask = "00";
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(156, 26);
|
||||
maskedTextBoxNumber.TabIndex = 4;
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonRefreshCollection.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
ButtonRefreshCollection.Location = new Point(38, 518);
|
||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
ButtonRefreshCollection.Size = new Size(150, 29);
|
||||
ButtonRefreshCollection.TabIndex = 2;
|
||||
ButtonRefreshCollection.Text = "Обновить все";
|
||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ButtonRemoveLocomotive
|
||||
//
|
||||
ButtonRemoveLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonRemoveLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
ButtonRemoveLocomotive.Location = new Point(38, 481);
|
||||
ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
|
||||
ButtonRemoveLocomotive.Size = new Size(150, 31);
|
||||
ButtonRemoveLocomotive.TabIndex = 1;
|
||||
ButtonRemoveLocomotive.Text = "Удалить локо";
|
||||
ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
|
||||
ButtonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click;
|
||||
//
|
||||
// ButtonAddLocomotive
|
||||
//
|
||||
ButtonAddLocomotive.Anchor = AnchorStyles.Top;
|
||||
ButtonAddLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
ButtonAddLocomotive.Location = new Point(38, 381);
|
||||
ButtonAddLocomotive.Name = "ButtonAddLocomotive";
|
||||
ButtonAddLocomotive.Size = new Size(150, 30);
|
||||
ButtonAddLocomotive.TabIndex = 0;
|
||||
ButtonAddLocomotive.Text = "Добавить локо";
|
||||
ButtonAddLocomotive.UseVisualStyleBackColor = true;
|
||||
ButtonAddLocomotive.Click += ButtonAddLocomotive_Click;
|
||||
//
|
||||
// pictureBoxCollections
|
||||
//
|
||||
pictureBoxCollections.Anchor = AnchorStyles.Left;
|
||||
pictureBoxCollections.Location = new Point(0, 31);
|
||||
pictureBoxCollections.Name = "pictureBoxCollections";
|
||||
pictureBoxCollections.Size = new Size(303, 523);
|
||||
pictureBoxCollections.TabIndex = 1;
|
||||
pictureBoxCollections.TabStop = false;
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(31, 28);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(149, 27);
|
||||
textBoxStorageName.TabIndex = 5;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(listBoxStorage);
|
||||
groupBox1.Controls.Add(ButtonAddObject);
|
||||
groupBox1.Controls.Add(ButtonRemoveObject);
|
||||
groupBox1.Controls.Add(textBoxStorageName);
|
||||
groupBox1.Location = new Point(7, 18);
|
||||
//groupBox1.Margin = new Padding(3, 4, 3, 4);
|
||||
groupBox1.Name = "groupBox1";
|
||||
//groupBox1.Padding = new Padding(3, 4, 3, 4);
|
||||
groupBox1.Size = new Size(216, 280);
|
||||
groupBox1.TabIndex = 5;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Наборы";
|
||||
//
|
||||
// listBoxStorage
|
||||
//
|
||||
listBoxStorage.FormattingEnabled = true;
|
||||
listBoxStorage.ItemHeight = 20;
|
||||
listBoxStorage.Location = new Point(31, 97);
|
||||
listBoxStorage.Margin = new Padding(3, 4, 3, 4);
|
||||
listBoxStorage.Name = "listBoxStorage";
|
||||
listBoxStorage.Size = new Size(149, 124);
|
||||
listBoxStorage.TabIndex = 9;
|
||||
listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
ButtonAddObject.Anchor = AnchorStyles.Top;
|
||||
ButtonAddObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
ButtonAddObject.Location = new Point(31, 62);
|
||||
ButtonAddObject.Name = "ButtonAddObject";
|
||||
ButtonAddObject.Size = new Size(149, 28);
|
||||
ButtonAddObject.TabIndex = 7;
|
||||
ButtonAddObject.Text = "Добавить набор";
|
||||
ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
ButtonAddObject.Click += ButtonAddObject_Click;
|
||||
//
|
||||
// ButtonRemoveObject
|
||||
//
|
||||
ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonRemoveObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
ButtonRemoveObject.Location = new Point(31, 238);
|
||||
ButtonRemoveObject.Name = "ButtonRemoveObject";
|
||||
ButtonRemoveObject.Size = new Size(149, 31);
|
||||
ButtonRemoveObject.TabIndex = 8;
|
||||
ButtonRemoveObject.Text = "Удалить набор";
|
||||
ButtonRemoveObject.UseVisualStyleBackColor = true;
|
||||
ButtonRemoveObject.Click += ButtonRemoveObject_Click;
|
||||
//
|
||||
// Instruments
|
||||
//
|
||||
Instruments.Anchor = AnchorStyles.Right;
|
||||
Instruments.Controls.Add(buttonSortByType);
|
||||
Instruments.Controls.Add(buttonSortByColor);
|
||||
Instruments.Controls.Add(ButtonRefreshCollection);
|
||||
Instruments.Controls.Add(groupBox1);
|
||||
Instruments.Controls.Add(maskedTextBoxNumber);
|
||||
Instruments.Controls.Add(ButtonAddLocomotive);
|
||||
Instruments.Controls.Add(ButtonRemoveLocomotive);
|
||||
Instruments.Location = new Point(302, 0);
|
||||
Instruments.Margin = new Padding(3, 4, 3, 4);
|
||||
Instruments.Name = "Instruments";
|
||||
Instruments.Padding = new Padding(3, 4, 3, 4);
|
||||
Instruments.Size = new Size(236, 554);
|
||||
Instruments.TabIndex = 6;
|
||||
Instruments.TabStop = false;
|
||||
Instruments.Text = "Инструменты";
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
buttonSortByType.Anchor = AnchorStyles.Top;
|
||||
buttonSortByType.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonSortByType.Location = new Point(44, 305);
|
||||
buttonSortByType.Name = "buttonSortByType";
|
||||
buttonSortByType.Size = new Size(150, 30);
|
||||
buttonSortByType.TabIndex = 7;
|
||||
buttonSortByType.Text = "Сортировать по типу";
|
||||
buttonSortByType.UseVisualStyleBackColor = true;
|
||||
buttonSortByType.Click += buttonSortByType_Click;
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
buttonSortByColor.Anchor = AnchorStyles.Top;
|
||||
buttonSortByColor.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
buttonSortByColor.Location = new Point(25, 341);
|
||||
buttonSortByColor.Name = "buttonSortByColor";
|
||||
buttonSortByColor.Size = new Size(181, 30);
|
||||
buttonSortByColor.TabIndex = 6;
|
||||
buttonSortByColor.Text = "Сортировать по цвету";
|
||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
buttonSortByColor.Click += buttonSortByColor_Click;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(538, 28);
|
||||
menuStrip1.TabIndex = 7;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
файлToolStripMenuItem.Size = new Size(59, 24);
|
||||
файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.Size = new Size(166, 26);
|
||||
SaveToolStripMenuItem.Text = "Сохранить";
|
||||
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
LoadToolStripMenuItem.Size = new Size(166, 26);
|
||||
LoadToolStripMenuItem.Text = "Загрузить";
|
||||
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog1";
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormLocomotiveCollections
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(538, 554);
|
||||
Controls.Add(Instruments);
|
||||
Controls.Add(pictureBoxCollections);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormLocomotiveCollections";
|
||||
Text = "Набор локомотивов";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)bindingSource2).EndInit();
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
Instruments.ResumeLayout(false);
|
||||
Instruments.PerformLayout();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
private void ButtonSortByColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#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;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button buttonSortByType;
|
||||
private Button buttonSortByColor;
|
||||
}
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using ProjectElectricLocomotive.Exceptions;
|
||||
using ProjectElectricLocomotive.Generics;
|
||||
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public partial class FormLocomotiveCollections : Form
|
||||
{
|
||||
private readonly LocomotiveGenericStorage _storage;
|
||||
/// <summary>
|
||||
/// Логер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
public FormLocomotiveCollections(ILogger<FormLocomotiveCollections> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new LocomotiveGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
_logger.LogWarning("Неудачная попытка. Коллекция не добавлена, не все данные заполнены");
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text.ToString());
|
||||
ReloadObjects();
|
||||
|
||||
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(name);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Набор '{name}' удален");
|
||||
}
|
||||
_logger.LogWarning("Отмена удаления набора");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (obj + loco > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollections.Image = obj.ShowLocomotives();
|
||||
_logger.LogInformation($"Добавлен объект {obj}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogWarning("Переполнение коллекции");
|
||||
}
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
//проверяем, удалось ли нам загрузить объект
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_logger.LogWarning("Отмена удаления объекта");
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
try
|
||||
{
|
||||
var removeObj = obj - pos;
|
||||
if (removeObj != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation($"Удален объект с позиции{pos}");
|
||||
pictureBoxCollections.Image = obj.ShowLocomotives();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
catch (LocoNotFoundException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning($"Не найден объект по позиции: {obj}");
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Сохранение"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
_logger.LogInformation($"Данные загружены в файл {saveFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogWarning($"Не удалось сохранить информацию в файл: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Загрузка"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO продумать логику
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.LoadData(openFileDialog.FileName);
|
||||
_logger.LogInformation($"Данные загружены из файла {openFileDialog.FileName}");
|
||||
ReloadObjects();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogWarning($"Не удалось загрузить информацию из файла: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSortByType_Click(object sender, EventArgs e) => CompareLocos(new LocoCompareByType());
|
||||
|
||||
private void buttonSortByColor_Click(object sender, EventArgs e) => CompareLocos(new LocoCompareByColor());
|
||||
|
||||
public void CompareLocos(IComparer<DrawingLocomotive?> comparer)
|
||||
{
|
||||
if (listBoxStorage.SelectedIndex == -1) return;
|
||||
|
||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||
if(obj == null) return;
|
||||
|
||||
obj.Sort(comparer);
|
||||
pictureBoxCollections.Image = obj.ShowLocomotives();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,138 +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>
|
||||
<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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>318, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>453, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>615, 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>
|
@ -1,394 +0,0 @@
|
||||
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.Plum;
|
||||
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.RoyalBlue;
|
||||
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.Turquoise;
|
||||
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.PaleGreen;
|
||||
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.LightYellow;
|
||||
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.PeachPuff;
|
||||
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.LightSalmon;
|
||||
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.Red;
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,184 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление loco
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddLoco?.Invoke(_loco);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<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>
|
@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using ProjectElectricLocomotive.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
internal class LocoCompareByColor : IComparer<DrawingLocomotive?>
|
||||
{
|
||||
public int Compare(DrawingLocomotive? x, DrawingLocomotive? y)
|
||||
{
|
||||
|
||||
if (x == null || x.EntityLocomotive == null)
|
||||
throw new NotImplementedException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityLocomotive == null)
|
||||
throw new NotImplementedException(nameof(y));
|
||||
|
||||
var bodyColor = x.EntityLocomotive.BodyColor.Name.CompareTo(y.EntityLocomotive.BodyColor.Name);
|
||||
|
||||
if (bodyColor != 0) return bodyColor;
|
||||
|
||||
if(x.EntityLocomotive is EntityElectricLocomotive &&
|
||||
y.EntityLocomotive is EntityElectricLocomotive)
|
||||
{
|
||||
var addcolor = (x.EntityLocomotive as EntityElectricLocomotive).AdditionalColor.Name.CompareTo((y.EntityLocomotive
|
||||
as EntityElectricLocomotive).AdditionalColor.Name);
|
||||
if(addcolor != 0) return addcolor;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
internal class LocoCompareByType : IComparer<DrawingLocomotive?>
|
||||
{
|
||||
public int Compare(DrawingLocomotive? x, DrawingLocomotive? y)
|
||||
{
|
||||
if (x == null || x.EntityLocomotive == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityLocomotive == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
}
|
||||
var speedCompare = x.EntityLocomotive.Speed.CompareTo(y.EntityLocomotive.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityLocomotive.Weight.CompareTo(y.EntityLocomotive.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
|
||||
internal class LocoNotFoundException : ApplicationException
|
||||
{
|
||||
public LocoNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public LocoNotFoundException() : base() { }
|
||||
public LocoNotFoundException(string message) : base(message) { }
|
||||
public LocoNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected LocoNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetLocomotives => _collection.GetLocomotives();
|
||||
|
||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||
|
||||
|
||||
//ширина/высота окна
|
||||
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, new DrawingLocoEqutables());
|
||||
}
|
||||
|
||||
/// Перегрузка оператора вычитания
|
||||
public static T? operator -(LocomotiveGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using ProjectElectricLocomotive.MovementStrategy;
|
||||
|
||||
namespace ProjectElectricLocomotive.Generics
|
||||
{
|
||||
internal class LocomotiveGenericStorage
|
||||
{
|
||||
//create lab 7
|
||||
/// <summary>
|
||||
/// Словарь (хранилище)
|
||||
/// </summary>
|
||||
readonly Dictionary<LocosCollectionInfo, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> _locomotivesStorage;
|
||||
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<LocosCollectionInfo> 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<LocosCollectionInfo, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void AddSet(string name)
|
||||
{
|
||||
if (!_locomotivesStorage.ContainsKey(new LocosCollectionInfo(name, "")))
|
||||
{
|
||||
_locomotivesStorage.Add(new LocosCollectionInfo(name, ""),
|
||||
new LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (_locomotivesStorage.ContainsKey(new LocosCollectionInfo(name, "")))
|
||||
{
|
||||
_locomotivesStorage.Remove(new LocosCollectionInfo(name, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>?
|
||||
this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_locomotivesStorage.ContainsKey(new LocosCollectionInfo(ind, "")))
|
||||
{
|
||||
return _locomotivesStorage[new LocosCollectionInfo(ind, "")];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly char _separatorRecords = ';';
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение информации по автомобилям в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<LocosCollectionInfo, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> record in _locomotivesStorage)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingLocomotive? elem in record.Value.GetLocomotives)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new Exception("Нет данных для записи, ошибка");
|
||||
}
|
||||
using StreamWriter fs = new StreamWriter(filename);
|
||||
{
|
||||
fs.WriteLine($"LocomotiveStorage{Environment.NewLine}");
|
||||
fs.WriteLine(data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка информации по автомобилям в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
|
||||
using (StreamReader fs = File.OpenText(filename))
|
||||
{
|
||||
|
||||
string str = fs.ReadLine();
|
||||
|
||||
if (str == null || str.Length == 0)
|
||||
{
|
||||
throw new IOException("Нет данных для загрузки");
|
||||
}
|
||||
|
||||
if (!str.StartsWith("LocomotiveStorage"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
throw new FileFormatException("Неверный формат данных");
|
||||
}
|
||||
|
||||
_locomotivesStorage.Clear();
|
||||
string strs = "";
|
||||
|
||||
|
||||
while ((strs = fs.ReadLine()) != null)
|
||||
{
|
||||
|
||||
if (strs == null)
|
||||
{
|
||||
throw new FileNotFoundException("Нет данных для загрузки");
|
||||
}
|
||||
|
||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set/*.Reverse()*/)
|
||||
{
|
||||
DrawingLocomotive? loco = elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (loco != null)
|
||||
{
|
||||
if ((collection + loco) == -1) // for my realization it's -1, for eegov's realization it's boolean
|
||||
{
|
||||
throw new Exception("Ошибка добавления ");
|
||||
}
|
||||
}
|
||||
}
|
||||
_locomotivesStorage.Add(new LocosCollectionInfo(record[0], string.Empty), collection);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public class LocosCollectionInfo : IEquatable<LocosCollectionInfo>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public LocosCollectionInfo(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public bool Equals(LocosCollectionInfo other)
|
||||
{
|
||||
if (Name != other?.Name)
|
||||
//throw new NotImplementedException(nameof(Name));
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Name.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
internal static class Program
|
||||
@ -16,30 +11,7 @@ namespace ProjectElectricLocomotive
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormLocomotiveCollections>());
|
||||
}
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormLocomotiveCollections>()
|
||||
.AddLogging(option =>
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(path: "C:\\Users\\katri\\OneDrive\\Ðàáî÷èé ñòîë\\ÂÒÎÐÎÉ ÊÓÐÑ\\ÐÏÏ\\PIbd-21_Bakalskaya_E.D._ElectricLocomotive._BASE\\ProjectElectricLocomotive\\ProjectElectricLocomotive\\appSettings.json", optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
|
||||
var logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,42 +8,4 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="nlog.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<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,103 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,133 +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.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.
Before Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
@ -1,110 +0,0 @@
|
||||
using ProjectElectricLocomotive.Exceptions;
|
||||
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 void SortSet(IComparer<T?> comparer) =>_places.Sort(comparer);
|
||||
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
|
||||
/// Добавление объекта в набор
|
||||
public int Insert(T loco, IEqualityComparer<T?>? equal = null)
|
||||
{
|
||||
if (equal != null)
|
||||
{
|
||||
foreach (var secondLoco in _places)
|
||||
{
|
||||
if (equal.Equals(loco, secondLoco))
|
||||
{
|
||||
throw new Exception("Такой объект уже есть в коллекции");
|
||||
}
|
||||
}
|
||||
}
|
||||
return Insert(loco, 0);
|
||||
}
|
||||
|
||||
public int Insert(T loco, int position, IEqualityComparer<T?>? equal = null)
|
||||
{
|
||||
if(_places.Count >= _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(equal != null)
|
||||
{
|
||||
foreach (var secondLoco in _places)
|
||||
{
|
||||
if(equal.Equals(loco, secondLoco))
|
||||
{
|
||||
throw new ApplicationException("Такой объект уже есть в коллекции");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_places.Insert(position, loco);
|
||||
return position;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (position >= Count || position < 0)
|
||||
return null;
|
||||
|
||||
T? tmp = _places[position];
|
||||
if (tmp == null)
|
||||
throw new LocoNotFoundException(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
[Serializable]
|
||||
internal class StorageOverflowException : ApplicationException
|
||||
{
|
||||
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
||||
public StorageOverflowException() : base() { }
|
||||
public StorageOverflowException(string message) : base(message) { }
|
||||
public StorageOverflowException(string message, Exception exception) : base(message, exception) { }
|
||||
protected StorageOverflowException(SerializationInfo info,
|
||||
StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "Locomotives"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="locolog-${shortdate}.log" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
||||
|
Loading…
x
Reference in New Issue
Block a user