Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
0014705a2f | |||
3cd45efd33 | |||
bafc5fc52a | |||
471df50dbc | |||
3ebd0c11b2 | |||
342c0055b5 | |||
8a7569da0d | |||
bd2452b603 | |||
fd34991f2e | |||
6a5b97bdd0 | |||
ed6ba9c2af | |||
54f7347305 | |||
c5c3f60f77 | |||
610b165409 | |||
a4f6cf4be8 |
25
Excavator.sln
Normal file
25
Excavator.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34024.191
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Excavator", "Excavator\Excavator.csproj", "{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7F269221-EAB0-4961-A192-4F793DC88242}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
74
Excavator/AbstractStrategy.cs
Normal file
74
Excavator/AbstractStrategy.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Excavator.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
using Excavator.DrawingObjects;
|
||||
|
||||
namespace Excavator.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;
|
||||
}
|
||||
}
|
||||
}
|
16
Excavator/Direction.cs
Normal file
16
Excavator/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
internal enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
16
Excavator/DirectionType.cs
Normal file
16
Excavator/DirectionType.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
49
Excavator/Drawing/DrawingExcavator.cs
Normal file
49
Excavator/Drawing/DrawingExcavator.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.Drawing
|
||||
{
|
||||
public class DrawingExcavator : DrawingMash
|
||||
{
|
||||
public DrawingExcavator(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports, int width, int height) : base(speed, weight, bodyColor, width, height, 180, 110)
|
||||
{
|
||||
if (EntityMash != null)
|
||||
{
|
||||
EntityMash = new EntityExcavator(speed, weight, bodyColor, additionalColor, bucket, supports);
|
||||
}
|
||||
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityMash is not EntityExcavator Excavator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Pen additionalPen = new(Excavator.AddColor);
|
||||
Brush additionalBrush = new SolidBrush(Excavator.AddColor);
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (Excavator.IsBucket)
|
||||
{
|
||||
Brush additionalBrush2 = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 42, 20, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 5, _startPosY + 37, 10, 50);
|
||||
}
|
||||
|
||||
if (Excavator.IsSupports)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 170, _startPosY + 47, 25, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 180, _startPosY + 27, 15, 45);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 175, _startPosY + 72, 25, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
146
Excavator/Drawing/DrawingMash.cs
Normal file
146
Excavator/Drawing/DrawingMash.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Entities;
|
||||
using Excavator.Move_Strategy;
|
||||
|
||||
namespace Excavator.Drawing
|
||||
{
|
||||
public class DrawingMash
|
||||
{
|
||||
public IMoveableObject GetMoveableObject => new DrawingObjectMash(this);
|
||||
public EntityMash? EntityMash { get; protected set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _mashWidth = 175;
|
||||
protected readonly int _mashHeight = 115;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _mashWidth;
|
||||
public int GetHeight => _mashHeight;
|
||||
public DrawingMash(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingMash(int speed, double weight, Color bodyColor, int width, int height, int mashWidth, int mashHeight)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_mashWidth = mashWidth;
|
||||
_mashHeight = mashHeight;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x > _pictureWidth || y > _pictureHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityMash.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityMash.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _mashWidth + EntityMash.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _mashHeight + EntityMash.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 30, _startPosY + 31, 140, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY + 2, 15, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 125, _startPosY + 2, 40, 40);
|
||||
|
||||
Brush additionalBrush1 = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
Brush gr = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 20, _startPosY + 72, 25, 25);
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 145, _startPosY + 72, 25, 25);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 55, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 85, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 110, _startPosY + 81, 17, 17);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 68, _startPosY + 72, 8, 8);
|
||||
g.FillEllipse(gr, _startPosX + 95, _startPosY + 72, 8, 8);
|
||||
|
||||
Pen blackPen = new Pen(Color.Black, 3);
|
||||
Rectangle rect1 = new Rectangle(_startPosX + 15, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect1, 90, 180);
|
||||
Rectangle rect2 = new Rectangle(_startPosX + 145, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect2, -90, 180);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 69, _startPosX + 165, _startPosY + 69);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 99, _startPosX + 165, _startPosY + 99);
|
||||
}
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityMash == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityMash.Step > 0,
|
||||
DirectionType.Up => _startPosY - EntityMash.Step > 0,
|
||||
DirectionType.Right => _startPosX + _mashWidth + EntityMash.Step < _pictureWidth,
|
||||
DirectionType.Down => _startPosY + _mashHeight + EntityMash.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
public void ChangeBordersPicture(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
48
Excavator/Drawing/ExtentionDrawingMash.cs
Normal file
48
Excavator/Drawing/ExtentionDrawingMash.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.Drawing
|
||||
{
|
||||
public static class ExtentionDrawingMash
|
||||
{
|
||||
public static DrawingMash? CreateDrawingMash(this string info, char separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingMash(
|
||||
Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawingExcavator(
|
||||
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;
|
||||
}
|
||||
public static string GetDataForSave(this DrawingMash DrawingMash, char separatorForObject)
|
||||
{
|
||||
var truck = DrawingMash.EntityMash;
|
||||
if (truck == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{truck.Speed}{separatorForObject}{truck.Weight}{separatorForObject}{truck.BodyColor.Name}";
|
||||
if (truck is not EntityExcavator Excavator)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{separatorForObject}{Excavator.AddColor.Name}{separatorForObject}{Excavator.IsBucket}{separatorForObject}{Excavator.IsSupports}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
137
Excavator/DrawingExc.cs
Normal file
137
Excavator/DrawingExc.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
internal class DrawingExc
|
||||
{
|
||||
public EntityExcavator? EntityExcavator { get; private set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
private readonly int _excWidth = 200;
|
||||
private readonly int _excHeight = 124;
|
||||
public bool Init(EntityExcavator bus, int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityExcavator = bus;
|
||||
if (_pictureWidth < _excWidth || _pictureHeight < _excHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
if (_startPosX + _excWidth > _pictureWidth) {
|
||||
_startPosX = _pictureWidth - _excWidth;
|
||||
}
|
||||
if (_startPosX < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
if (_startPosY + _excHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight - _excHeight;
|
||||
}
|
||||
if (_startPosY < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
}
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (EntityExcavator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Left:
|
||||
if (_startPosX - EntityExcavator.Step > -17)
|
||||
{
|
||||
_startPosX -= (int)EntityExcavator.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Up:
|
||||
if (_startPosY - EntityExcavator.Step > -35)
|
||||
{
|
||||
_startPosY -= (int)EntityExcavator.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
if (_startPosX + EntityExcavator.Step + _excWidth + 14 < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityExcavator.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_startPosY + EntityExcavator.Step + _excHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityExcavator.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityExcavator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityExcavator.AdditionalColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 40, _startPosY + 60, 140, 35); //маленький
|
||||
g.FillRectangle(additionalBrush, _startPosX + 70, _startPosY + 30, 15, 35); //2
|
||||
g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 30, 40, 40); //большой прямоугольник 2
|
||||
|
||||
Brush additionalBrush1 = new
|
||||
SolidBrush(EntityExcavator.AdditionalColor);
|
||||
if (EntityExcavator.bucket)
|
||||
{
|
||||
Brush additionalBrush2 = new
|
||||
SolidBrush(EntityExcavator.AdditionalColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 70, 20, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 65, 15, 50);
|
||||
|
||||
}
|
||||
if (EntityExcavator.Support)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 170, _startPosY + 75, 35, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 200, _startPosY + 55, 15, 45);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 195, _startPosY + 100, 30, 5);
|
||||
}
|
||||
Brush gr = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 30, _startPosY + 100, 25, 25);
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 155, _startPosY + 100, 25, 25);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 65, _startPosY + 108, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 95, _startPosY + 108, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 120, _startPosY + 108, 17, 17);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 83, _startPosY + 100, 8, 8);
|
||||
g.FillEllipse(gr, _startPosX + 110, _startPosY + 100, 8, 8);
|
||||
|
||||
Pen blackPen = new Pen(Color.Black, 3);
|
||||
Rectangle rect1 = new Rectangle(_startPosX + 25, _startPosY + 97, 30, 30);
|
||||
g.DrawArc(blackPen, rect1, 90, 180);
|
||||
Rectangle rect2 = new Rectangle(_startPosX + 155, _startPosY + 97, 30, 30);
|
||||
g.DrawArc(blackPen, rect2, -90, 180);
|
||||
g.DrawLine(blackPen, _startPosX + 37, _startPosY + 97, _startPosX + 175, _startPosY + 97);
|
||||
g.DrawLine(blackPen, _startPosX + 37, _startPosY + 127, _startPosX + 175, _startPosY + 127);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
49
Excavator/DrawingExcavator.cs
Normal file
49
Excavator/DrawingExcavator.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Excavator.DrawingObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public class DrawingExcavator : DrawingMash
|
||||
{
|
||||
public DrawingExcavator(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports, int width, int height) : base(speed, weight, bodyColor, width, height, 180, 110)
|
||||
{
|
||||
if (EntityMash != null)
|
||||
{
|
||||
EntityMash = new EntityExcavator(speed, weight, bodyColor, additionalColor, bucket, supports);
|
||||
}
|
||||
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityMash is not EntityExcavator Excavator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Pen additionalPen = new(Excavator.Body);
|
||||
Brush additionalBrush = new SolidBrush(Excavator.Body);
|
||||
base.DrawTransport(g);
|
||||
if (Excavator.bucket)
|
||||
{
|
||||
Brush additionalBrush2 = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 42, 20, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 5, _startPosY + 37, 10, 50);
|
||||
}
|
||||
|
||||
if (Excavator.supports)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 170, _startPosY + 47, 25, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 180, _startPosY + 27, 15, 45);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 175, _startPosY + 72, 25, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
138
Excavator/DrawingMahs.cs
Normal file
138
Excavator/DrawingMahs.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.DrawingObjects
|
||||
{
|
||||
public class DrawingMash
|
||||
{
|
||||
public EntityMash? EntityMash { get; protected set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _mashWidth = 150;
|
||||
protected readonly int _mashHeight = 95;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _mashWidth;
|
||||
public int GetHeight => _mashHeight;
|
||||
public DrawingMash(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingMash(int speed, double weight, Color bodyColor, int width, int height, int mashWidth, int mashHeight)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_mashWidth = mashWidth;
|
||||
_mashHeight = mashHeight;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x > _pictureWidth || y > _pictureHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityMash.Step > -50)
|
||||
{
|
||||
_startPosX -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityMash.Step > -35)
|
||||
{
|
||||
_startPosY -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _mashWidth + EntityMash.Step < _pictureWidth + 14)
|
||||
{
|
||||
_startPosX += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _mashHeight + EntityMash.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 30, _startPosY + 31, 140, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY + 2, 15, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 125, _startPosY + 2, 40, 40);
|
||||
|
||||
Brush additionalBrush1 = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
Brush gr = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 20, _startPosY + 72, 25, 25);
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 145, _startPosY + 72, 25, 25);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 55, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 85, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 110, _startPosY + 81, 17, 17);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 68, _startPosY + 72, 8, 8);
|
||||
g.FillEllipse(gr, _startPosX + 95, _startPosY + 72, 8, 8);
|
||||
|
||||
Pen blackPen = new Pen(Color.Black, 3);
|
||||
Rectangle rect1 = new Rectangle(_startPosX + 15, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect1, 90, 180);
|
||||
Rectangle rect2 = new Rectangle(_startPosX + 145, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect2, -90, 180);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 69, _startPosX + 165, _startPosY + 69);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 99, _startPosX + 165, _startPosY + 99);
|
||||
}
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityMash == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityMash.Step > 0,
|
||||
DirectionType.Up => _startPosY - EntityMash.Step > 0,
|
||||
DirectionType.Right => _startPosX + _mashWidth + EntityMash.Step < _pictureWidth,
|
||||
DirectionType.Down => _startPosY + _mashHeight + EntityMash.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
140
Excavator/DrawingMash.cs
Normal file
140
Excavator/DrawingMash.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Entities;
|
||||
using Excavator.MovementStrategy;
|
||||
|
||||
namespace Excavator.DrawingObjects
|
||||
{
|
||||
public class DrawingMash
|
||||
{
|
||||
public IMoveableObject GetMoveableObject => new DrawingObjectMash(this);
|
||||
public EntityMash? EntityMash { get; protected set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _mashWidth = 175;
|
||||
protected readonly int _mashHeight = 115;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _mashWidth;
|
||||
public int GetHeight => _mashHeight;
|
||||
public DrawingMash(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingMash(int speed, double weight, Color bodyColor, int width, int height, int mashWidth, int mashHeight)
|
||||
{
|
||||
if (width < _mashWidth || height < _mashHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_mashWidth = mashWidth;
|
||||
_mashHeight = mashHeight;
|
||||
EntityMash = new EntityMash(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x > _pictureWidth || y > _pictureHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityMash.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityMash.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _mashWidth + EntityMash.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _mashHeight + EntityMash.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMash.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 30, _startPosY + 31, 140, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY + 2, 15, 35);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 125, _startPosY + 2, 40, 40);
|
||||
|
||||
Brush additionalBrush1 = new
|
||||
SolidBrush(EntityMash.BodyColor);
|
||||
|
||||
Brush gr = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 20, _startPosY + 72, 25, 25);
|
||||
g.FillEllipse(additionalBrush1, _startPosX + 145, _startPosY + 72, 25, 25);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 55, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 85, _startPosY + 81, 17, 17);
|
||||
g.FillEllipse(gr, _startPosX + 110, _startPosY + 81, 17, 17);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 68, _startPosY + 72, 8, 8);
|
||||
g.FillEllipse(gr, _startPosX + 95, _startPosY + 72, 8, 8);
|
||||
|
||||
Pen blackPen = new Pen(Color.Black, 3);
|
||||
Rectangle rect1 = new Rectangle(_startPosX + 15, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect1, 90, 180);
|
||||
Rectangle rect2 = new Rectangle(_startPosX + 145, _startPosY + 69, 30, 30);
|
||||
g.DrawArc(blackPen, rect2, -90, 180);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 69, _startPosX + 165, _startPosY + 69);
|
||||
g.DrawLine(blackPen, _startPosX + 27, _startPosY + 99, _startPosX + 165, _startPosY + 99);
|
||||
}
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityMash == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityMash.Step > 0,
|
||||
DirectionType.Up => _startPosY - EntityMash.Step > 0,
|
||||
DirectionType.Right => _startPosX + _mashWidth + EntityMash.Step < _pictureWidth,
|
||||
DirectionType.Down => _startPosY + _mashHeight + EntityMash.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
35
Excavator/DrawingObjectMash.cs
Normal file
35
Excavator/DrawingObjectMash.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Excavator.MovementStrategy;
|
||||
using Excavator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.DrawingObjects;
|
||||
namespace Excavator.MovementStrategy
|
||||
{
|
||||
public class DrawingObjectMash : IMoveableObject
|
||||
{
|
||||
private readonly DrawingMash? _drawingMash = null;
|
||||
public DrawingObjectMash(DrawingMash drawingMash)
|
||||
{
|
||||
_drawingMash = drawingMash;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawingMash == null || _drawingMash.EntityMash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawingMash.GetPosX,_drawingMash.GetPosY, _drawingMash.GetWidth, _drawingMash.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawingMash?.EntityMash?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) => _drawingMash?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) => _drawingMash?.MoveTransport(direction);
|
||||
}
|
||||
}
|
17
Excavator/Entities/DirectionType.cs
Normal file
17
Excavator/Entities/DirectionType.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Entities
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
|
||||
}
|
||||
}
|
28
Excavator/Entities/EntityExcavator.cs
Normal file
28
Excavator/Entities/EntityExcavator.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Excavator.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Entities
|
||||
{
|
||||
public class EntityExcavator : EntityMash
|
||||
{
|
||||
public Color AddColor { get; private set; }
|
||||
public bool IsBucket { get; private set; }
|
||||
public bool IsSupports { get; private set; }
|
||||
|
||||
public EntityExcavator(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AddColor = additionalColor;
|
||||
IsBucket = bucket;
|
||||
IsSupports = supports;
|
||||
}
|
||||
|
||||
public void ChangeAdditionalColor(Color additionalColor)
|
||||
{
|
||||
AddColor = additionalColor;
|
||||
}
|
||||
}
|
||||
}
|
27
Excavator/Entities/EntityMash.cs
Normal file
27
Excavator/Entities/EntityMash.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Entities
|
||||
{
|
||||
public class EntityMash
|
||||
{
|
||||
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 EntityMash(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void ChangeBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
22
Excavator/EntityExcavator.cs
Normal file
22
Excavator/EntityExcavator.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Excavator.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Entities
|
||||
{
|
||||
public class EntityExcavator : EntityMash
|
||||
{
|
||||
public Color Body { get; private set; }
|
||||
public bool bucket { get; private set; }
|
||||
public bool supports { get; private set; }
|
||||
public EntityExcavator(int speed, double weight, Color bodyColor, Color additionalColor, bool Bucket, bool Supports) : base(speed, weight, bodyColor)
|
||||
{
|
||||
Body = additionalColor;
|
||||
bucket = Bucket;
|
||||
supports = Supports;
|
||||
}
|
||||
}
|
||||
}
|
22
Excavator/EntityMash.cs
Normal file
22
Excavator/EntityMash.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Entities
|
||||
{
|
||||
public class EntityMash
|
||||
{
|
||||
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 EntityMash(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
31
Excavator/Excavator.cs
Normal file
31
Excavator/Excavator.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public class EntityExcavator
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool Support { get; private set; }
|
||||
public bool bucket { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool support, bool bucket)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
|
||||
Support = support;
|
||||
this.bucket = bucket;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
40
Excavator/Excavator.csproj
Normal file
40
Excavator/Excavator.csproj
Normal file
@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.7" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||
<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>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties serilog_1json__JsonSchema="https://dstack-runner-downloads.s3.eu-west-1.amazonaws.com/latest/schemas/configuration.json" /></VisualStudio></ProjectExtensions>
|
||||
|
||||
</Project>
|
19
Excavator/Exceptions/MashNotFoundException.cs
Normal file
19
Excavator/Exceptions/MashNotFoundException.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Excavator.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
internal class MashNotFoundException : ApplicationException
|
||||
{
|
||||
public MashNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public MashNotFoundException() : base() { }
|
||||
public MashNotFoundException(string message) : base(message) { }
|
||||
public MashNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected MashNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
19
Excavator/Exceptions/StorageOverflowException.cs
Normal file
19
Excavator/Exceptions/StorageOverflowException.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Excavator.Exceptions
|
||||
{
|
||||
[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 context) : base(info, context) { }
|
||||
}
|
||||
}
|
177
Excavator/FormExcavator.Designer.cs
generated
Normal file
177
Excavator/FormExcavator.Designer.cs
generated
Normal file
@ -0,0 +1,177 @@
|
||||
namespace Excavator
|
||||
{
|
||||
partial class FormExcavator
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
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.pictureBoxExcavator = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreateExcavator = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||
this.buttonStep = new System.Windows.Forms.Button();
|
||||
this.buttonCreateMash = new System.Windows.Forms.Button();
|
||||
this.buttonSelect = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxExcavator
|
||||
//
|
||||
this.pictureBoxExcavator.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxExcavator.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxExcavator.Name = "pictureBoxExcavator";
|
||||
this.pictureBoxExcavator.Size = new System.Drawing.Size(882, 453);
|
||||
this.pictureBoxExcavator.TabIndex = 5;
|
||||
this.pictureBoxExcavator.TabStop = false;
|
||||
//
|
||||
// buttonCreateExcavator
|
||||
//
|
||||
this.buttonCreateExcavator.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateExcavator.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.buttonCreateExcavator.Location = new System.Drawing.Point(11, 365);
|
||||
this.buttonCreateExcavator.Name = "buttonCreateExcavator";
|
||||
this.buttonCreateExcavator.Size = new System.Drawing.Size(120, 73);
|
||||
this.buttonCreateExcavator.TabIndex = 6;
|
||||
this.buttonCreateExcavator.Text = "Создать Экскаватор";
|
||||
this.buttonCreateExcavator.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateExcavator.Click += new System.EventHandler(this.buttonCreateExcavator_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(811, 377);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 29);
|
||||
this.buttonUp.TabIndex = 7;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(776, 413);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 29);
|
||||
this.buttonLeft.TabIndex = 8;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(811, 413);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 29);
|
||||
this.buttonDown.TabIndex = 9;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(848, 413);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 29);
|
||||
this.buttonRight.TabIndex = 10;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// 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[] {
|
||||
"В центр",
|
||||
"В правый нижний угол"});
|
||||
this.comboBoxStrategy.Location = new System.Drawing.Point(719, 12);
|
||||
this.comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBoxStrategy.TabIndex = 11;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonStep.Location = new System.Drawing.Point(747, 45);
|
||||
this.buttonStep.Name = "buttonStep";
|
||||
this.buttonStep.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonStep.TabIndex = 12;
|
||||
this.buttonStep.Text = "Шаг";
|
||||
this.buttonStep.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonCreateMash
|
||||
//
|
||||
this.buttonCreateMash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateMash.Location = new System.Drawing.Point(138, 365);
|
||||
this.buttonCreateMash.Name = "buttonCreateMash";
|
||||
this.buttonCreateMash.Size = new System.Drawing.Size(120, 74);
|
||||
this.buttonCreateMash.TabIndex = 13;
|
||||
this.buttonCreateMash.Text = "Создать Гусеничную Машину";
|
||||
this.buttonCreateMash.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateMash.Click += new System.EventHandler(this.buttonCreateMash_Click);
|
||||
//
|
||||
// buttonSelect
|
||||
//
|
||||
this.buttonSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonSelect.Location = new System.Drawing.Point(273, 365);
|
||||
this.buttonSelect.Name = "buttonSelect";
|
||||
this.buttonSelect.Size = new System.Drawing.Size(120, 73);
|
||||
this.buttonSelect.TabIndex = 14;
|
||||
this.buttonSelect.Text = "Выбрать объект";
|
||||
this.buttonSelect.UseVisualStyleBackColor = true;
|
||||
this.buttonSelect.Click += new System.EventHandler(this.buttonSelect_Click);
|
||||
//
|
||||
// FormExcavator
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(882, 453);
|
||||
this.Controls.Add(this.buttonSelect);
|
||||
this.Controls.Add(this.buttonCreateMash);
|
||||
this.Controls.Add(this.buttonStep);
|
||||
this.Controls.Add(this.comboBoxStrategy);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonCreateExcavator);
|
||||
this.Controls.Add(this.pictureBoxExcavator);
|
||||
this.Name = "FormExcavator";
|
||||
this.Text = "Экскаватор";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxExcavator;
|
||||
private Button buttonCreateExcavator;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStep;
|
||||
private Button buttonCreateMash;
|
||||
private Button buttonSelect;
|
||||
}
|
||||
}
|
137
Excavator/FormExcavator.cs
Normal file
137
Excavator/FormExcavator.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Entities;
|
||||
using Excavator.Move_Strategy;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
|
||||
public partial class FormExcavator : Form
|
||||
{
|
||||
private DrawingMash? _DrawingMash;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawingMash? Selectedmash { get; private set; }
|
||||
|
||||
public FormExcavator()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
Selectedmash = null;
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_DrawingMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxExcavator.Width, pictureBoxExcavator.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_DrawingMash.DrawTransport(gr);
|
||||
pictureBoxExcavator.Image = bmp;
|
||||
|
||||
}
|
||||
private void buttonCreateExcavator_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
Color color1 = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
ColorDialog dialog1 = new();
|
||||
if (dialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color1 = dialog1.Color;
|
||||
}
|
||||
_DrawingMash = new DrawingExcavator(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color, color1, true, true,
|
||||
pictureBoxExcavator.Width, pictureBoxExcavator.Height);
|
||||
_DrawingMash.SetPosition(random.Next(10, 100), random.Next(10,
|
||||
100));
|
||||
Draw();
|
||||
}
|
||||
private void buttonCreateMash_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_DrawingMash = new DrawingMash(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color,
|
||||
pictureBoxExcavator.Width, pictureBoxExcavator.Height);
|
||||
_DrawingMash.SetPosition(random.Next(10, 100), random.Next(10,100));
|
||||
Draw();
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_DrawingMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_DrawingMash.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_DrawingMash.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_DrawingMash.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_DrawingMash.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_DrawingMash == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new DrawingObjectmash(_DrawingMash), pictureBoxExcavator.Width, pictureBoxExcavator.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
Selectedmash = _DrawingMash;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
2757
Excavator/FormExcavator.resx
Normal file
2757
Excavator/FormExcavator.resx
Normal file
File diff suppressed because it is too large
Load Diff
289
Excavator/FormExcavatorCollection.Designer.cs
generated
Normal file
289
Excavator/FormExcavatorCollection.Designer.cs
generated
Normal file
@ -0,0 +1,289 @@
|
||||
namespace Excavator
|
||||
{
|
||||
partial class FormExcavatorCollection
|
||||
{
|
||||
/// <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.buttonAddMash = new System.Windows.Forms.Button();
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.labelInstruments = new System.Windows.Forms.Label();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDeleteMash = new System.Windows.Forms.Button();
|
||||
this.colorDialog = new System.Windows.Forms.ColorDialog();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.buttonAddStorage = new System.Windows.Forms.Button();
|
||||
this.buttonDeleteStorage = new System.Windows.Forms.Button();
|
||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.toolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.Sort_color_button = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonAddMash
|
||||
//
|
||||
this.buttonAddMash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddMash.Location = new System.Drawing.Point(982, 441);
|
||||
this.buttonAddMash.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonAddMash.Name = "buttonAddMash";
|
||||
this.buttonAddMash.Size = new System.Drawing.Size(135, 37);
|
||||
this.buttonAddMash.TabIndex = 0;
|
||||
this.buttonAddMash.Text = "Добавить автобус";
|
||||
this.buttonAddMash.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMash.Click += new System.EventHandler(this.buttonAddMash_Click);
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 27);
|
||||
this.pictureBoxCollection.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(949, 633);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// labelInstruments
|
||||
//
|
||||
this.labelInstruments.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelInstruments.AutoSize = true;
|
||||
this.labelInstruments.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelInstruments.Location = new System.Drawing.Point(982, 0);
|
||||
this.labelInstruments.Name = "labelInstruments";
|
||||
this.labelInstruments.Size = new System.Drawing.Size(136, 28);
|
||||
this.labelInstruments.TabIndex = 2;
|
||||
this.labelInstruments.Text = "Инструменты";
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(973, 173);
|
||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(150, 33);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить набор";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||
//
|
||||
// buttonDeleteMash
|
||||
//
|
||||
this.buttonDeleteMash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDeleteMash.Location = new System.Drawing.Point(982, 525);
|
||||
this.buttonDeleteMash.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonDeleteMash.Name = "buttonDeleteMash";
|
||||
this.buttonDeleteMash.Size = new System.Drawing.Size(135, 37);
|
||||
this.buttonDeleteMash.TabIndex = 4;
|
||||
this.buttonDeleteMash.Text = "Удалить";
|
||||
this.buttonDeleteMash.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteMash.Click += new System.EventHandler(this.buttonDeleteMash_Click);
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(973, 487);
|
||||
this.maskedTextBoxNumber.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.maskedTextBoxNumber.Mask = "00";
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(157, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 5;
|
||||
this.maskedTextBoxNumber.ValidatingType = typeof(int);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(973, 51);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(66, 20);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "Наборы";
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 20;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(971, 213);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(150, 44);
|
||||
this.listBoxStorages.TabIndex = 8;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// buttonAddStorage
|
||||
//
|
||||
this.buttonAddStorage.Location = new System.Drawing.Point(971, 136);
|
||||
this.buttonAddStorage.Name = "buttonAddStorage";
|
||||
this.buttonAddStorage.Size = new System.Drawing.Size(150, 33);
|
||||
this.buttonAddStorage.TabIndex = 9;
|
||||
this.buttonAddStorage.Text = "Добавить набор";
|
||||
this.buttonAddStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonAddStorage.Click += new System.EventHandler(this.buttonAddStorage_Click);
|
||||
//
|
||||
// buttonDeleteStorage
|
||||
//
|
||||
this.buttonDeleteStorage.Location = new System.Drawing.Point(971, 364);
|
||||
this.buttonDeleteStorage.Name = "buttonDeleteStorage";
|
||||
this.buttonDeleteStorage.Size = new System.Drawing.Size(150, 33);
|
||||
this.buttonDeleteStorage.TabIndex = 10;
|
||||
this.buttonDeleteStorage.Text = "Удалить набор";
|
||||
this.buttonDeleteStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteStorage.Click += new System.EventHandler(this.buttonDeleteStorage_Click);
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(971, 103);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(150, 27);
|
||||
this.textBoxStorageName.TabIndex = 11;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
|
||||
this.menuStrip.Size = new System.Drawing.Size(1146, 30);
|
||||
this.menuStrip.TabIndex = 12;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem
|
||||
//
|
||||
this.toolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem,
|
||||
this.loadToolStripMenuItem});
|
||||
this.toolStripMenuItem.Name = "toolStripMenuItem";
|
||||
this.toolStripMenuItem.Size = new System.Drawing.Size(59, 24);
|
||||
this.toolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(166, 26);
|
||||
this.saveToolStripMenuItem.Text = "Сохранить";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(166, 26);
|
||||
this.loadToolStripMenuItem.Text = "Загрузить";
|
||||
this.loadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(966, 265);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(164, 31);
|
||||
this.button1.TabIndex = 13;
|
||||
this.button1.Text = "Сортировка по типу";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.buttonSortByType_Click);
|
||||
//
|
||||
// Sort_color_button
|
||||
//
|
||||
this.Sort_color_button.Location = new System.Drawing.Point(966, 304);
|
||||
this.Sort_color_button.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Sort_color_button.Name = "Sort_color_button";
|
||||
this.Sort_color_button.Size = new System.Drawing.Size(165, 31);
|
||||
this.Sort_color_button.TabIndex = 14;
|
||||
this.Sort_color_button.Text = "Сортировка по цвету";
|
||||
this.Sort_color_button.UseVisualStyleBackColor = true;
|
||||
this.Sort_color_button.Click += new System.EventHandler(this.Sort_Color_button_Click);
|
||||
//
|
||||
// FormExcavatorCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1146, 672);
|
||||
this.Controls.Add(this.Sort_color_button);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBoxStorageName);
|
||||
this.Controls.Add(this.buttonDeleteStorage);
|
||||
this.Controls.Add(this.buttonAddStorage);
|
||||
this.Controls.Add(this.listBoxStorages);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.buttonAddMash);
|
||||
this.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.Controls.Add(this.buttonDeleteMash);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.labelInstruments);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormExcavatorCollection";
|
||||
this.Text = "Набор объектов";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonAddMash;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Label labelInstruments;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDeleteMash;
|
||||
private ColorDialog colorDialog;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private Label label1;
|
||||
private ListBox listBoxStorages;
|
||||
private Button buttonAddStorage;
|
||||
private Button buttonDeleteStorage;
|
||||
private TextBox textBoxStorageName;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem toolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button button1;
|
||||
private Button Sort_color_button;
|
||||
}
|
||||
}
|
230
Excavator/FormExcavatorCollection.cs
Normal file
230
Excavator/FormExcavatorCollection.cs
Normal file
@ -0,0 +1,230 @@
|
||||
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;
|
||||
using Excavator.Generic;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Move_Strategy;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Excavator.Exceptions;
|
||||
using Excavator.Generics;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public partial class FormExcavatorCollection : Form
|
||||
{
|
||||
private readonly MashsGenericStorage _storage;
|
||||
private readonly ILogger _logger;
|
||||
public FormExcavatorCollection(ILogger<FormExcavatorCollection> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new MashsGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void buttonSortByType_Click(object sender, EventArgs e) => CompareMash(new MashCompareByType());
|
||||
|
||||
private void Sort_Color_button_Click(object sender, EventArgs e) => CompareMash(new MashCompareByColor());
|
||||
private void CompareMash(IComparer<DrawingMash?> comparer)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj.Sort(comparer);
|
||||
pictureBoxCollection.Image = obj.ShowMash();
|
||||
}
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i].Name);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
|
||||
}
|
||||
private void buttonAddStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
|
||||
}
|
||||
private void listBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowMash();
|
||||
}
|
||||
private void buttonDeleteStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(name);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Удалён набор: {name}");
|
||||
}
|
||||
}
|
||||
private void buttonAddMash_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var FormMashConfig = new FormMashConfig();
|
||||
FormMashConfig.AddEvent(AddMash);
|
||||
FormMashConfig.Show();
|
||||
}
|
||||
|
||||
private void AddMash(DrawingMash selectedMash)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("Не выбран набор");
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
selectedMash.ChangeBordersPicture(Width, Height);
|
||||
try
|
||||
{
|
||||
if (obj + selectedMash != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowMash();
|
||||
_logger.LogInformation($"Добавлен объект: {selectedMash.EntityMash.BodyColor}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDeleteMash_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (obj - pos)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowMash();
|
||||
_logger.LogInformation($"Удалён объект по позиции : {pos}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
MessageBox.Show("Неверный формат ввода");
|
||||
_logger.LogWarning("Неверный формат ввода");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowMash();
|
||||
}
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Файл сохранён по пути: {saveFileDialog.FileName}");
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.LoadData(openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Файл загружен по пути: {openFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
}
|
75
Excavator/FormExcavatorCollection.resx
Normal file
75
Excavator/FormExcavatorCollection.resx
Normal file
@ -0,0 +1,75 @@
|
||||
<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="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>428, 16</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>590, 16</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>36</value>
|
||||
</metadata>
|
||||
</root>
|
114
Excavator/FormMashCollection.Designer.cs
generated
Normal file
114
Excavator/FormMashCollection.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace Excavator
|
||||
{
|
||||
partial class FormMashCollection
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
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.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.labelInstruments = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.TextBox();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(1, -3);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(918, 1232);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// labelInstruments
|
||||
//
|
||||
this.labelInstruments.AutoSize = true;
|
||||
this.labelInstruments.Location = new System.Drawing.Point(974, 29);
|
||||
this.labelInstruments.Name = "labelInstruments";
|
||||
this.labelInstruments.Size = new System.Drawing.Size(103, 20);
|
||||
this.labelInstruments.TabIndex = 1;
|
||||
this.labelInstruments.Text = "Инструменты";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(960, 84);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(184, 59);
|
||||
this.buttonAdd.TabIndex = 2;
|
||||
this.buttonAdd.Text = "Добавить объект";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAddMash_Click);
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(999, 187);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(125, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 3;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(960, 223);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(189, 60);
|
||||
this.buttonDelete.TabIndex = 4;
|
||||
this.buttonDelete.Text = "Удалить объект";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonRemoveMash_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(960, 347);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(189, 60);
|
||||
this.buttonUpdate.TabIndex = 5;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||
//
|
||||
// FormMashCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1317, 1055);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.labelInstruments);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Name = "FormMashCollection";
|
||||
this.Text = "Экскаватор";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Label labelInstruments;
|
||||
private Button buttonAdd;
|
||||
private TextBox maskedTextBoxNumber;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
}
|
||||
}
|
74
Excavator/FormMashCollection.cs
Normal file
74
Excavator/FormMashCollection.cs
Normal file
@ -0,0 +1,74 @@
|
||||
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;
|
||||
using Excavator.DrawingObjects;
|
||||
using Excavator;
|
||||
using Excavator.MovementStrategy;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public partial class FormMashCollection : Form
|
||||
{
|
||||
private readonly MashGenericCollection<DrawingMash, DrawingObjectMash> _Mash;
|
||||
public FormMashCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_Mash = new MashGenericCollection<DrawingMash, DrawingObjectMash>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
|
||||
}
|
||||
private void ButtonAddMash_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormExcavator form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_Mash + form.SelectedMash != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _Mash.ShowMash();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRemoveMash_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = 0;
|
||||
try
|
||||
{
|
||||
pos = Convert.ToInt32(maskedTextBoxNumber.Text) ;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Ошибка ввода данных");
|
||||
return;
|
||||
}
|
||||
if (_Mash - (_Mash.ReturnLength() - pos))
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _Mash.ShowMash();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _Mash.ShowMash();
|
||||
}
|
||||
}
|
||||
}
|
60
Excavator/FormMashCollection.resx
Normal file
60
Excavator/FormMashCollection.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
382
Excavator/FormMashConfig.Designer.cs
generated
Normal file
382
Excavator/FormMashConfig.Designer.cs
generated
Normal file
@ -0,0 +1,382 @@
|
||||
namespace Excavator
|
||||
{
|
||||
partial class FormMashConfig
|
||||
{
|
||||
/// <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.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.labelAdvancedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColor = new System.Windows.Forms.GroupBox();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelPink = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelRoyalBlue = new System.Windows.Forms.Panel();
|
||||
this.panelFirebrick = new System.Windows.Forms.Panel();
|
||||
this.checkBoxSupports = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxBucket = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelAdditionalColor = new System.Windows.Forms.Label();
|
||||
this.labelMainColor = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
this.groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelAdvancedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColor);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxSupports);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxBucket);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(14, 48);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(570, 251);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
this.labelAdvancedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdvancedObject.Location = new System.Drawing.Point(440, 188);
|
||||
this.labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
this.labelAdvancedObject.Size = new System.Drawing.Size(120, 30);
|
||||
this.labelAdvancedObject.TabIndex = 8;
|
||||
this.labelAdvancedObject.Text = "Продвинутый";
|
||||
this.labelAdvancedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAdvancedObject.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(283, 188);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(120, 30);
|
||||
this.labelSimpleObject.TabIndex = 7;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
this.groupBoxColor.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColor.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColor.Controls.Add(this.panelPink);
|
||||
this.groupBoxColor.Controls.Add(this.panelGray);
|
||||
this.groupBoxColor.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColor.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColor.Controls.Add(this.panelRoyalBlue);
|
||||
this.groupBoxColor.Controls.Add(this.panelFirebrick);
|
||||
this.groupBoxColor.Location = new System.Drawing.Point(283, 32);
|
||||
this.groupBoxColor.Name = "groupBoxColor";
|
||||
this.groupBoxColor.Size = new System.Drawing.Size(277, 145);
|
||||
this.groupBoxColor.TabIndex = 6;
|
||||
this.groupBoxColor.TabStop = false;
|
||||
this.groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(5, 85);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelBlue.TabIndex = 0;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(75, 85);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelBlack.TabIndex = 0;
|
||||
//
|
||||
// panelPink
|
||||
//
|
||||
this.panelPink.BackColor = System.Drawing.Color.DeepPink;
|
||||
this.panelPink.Location = new System.Drawing.Point(145, 85);
|
||||
this.panelPink.Name = "panelPink";
|
||||
this.panelPink.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelPink.TabIndex = 0;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
this.panelGray.Location = new System.Drawing.Point(215, 85);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelGray.TabIndex = 0;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(215, 25);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelGreen.TabIndex = 0;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(145, 25);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelYellow.TabIndex = 0;
|
||||
//
|
||||
// panelRoyalBlue
|
||||
//
|
||||
this.panelRoyalBlue.BackColor = System.Drawing.Color.RoyalBlue;
|
||||
this.panelRoyalBlue.Location = new System.Drawing.Point(75, 25);
|
||||
this.panelRoyalBlue.Name = "panelRoyalBlue";
|
||||
this.panelRoyalBlue.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelRoyalBlue.TabIndex = 0;
|
||||
//
|
||||
// panelFirebrick
|
||||
//
|
||||
this.panelFirebrick.BackColor = System.Drawing.Color.Firebrick;
|
||||
this.panelFirebrick.Location = new System.Drawing.Point(5, 25);
|
||||
this.panelFirebrick.Name = "panelFirebrick";
|
||||
this.panelFirebrick.Size = new System.Drawing.Size(50, 40);
|
||||
this.panelFirebrick.TabIndex = 0;
|
||||
//
|
||||
// checkBoxSupports
|
||||
//
|
||||
this.checkBoxSupports.AutoSize = true;
|
||||
this.checkBoxSupports.Location = new System.Drawing.Point(13, 149);
|
||||
this.checkBoxSupports.Name = "checkBoxSupports";
|
||||
this.checkBoxSupports.Size = new System.Drawing.Size(132, 24);
|
||||
this.checkBoxSupports.TabIndex = 5;
|
||||
this.checkBoxSupports.Text = "Наличие опор";
|
||||
this.checkBoxSupports.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBucket
|
||||
//
|
||||
this.checkBoxBucket.AutoSize = true;
|
||||
this.checkBoxBucket.Location = new System.Drawing.Point(13, 119);
|
||||
this.checkBoxBucket.Name = "checkBoxBucket";
|
||||
this.checkBoxBucket.Size = new System.Drawing.Size(143, 24);
|
||||
this.checkBoxBucket.TabIndex = 4;
|
||||
this.checkBoxBucket.Text = "Наличие отвала";
|
||||
this.checkBoxBucket.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(94, 32);
|
||||
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 = 3;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(94, 83);
|
||||
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 = 2;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(6, 85);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(36, 20);
|
||||
this.labelWeight.TabIndex = 1;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(6, 32);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(76, 20);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(35, 84);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(327, 205);
|
||||
this.pictureBoxObject.TabIndex = 1;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.labelAdditionalColor);
|
||||
this.panelObject.Controls.Add(this.labelMainColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(613, 29);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(401, 301);
|
||||
this.panelObject.TabIndex = 2;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
this.labelAdditionalColor.AllowDrop = true;
|
||||
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdditionalColor.Location = new System.Drawing.Point(233, 19);
|
||||
this.labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
this.labelAdditionalColor.Size = new System.Drawing.Size(90, 50);
|
||||
this.labelAdditionalColor.TabIndex = 3;
|
||||
this.labelAdditionalColor.Text = "Доп. цвет";
|
||||
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragDrop);
|
||||
this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragEnter);
|
||||
//
|
||||
// labelMainColor
|
||||
//
|
||||
this.labelMainColor.AllowDrop = true;
|
||||
this.labelMainColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelMainColor.Location = new System.Drawing.Point(77, 19);
|
||||
this.labelMainColor.Name = "labelMainColor";
|
||||
this.labelMainColor.Size = new System.Drawing.Size(90, 50);
|
||||
this.labelMainColor.TabIndex = 2;
|
||||
this.labelMainColor.Text = "Цвет";
|
||||
this.labelMainColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelMainColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragDrop);
|
||||
this.labelMainColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragEnter);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(689, 337);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonAdd.TabIndex = 3;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(846, 339);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormMashConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1032, 383);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormMashConfig";
|
||||
this.Text = "FormMashConfig";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
||||
this.groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBoxSupports;
|
||||
private CheckBox checkBoxBucket;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelBlue;
|
||||
private Panel panelBlack;
|
||||
private Panel panelPink;
|
||||
private Panel panelGray;
|
||||
private Panel panelGreen;
|
||||
private Panel panelYellow;
|
||||
private Panel panelRoyalBlue;
|
||||
private Panel panelFirebrick;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelAdditionalColor;
|
||||
private Label labelMainColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
146
Excavator/FormMashConfig.cs
Normal file
146
Excavator/FormMashConfig.cs
Normal file
@ -0,0 +1,146 @@
|
||||
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;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
public partial class FormMashConfig : Form
|
||||
{
|
||||
|
||||
DrawingMash? _mash = null;
|
||||
private event Action<DrawingMash>? EventAddMash;
|
||||
public FormMashConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelFirebrick.MouseDown += PanelColor_MouseDown;
|
||||
panelRoyalBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPink.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
private void DrawMash()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_mash?.SetPosition(5, 5);
|
||||
_mash?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawingMash> ev)
|
||||
{
|
||||
if (EventAddMash == null)
|
||||
{
|
||||
EventAddMash = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddMash += ev;
|
||||
}
|
||||
}
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_mash = new DrawingMash(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value,
|
||||
Color.White,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
|
||||
case "labelAdvancedObject":
|
||||
_mash = new DrawingExcavator(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black,
|
||||
checkBoxBucket.Checked, checkBoxSupports.Checked,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawMash();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _mash != null)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
_mash.EntityMash.ChangeBodyColor(color);
|
||||
DrawMash();
|
||||
}
|
||||
|
||||
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _mash != null && _mash is DrawingExcavator)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
|
||||
EntityExcavator? _excavator = _mash.EntityMash as EntityExcavator;
|
||||
_excavator.ChangeAdditionalColor(color);
|
||||
DrawMash();
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mash == null)
|
||||
return;
|
||||
|
||||
EventAddMash?.Invoke(_mash);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
Excavator/FormMashConfig.resx
Normal file
60
Excavator/FormMashConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
55
Excavator/Generic/DrawingMashEqutables.cs
Normal file
55
Excavator/Generic/DrawingMashEqutables.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.Generics
|
||||
{
|
||||
internal class DrawingMashEqutables : IEqualityComparer<DrawingMash?>
|
||||
{
|
||||
public bool Equals(DrawingMash? x, DrawingMash? y)
|
||||
{
|
||||
if (x == null && x.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null && y.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
if ((x.GetType().Name != y.GetType().Name))
|
||||
return false;
|
||||
|
||||
if (x.EntityMash.Speed != y.EntityMash.Speed)
|
||||
return false;
|
||||
|
||||
if (x.EntityMash.Weight != y.EntityMash.Weight)
|
||||
return false;
|
||||
|
||||
if (x.EntityMash.BodyColor != y.EntityMash.BodyColor)
|
||||
return false;
|
||||
|
||||
if (x is DrawingExcavator && y is DrawingExcavator)
|
||||
{
|
||||
var xExcavator = (EntityExcavator)x.EntityMash;
|
||||
var yExcavator = (EntityExcavator)y.EntityMash;
|
||||
|
||||
if (xExcavator.AddColor != yExcavator.AddColor)
|
||||
return false;
|
||||
|
||||
if (xExcavator.IsBucket != yExcavator.IsBucket)
|
||||
return false;
|
||||
|
||||
if (xExcavator.IsSupports != yExcavator.IsSupports)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int GetHashCode([DisallowNull] DrawingMash? obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
27
Excavator/Generic/MashCollectionInfo.cs
Normal file
27
Excavator/Generic/MashCollectionInfo.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Generics
|
||||
{
|
||||
internal class MashCollectionInfo : IEquatable<MashCollectionInfo>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public MashCollectionInfo(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
public bool Equals(MashCollectionInfo? other)
|
||||
{
|
||||
if (ReferenceEquals(other, null))
|
||||
return false;
|
||||
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
}
|
||||
}
|
34
Excavator/Generic/MashCompareByColor.cs
Normal file
34
Excavator/Generic/MashCompareByColor.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.Generics
|
||||
{
|
||||
internal class MashCompareByColor : IComparer<DrawingMash>
|
||||
{
|
||||
public int Compare(DrawingMash? x, DrawingMash? y)
|
||||
{
|
||||
if (x == null || x.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
var xMash = x.EntityMash;
|
||||
var yMash = y.EntityMash;
|
||||
|
||||
if (xMash.BodyColor != yMash.BodyColor)
|
||||
return xMash.BodyColor.Name.CompareTo(yMash.BodyColor.Name);
|
||||
|
||||
var speedCompare = x.EntityMash.Speed.CompareTo(y.EntityMash.Speed);
|
||||
if (speedCompare != 0)
|
||||
return speedCompare;
|
||||
|
||||
return x.EntityMash.Weight.CompareTo(y.EntityMash.Weight);
|
||||
}
|
||||
}
|
||||
}
|
30
Excavator/Generic/MashCompareByType.cs
Normal file
30
Excavator/Generic/MashCompareByType.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Drawing;
|
||||
|
||||
namespace Excavator.Generics
|
||||
{
|
||||
internal class MashCompareByType : IComparer<DrawingMash>
|
||||
{
|
||||
public int Compare(DrawingMash? x, DrawingMash? y)
|
||||
{
|
||||
if (x == null || x.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityMash == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
|
||||
var speedCompare = x.EntityMash.Speed.CompareTo(y.EntityMash.Speed);
|
||||
if (speedCompare != 0)
|
||||
return speedCompare;
|
||||
|
||||
return x.EntityMash.Weight.CompareTo(y.EntityMash.Weight);
|
||||
}
|
||||
}
|
||||
}
|
99
Excavator/Generic/MashGenericCollection.cs
Normal file
99
Excavator/Generic/MashGenericCollection.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Generics;
|
||||
using Excavator.Move_Strategy;
|
||||
|
||||
namespace Excavator.Generic
|
||||
{
|
||||
internal class MashGenericCollection<T, U>
|
||||
where T : DrawingMash
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 200;
|
||||
private readonly int _placeSizeHeight = 120;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public MashGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||
|
||||
public static int operator +(MashGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
return collect._collection.Insert(obj, new DrawingMashEqutables());
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
public static bool operator -(MashGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
if (collect._collection.GetMash(pos) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Remove(pos) ?? false;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetMash => _collection.GetMash();
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowMash()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics gr)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int x = _pictureWidth / _placeSizeWidth - 1;
|
||||
int y = 0;
|
||||
|
||||
foreach (var mash in _collection.GetMash())
|
||||
{
|
||||
if (mash != null)
|
||||
{
|
||||
if (x < 0)
|
||||
{
|
||||
x = _pictureWidth / _placeSizeWidth - 1;
|
||||
++y;
|
||||
}
|
||||
mash.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||
mash.DrawTransport(g);
|
||||
--x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
142
Excavator/Generic/MashsGenericStorage.cs
Normal file
142
Excavator/Generic/MashsGenericStorage.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Generics;
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Generics;
|
||||
using Excavator.Move_Strategy;
|
||||
|
||||
namespace Excavator.Generic
|
||||
{
|
||||
internal class MashsGenericStorage
|
||||
{
|
||||
readonly Dictionary<MashCollectionInfo, MashGenericCollection<DrawingMash, DrawingObjectMash>> _mashStorages;
|
||||
public List<MashCollectionInfo> Keys => _mashStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
private readonly char _separatorRecords = ';';
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
public MashsGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mashStorages = new Dictionary<MashCollectionInfo, MashGenericCollection<DrawingMash, DrawingObjectMash>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
MashCollectionInfo set = new MashCollectionInfo(name, string.Empty);
|
||||
|
||||
if (_mashStorages.ContainsKey(set))
|
||||
return;
|
||||
|
||||
_mashStorages.Add(set, new MashGenericCollection<DrawingMash, DrawingObjectMash>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
public void DelSet(string name)
|
||||
{
|
||||
MashCollectionInfo set = new MashCollectionInfo(name, string.Empty);
|
||||
if (!_mashStorages.ContainsKey(set))
|
||||
return;
|
||||
|
||||
_mashStorages.Remove(set);
|
||||
|
||||
}
|
||||
public MashGenericCollection<DrawingMash, DrawingObjectMash>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
MashCollectionInfo set = new MashCollectionInfo(ind, string.Empty);
|
||||
|
||||
if (!_mashStorages.ContainsKey(set))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _mashStorages[set];
|
||||
}
|
||||
}
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<MashCollectionInfo,
|
||||
MashGenericCollection<DrawingMash, DrawingObjectMash>> record in _mashStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingMash? elem in record.Value.GetMash)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new Exception("Невалиданя операция, нет данных для сохранения");
|
||||
}
|
||||
using FileStream fs = new(filename, FileMode.Create);
|
||||
byte[] info = new
|
||||
UTF8Encoding(true).GetBytes($"BusStorage{Environment.NewLine}{data}");
|
||||
fs.Write(info, 0, info.Length);
|
||||
return;
|
||||
}
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new Exception("Файл не найден");
|
||||
}
|
||||
string bufferTextFromFile = "";
|
||||
using (FileStream fs = new(filename, FileMode.Open))
|
||||
{
|
||||
byte[] b = new byte[fs.Length];
|
||||
UTF8Encoding temp = new(true);
|
||||
while (fs.Read(b, 0, b.Length) > 0)
|
||||
{
|
||||
bufferTextFromFile += temp.GetString(b);
|
||||
}
|
||||
}
|
||||
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
throw new Exception("Нет данных для загрузки");
|
||||
}
|
||||
if (!strs[0].StartsWith("MashStorage"))
|
||||
{
|
||||
throw new Exception("Неверный формат данных");
|
||||
}
|
||||
_mashStorages.Clear();
|
||||
foreach (string data in strs)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
MashGenericCollection<DrawingMash, DrawingObjectMash>
|
||||
collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawingMash? Mash =
|
||||
elem?.CreateDrawingMash(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (Mash != null)
|
||||
{
|
||||
if ((collection + Mash) == -1)
|
||||
{
|
||||
throw new Exception("Ошибка добавления в коллекцию");
|
||||
}
|
||||
}
|
||||
}
|
||||
_mashStorages.Add(new MashCollectionInfo(record[0], string.Empty), collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
85
Excavator/Generic/SetGeneric.cs
Normal file
85
Excavator/Generic/SetGeneric.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using Excavator.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Excavator.Generic
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
public int Insert(T mash, IEqualityComparer<T?>? equal = null)
|
||||
{
|
||||
return Insert(mash, 0, equal);
|
||||
}
|
||||
|
||||
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
|
||||
public int Insert(T mash, int position, IEqualityComparer<T?>? equal = null)
|
||||
{
|
||||
if (Count >= _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
}
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
throw new IndexOutOfRangeException("Индекс вне границ коллекции");
|
||||
}
|
||||
if (equal != null && _places.Contains(mash, equal))
|
||||
{
|
||||
throw new ArgumentException("Данный объект уже есть в коллекции");
|
||||
}
|
||||
_places.Insert(position, mash);
|
||||
return 0;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
throw new MashNotFoundException(position);
|
||||
}
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetMash(int? maxMash = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxMash.HasValue && i == maxMash.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
Excavator/IMoveableObject.cs
Normal file
18
Excavator/IMoveableObject.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.DrawingObjects;
|
||||
|
||||
namespace Excavator.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
105
Excavator/MashGenericCollection.cs
Normal file
105
Excavator/MashGenericCollection.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.DrawingObjects;
|
||||
using Excavator.MovementStrategy;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
internal class MashGenericCollection<T, U>
|
||||
where T : DrawingMash
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 200;
|
||||
private readonly int _placeSizeHeight = 120;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public MashGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static int operator +(MashGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static bool operator -(MashGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
if (collect._collection.Get(pos) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Remove(pos) ?? false;
|
||||
}
|
||||
|
||||
public int ReturnLength()
|
||||
{
|
||||
return _collection.Count;
|
||||
}
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowMash()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics gr)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int index = -1;
|
||||
for (int i = 0; i <= _collection.Count; ++i)
|
||||
{
|
||||
DrawingMash _Mash = _collection.Get(i);
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (_Mash != null)
|
||||
{
|
||||
index = _collection.Count - i;
|
||||
while ((index - _pictureWidth / _placeSizeWidth) >= 0)
|
||||
{
|
||||
y++;
|
||||
index -= _pictureWidth / _placeSizeWidth;
|
||||
}
|
||||
if (index > 0)
|
||||
{
|
||||
x += index;
|
||||
}
|
||||
x = _pictureWidth / _placeSizeWidth - 1 - x;
|
||||
_Mash.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||
|
||||
_Mash.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
Excavator/MoveToBorder.cs
Normal file
57
Excavator/MoveToBorder.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.MovementStrategy
|
||||
{
|
||||
internal class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
Excavator/MoveToCenter.cs
Normal file
57
Excavator/MoveToCenter.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
Excavator/Move_Strategy/AbstractStrategy.cs
Normal file
75
Excavator/Move_Strategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excavator.Entities;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
Excavator/Move_Strategy/DrawingObjectBus.cs
Normal file
35
Excavator/Move_Strategy/DrawingObjectBus.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Entities;
|
||||
using Excavator.Drawing;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
public class DrawingObjectmash : IMoveableObject
|
||||
{
|
||||
private readonly DrawingMash? _DrawingMash = null;
|
||||
public DrawingObjectmash(DrawingMash DrawingMash)
|
||||
{
|
||||
_DrawingMash = DrawingMash;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DrawingMash == null || _DrawingMash.EntityMash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_DrawingMash.GetPosX, _DrawingMash.GetPosY, _DrawingMash.GetWidth, _DrawingMash.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_DrawingMash?.EntityMash?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) => _DrawingMash?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) => _DrawingMash?.MoveTransport(direction);
|
||||
}
|
||||
}
|
36
Excavator/Move_Strategy/DrawingObjectMash.cs
Normal file
36
Excavator/Move_Strategy/DrawingObjectMash.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Entities;
|
||||
using Excavator.Drawing;
|
||||
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
public class DrawingObjectMash : IMoveableObject
|
||||
{
|
||||
private readonly DrawingMash? _drawingMash = null;
|
||||
public DrawingObjectMash(DrawingMash DrawingMash)
|
||||
{
|
||||
_drawingMash = DrawingMash;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawingMash == null || _drawingMash.EntityMash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawingMash.GetPosX, _drawingMash.GetPosY, _drawingMash.GetWidth, _drawingMash.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawingMash?.EntityMash?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) => _drawingMash?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) => _drawingMash?.MoveTransport(direction);
|
||||
}
|
||||
}
|
19
Excavator/Move_Strategy/IMoveableObject.cs
Normal file
19
Excavator/Move_Strategy/IMoveableObject.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Excavator.Drawing;
|
||||
using Excavator.Entities;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
57
Excavator/Move_Strategy/MoveToBorder.cs
Normal file
57
Excavator/Move_Strategy/MoveToBorder.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
internal class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
Excavator/Move_Strategy/MoveToCenter.cs
Normal file
57
Excavator/Move_Strategy/MoveToCenter.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
Excavator/Move_Strategy/ObjectParameters.cs
Normal file
29
Excavator/Move_Strategy/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
15
Excavator/Move_Strategy/Status.cs
Normal file
15
Excavator/Move_Strategy/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.Move_Strategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
29
Excavator/ObjectParameters.cs
Normal file
29
Excavator/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.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;
|
||||
}
|
||||
}
|
||||
}
|
40
Excavator/Program.cs
Normal file
40
Excavator/Program.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormExcavatorCollection>());
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormExcavatorCollection>().AddLogging(option =>
|
||||
{
|
||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||
string pathNeed = "";
|
||||
for (int i = 0; i < path.Length - 3; i++)
|
||||
{
|
||||
pathNeed += path[i] + "\\";
|
||||
}
|
||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}serilog.json", optional: false, reloadOnChange: true).Build();
|
||||
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
103
Excavator/Properties/Resources.Designer.cs
generated
Normal file
103
Excavator/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Excavator.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("Excavator.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 стрелка_вверх {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вверх", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_влево {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка влево", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_вниз {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вниз", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_вправо {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вправо", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
Excavator/Properties/Resources.resx
Normal file
133
Excavator/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="стрелка вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка вправо" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Excavator/Resources/ArrowDown.png
Normal file
BIN
Excavator/Resources/ArrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
Excavator/Resources/ArrowLeft.png
Normal file
BIN
Excavator/Resources/ArrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
Excavator/Resources/ArrowRight.png
Normal file
BIN
Excavator/Resources/ArrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
Excavator/Resources/ArrowUp.png
Normal file
BIN
Excavator/Resources/ArrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
85
Excavator/SetGeneric.cs
Normal file
85
Excavator/SetGeneric.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
|
||||
{
|
||||
private readonly T?[] _places;
|
||||
public int Count => _places.Length - 1;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
public int Insert(T Mash)
|
||||
{
|
||||
int pos = Count - 1;
|
||||
if (_places[Count] != null)
|
||||
{
|
||||
for (int i = pos; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = pos + 1; i <= Count; ++i)
|
||||
{
|
||||
_places[i - 1] = _places[i];
|
||||
}
|
||||
}
|
||||
_places[Count] = Mash;
|
||||
return pos;
|
||||
}
|
||||
public bool Insert(T Mash, int position)
|
||||
{
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_places[Count] != null)
|
||||
{
|
||||
int pos = Count;
|
||||
for (int i = Count; i > 0; --i)
|
||||
{
|
||||
|
||||
if (_places[i] == null)
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = Count; i >= pos; --i)
|
||||
{
|
||||
_places[i - 1] = _places[i];
|
||||
}
|
||||
}
|
||||
_places[Count] = Mash;
|
||||
return true;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places[position] = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
15
Excavator/Status.cs
Normal file
15
Excavator/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Excavator.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
20
Excavator/serilog.json
Normal file
20
Excavator/serilog.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/buslog.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "ProjectAirbus"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user