Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
0208828b09 | |||
60f34c49b3 | |||
a29254945d | |||
ec901ec714 | |||
afeffbc024 | |||
1533dab9a5 | |||
20f939bb77 | |||
295bdabdb7 | |||
76aaebda1d | |||
b26ab91e64 | |||
72fbe6a105 | |||
fdd3f8a042 | |||
c8eed1e7df | |||
cfa3253cf1 | |||
1047be1e08 | |||
7d41cfe353 | |||
f631fce11e |
25
lainer/Lainer1.sln
Normal file
25
lainer/Lainer1.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33829.357
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lainer1", "Lainer1\Lainer1.csproj", "{AB21363F-202A-4647-B3B2-6D522DF13DB8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AB21363F-202A-4647-B3B2-6D522DF13DB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AB21363F-202A-4647-B3B2-6D522DF13DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AB21363F-202A-4647-B3B2-6D522DF13DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AB21363F-202A-4647-B3B2-6D522DF13DB8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D9EDD43C-01B3-4787-8583-4650BC513AF7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
69
lainer/Lainer1/AbstractStrategy.cs
Normal file
69
lainer/Lainer1/AbstractStrategy.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using ProjectLainer;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
|
||||
namespace ProjectLainer.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;
|
||||
}
|
||||
}
|
||||
}
|
10
lainer/Lainer1/DirectionTypeEnum.cs
Normal file
10
lainer/Lainer1/DirectionTypeEnum.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
161
lainer/Lainer1/DrawingLainer.cs
Normal file
161
lainer/Lainer1/DrawingLainer.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using ProjectLainer.Entities;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectLainer.DrawningObjects
|
||||
{
|
||||
public class DrawingLainer
|
||||
{
|
||||
public EntityLainer? EntityLainer { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectLainer(this);
|
||||
public DrawingLainer(int speed, double weight, Color bodyColor, int
|
||||
width, int height)
|
||||
{
|
||||
if (width < _LainerWidth || height < _LainerHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityLainer = new EntityLainer(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
protected DrawingLainer(int speed, double weight, Color bodyColor, int
|
||||
width, int height, int carWidth, int carHeight)
|
||||
{
|
||||
if (width < _LainerWidth || height < _LainerHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_LainerWidth = carWidth;
|
||||
_LainerHeight = carHeight;
|
||||
EntityLainer = new EntityLainer(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
|
||||
if (x + _LainerWidth < _pictureWidth && x + _LainerWidth > 0)
|
||||
{
|
||||
_startPosX = x;
|
||||
}
|
||||
if (y + _LainerHeight < _pictureHeight && y + _LainerHeight > 0)
|
||||
{
|
||||
_startPosY = y;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
//îòðèñîâêà òðóá
|
||||
Brush brush = new SolidBrush(Color.Black);
|
||||
Rectangle smokestack1 = new Rectangle(_startPosX + 20, _startPosY, 20, 50);
|
||||
Rectangle smokestack2 = new Rectangle(_startPosX + 60, _startPosY, 20, 50);
|
||||
g.FillRectangle(brush, smokestack1);
|
||||
g.FillRectangle(brush, smokestack2);
|
||||
//ãðàíèöû ëàéíåðà
|
||||
Pen pen = new(Color.Red);
|
||||
brush = new SolidBrush(Color.Red);
|
||||
Point point1 = new Point(_startPosX, _startPosY + 50);
|
||||
Point point2 = new Point(_startPosX + _LainerWidth, _startPosY + 50);
|
||||
Point point3 = new Point(_startPosX + 20, _startPosY + 80);
|
||||
Point point4 = new Point(_startPosX + 80, _startPosY + 80);
|
||||
Point[] points = { point1, point2, point4, point3 };
|
||||
g.DrawPolygon(pen, points);
|
||||
g.FillPolygon(brush, points);
|
||||
//1 ïàëóáà
|
||||
brush = new SolidBrush(EntityLainer.BodyColor);
|
||||
Rectangle deck = new Rectangle(_startPosX + 5, _startPosY + 30, _LainerWidth - 10, 20);
|
||||
g.FillRectangle(brush, deck);
|
||||
//ñòåêëà
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
g.FillEllipse(brBlue, _startPosX + i * 16, _startPosY + 33, 14, 14);
|
||||
}
|
||||
}
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
private readonly int _LainerWidth = 150;
|
||||
private readonly int _LainerHeight = 80;
|
||||
public int GetWidth => _LainerWidth;
|
||||
public int GetHeight => _LainerHeight;
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityLainer == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
//âëåâî
|
||||
DirectionType.Left => _startPosX - EntityLainer.Step > 0,
|
||||
//ââåðõ
|
||||
DirectionType.Up => _startPosY - EntityLainer.Step > 0,
|
||||
// âïðàâî
|
||||
DirectionType.Right => _startPosX + _LainerWidth + EntityLainer.Step < _pictureWidth,
|
||||
//âíèç
|
||||
DirectionType.Down => _startPosY + _LainerHeight + EntityLainer.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//âëåâî
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityLainer.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosX = 1;
|
||||
}
|
||||
break;
|
||||
//ââåðõ
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityLainer.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosY = 1;
|
||||
}
|
||||
break;
|
||||
// âïðàâî
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + EntityLainer.Step <= _pictureWidth - _LainerWidth)
|
||||
{
|
||||
_startPosX += (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosX = _pictureWidth - _LainerWidth;
|
||||
}
|
||||
break;
|
||||
//âíèç
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + EntityLainer.Step < _pictureHeight - _LainerHeight)
|
||||
{
|
||||
_startPosY += (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosY = _pictureHeight - _LainerHeight;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
lainer/Lainer1/DrawingObjectLainer.cs
Normal file
32
lainer/Lainer1/DrawingObjectLainer.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using ProjectLainer.MovementStrategy;
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.DrawningObjects;
|
||||
namespace ProjectLainer.MovementStrategy
|
||||
{
|
||||
public class DrawningObjectLainer : IMoveableObject
|
||||
{
|
||||
private readonly DrawingLainer? _drawningLainer = null;
|
||||
public DrawningObjectLainer(DrawingLainer drawningLainer)
|
||||
{
|
||||
_drawningLainer = drawningLainer;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningLainer == null || _drawningLainer.EntityLainer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningLainer.GetPosX,
|
||||
_drawningLainer.GetPosY, _drawningLainer.GetWidth, _drawningLainer.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningLainer?.EntityLainer?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>
|
||||
_drawningLainer?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>
|
||||
_drawningLainer?.MoveTransport(direction);
|
||||
}
|
||||
}
|
||||
|
52
lainer/Lainer1/DrawingSuperLainer.cs
Normal file
52
lainer/Lainer1/DrawingSuperLainer.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using ProjectLainer.Entities;
|
||||
namespace ProjectLainer.DrawningObjects
|
||||
{
|
||||
public class DrawningSuperLainer : DrawingLainer
|
||||
{
|
||||
public DrawningSuperLainer(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool pools, bool decks, int width, int height) : base(speed, weight, bodyColor, width, height, 110, 60)
|
||||
{
|
||||
if (EntityLainer != null)
|
||||
{
|
||||
EntityLainer = new EntitySuperLainer(speed, weight, bodyColor,
|
||||
additionalColor, pools, decks);
|
||||
}
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityLainer is not EntitySuperLainer superlainer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.DrawTransport(g);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(superlainer.AdditionalColor);
|
||||
if (superlainer.Decks)
|
||||
{
|
||||
Point point1 = new Point(_startPosX, _startPosY + 10);
|
||||
Point point2 = new Point(_startPosX + GetWidth, _startPosY + 10);
|
||||
Point point3 = new Point(_startPosX + 20, _startPosY + 30);
|
||||
Point point4 = new Point(_startPosX + 80, _startPosY + 30);
|
||||
Point[] points = { point1, point2, point4, point3 };
|
||||
g.DrawPolygon(pen, points);
|
||||
g.FillPolygon(additionalBrush, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
Point point3 = new Point(_startPosX, _startPosY + 30);
|
||||
Point point4 = new Point(_startPosX + GetWidth, _startPosY + 30);
|
||||
Point point1 = new Point(_startPosX + 20, _startPosY + 10);
|
||||
Point point2 = new Point(_startPosX + 80, _startPosY + 10);
|
||||
Point[] points = { point1, point2, point4, point3 };
|
||||
g.DrawPolygon(pen, points);
|
||||
g.FillPolygon(additionalBrush, points);
|
||||
}
|
||||
for (int i = 2; i < 5; i++)
|
||||
{
|
||||
g.FillEllipse(brBlue, _startPosX + i * 16, _startPosY + 15, 12, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
144
lainer/Lainer1/DrawningLainer.cs
Normal file
144
lainer/Lainer1/DrawningLainer.cs
Normal file
@ -0,0 +1,144 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public class DrawningLainer
|
||||
{
|
||||
public EntityLainer? EntityLainer { get; private set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
private readonly int _LainerWidth = 150;
|
||||
private readonly int _LainerHeight = 80;
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool ispool, bool addDecks, int width, int height)
|
||||
{
|
||||
if(width <= _LainerWidth || height <= _LainerHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityLainer = new EntityLainer();
|
||||
EntityLainer.Init(speed, weight, bodyColor, additionalColor, ispool, addDecks);
|
||||
return true;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if(x + _LainerWidth < _pictureWidth && x + _LainerWidth > 0)
|
||||
{
|
||||
_startPosX = x;
|
||||
}
|
||||
if (y + _LainerHeight < _pictureHeight && y + _LainerHeight > 0)
|
||||
{
|
||||
_startPosY = y;
|
||||
}
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityLainer == null)
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//âëåâî
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityLainer.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosX = 1;
|
||||
}
|
||||
break;
|
||||
//ââåðõ
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityLainer.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosY = 1;
|
||||
}
|
||||
break;
|
||||
// âïðàâî
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + EntityLainer.Step <= _pictureWidth - _LainerWidth)
|
||||
{
|
||||
_startPosX += (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosX = _pictureWidth - _LainerWidth;
|
||||
}
|
||||
break;
|
||||
//âíèç
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + EntityLainer.Step <= _pictureHeight - _LainerHeight)
|
||||
{
|
||||
_startPosY += (int)EntityLainer.Step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosY = _pictureHeight - _LainerHeight;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityLainer.AdditionalColor);
|
||||
var brush = new SolidBrush(Color.Black);
|
||||
// äîï ïàëóáû è îòðèñîâêà òðóá
|
||||
Rectangle smokestack1 = new Rectangle(_startPosX + 20, _startPosY, 20, 50);
|
||||
Rectangle smokestack2 = new Rectangle(_startPosX + 60, _startPosY, 20, 50);
|
||||
g.FillRectangle(brush, smokestack1);
|
||||
g.FillRectangle(brush, smokestack2);
|
||||
if (EntityLainer.Decks)
|
||||
{
|
||||
Rectangle deck2 = new Rectangle(_startPosX + 10, _startPosY + 10, _LainerWidth - 18, 20);
|
||||
g.FillRectangle(additionalBrush, deck2);
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
g.FillEllipse(brBlue, _startPosX + i * 16, _startPosY + 15, 12, 12);
|
||||
}
|
||||
}
|
||||
//ãðàíèöû ëàéíåðà
|
||||
pen = new(Color.Red);
|
||||
brush = new SolidBrush(Color.Red);
|
||||
Point point1 = new Point(_startPosX, _startPosY + 50);
|
||||
Point point2 = new Point(_startPosX + _LainerWidth, _startPosY+50);
|
||||
Point point3 = new Point(_startPosX + 20, _startPosY+80);
|
||||
Point point4 = new Point(_startPosX + 80, _startPosY + 80);
|
||||
Point[] points = { point1, point2, point4, point3};
|
||||
g.DrawPolygon(pen, points);
|
||||
g.FillPolygon(brush, points);
|
||||
//1 ïàëóáà
|
||||
brush = new SolidBrush(Color.Green);
|
||||
Rectangle deck = new Rectangle(_startPosX + 5, _startPosY + 30, _LainerWidth - 10, 20);
|
||||
g.FillRectangle(brush,deck);
|
||||
//ñòåêëà
|
||||
for (int i = 1; i < 7; i++)
|
||||
{
|
||||
g.FillEllipse(brBlue, _startPosX + i*16, _startPosY + 33, 14, 14);
|
||||
}
|
||||
// áàññåéí
|
||||
if (EntityLainer.Pool)
|
||||
{
|
||||
g.FillEllipse(brBlue, _startPosX + _LainerWidth - 35, _startPosY + _LainerHeight - 55, 35, 12);
|
||||
brush = new SolidBrush(Color.DarkGray);
|
||||
Rectangle rect2 = new Rectangle(_startPosX + _LainerWidth - 35, _startPosY + _LainerHeight - 50, 35, 20);
|
||||
g.FillRectangle(brush, rect2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
20
lainer/Lainer1/EntityLainer.cs
Normal file
20
lainer/Lainer1/EntityLainer.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace ProjectLainer.Entities
|
||||
{
|
||||
public class EntityLainer
|
||||
{
|
||||
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 EntityLainer(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void ChangeColor(Color bodyColor)
|
||||
{
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
20
lainer/Lainer1/EntitySuperLainer.cs
Normal file
20
lainer/Lainer1/EntitySuperLainer.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace ProjectLainer.Entities
|
||||
{
|
||||
public class EntitySuperLainer : EntityLainer
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool Pools { get; private set; }
|
||||
public bool Decks { get; private set; }
|
||||
public EntitySuperLainer(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool pools, bool decks) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Pools = pools;
|
||||
Decks = decks;
|
||||
}
|
||||
public void ChangeAddColor(Color additionalColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
}
|
||||
}
|
||||
}
|
158
lainer/Lainer1/FormLainerCollection.Designer.cs
generated
Normal file
158
lainer/Lainer1/FormLainerCollection.Designer.cs
generated
Normal file
@ -0,0 +1,158 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
partial class FormLainerCollection
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxCollection = new PictureBox();
|
||||
ButtonAddLainer = new Button();
|
||||
ButtonRemove = new Button();
|
||||
ButtonRefresh = new Button();
|
||||
maskedTextBoxNumber = new MaskedTextBox();
|
||||
ButtonAddObject = new Button();
|
||||
textBoxStorageName = new TextBox();
|
||||
listBoxStorages = new ListBox();
|
||||
ButtonDelObject = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location = new Point(16, 14);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(815, 434);
|
||||
pictureBoxCollection.TabIndex = 0;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// ButtonAddLainer
|
||||
//
|
||||
ButtonAddLainer.Location = new Point(872, 282);
|
||||
ButtonAddLainer.Name = "ButtonAddLainer";
|
||||
ButtonAddLainer.Size = new Size(154, 32);
|
||||
ButtonAddLainer.TabIndex = 1;
|
||||
ButtonAddLainer.Text = "добавить лайнер";
|
||||
ButtonAddLainer.UseVisualStyleBackColor = true;
|
||||
ButtonAddLainer.Click += ButtonAddLainer_Click;
|
||||
//
|
||||
// ButtonRemove
|
||||
//
|
||||
ButtonRemove.Location = new Point(887, 384);
|
||||
ButtonRemove.Name = "ButtonRemove";
|
||||
ButtonRemove.Size = new Size(139, 37);
|
||||
ButtonRemove.TabIndex = 2;
|
||||
ButtonRemove.Text = "удалить лайнер";
|
||||
ButtonRemove.UseVisualStyleBackColor = true;
|
||||
ButtonRemove.Click += ButtonRemove_Click;
|
||||
//
|
||||
// ButtonRefresh
|
||||
//
|
||||
ButtonRefresh.Location = new Point(849, 449);
|
||||
ButtonRefresh.Name = "ButtonRefresh";
|
||||
ButtonRefresh.Size = new Size(164, 29);
|
||||
ButtonRefresh.TabIndex = 3;
|
||||
ButtonRefresh.Text = "обновить коллекцию";
|
||||
ButtonRefresh.UseVisualStyleBackColor = true;
|
||||
ButtonRefresh.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Location = new Point(888, 351);
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(125, 27);
|
||||
maskedTextBoxNumber.TabIndex = 4;
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
ButtonAddObject.Location = new Point(856, 55);
|
||||
ButtonAddObject.Name = "ButtonAddObject";
|
||||
ButtonAddObject.Size = new Size(170, 29);
|
||||
ButtonAddObject.TabIndex = 5;
|
||||
ButtonAddObject.Text = "добавить набор";
|
||||
ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
ButtonAddObject.Click += ButtonAddObject_Click;
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(892, 22);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(125, 27);
|
||||
textBoxStorageName.TabIndex = 6;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 20;
|
||||
listBoxStorages.Location = new Point(876, 90);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(150, 104);
|
||||
listBoxStorages.TabIndex = 7;
|
||||
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
ButtonDelObject.Location = new Point(888, 210);
|
||||
ButtonDelObject.Name = "ButtonDelObject";
|
||||
ButtonDelObject.Size = new Size(138, 29);
|
||||
ButtonDelObject.TabIndex = 8;
|
||||
ButtonDelObject.Text = "удалить набор";
|
||||
ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
ButtonDelObject.Click += ButtonDelObject_Click;
|
||||
//
|
||||
// FormLainerCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1038, 490);
|
||||
Controls.Add(ButtonDelObject);
|
||||
Controls.Add(listBoxStorages);
|
||||
Controls.Add(textBoxStorageName);
|
||||
Controls.Add(ButtonAddObject);
|
||||
Controls.Add(maskedTextBoxNumber);
|
||||
Controls.Add(ButtonRefresh);
|
||||
Controls.Add(ButtonRemove);
|
||||
Controls.Add(ButtonAddLainer);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Name = "FormLainerCollection";
|
||||
Text = "FormLainerCollection";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Button ButtonAddLainer;
|
||||
private Button ButtonRemove;
|
||||
private Button ButtonRefresh;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private Button ButtonAddObject;
|
||||
private TextBox textBoxStorageName;
|
||||
private ListBox listBoxStorages;
|
||||
private Button ButtonDelObject;
|
||||
}
|
||||
}
|
141
lainer/Lainer1/FormLainerCollection.cs
Normal file
141
lainer/Lainer1/FormLainerCollection.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.Generics;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public partial class FormLainerCollection : Form
|
||||
{
|
||||
private readonly LainersGenericStorage _storage;
|
||||
public FormLainerCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new LainersGenericStorage(pictureBoxCollection.Width,
|
||||
pictureBoxCollection.Height);
|
||||
}
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
|
||||
foreach (string key in _storage.Keys)
|
||||
{
|
||||
listBoxStorages.Items.Add(key);
|
||||
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 ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||
?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
private void ButtonAddLainer_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var formLinerConfig = new FormLainerConfig();
|
||||
formLinerConfig.AddEvent(AddLainer);
|
||||
formLinerConfig.Show();
|
||||
}
|
||||
private void ButtonRemove_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;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (obj - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowLainers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonRefreshCollection_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.ShowLainers();
|
||||
}
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers();
|
||||
}
|
||||
private void AddLainer(DrawingEntity lainer)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (obj + lainer)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowLainers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
lainer/Lainer1/FormLainerCollection.resx
Normal file
120
lainer/Lainer1/FormLainerCollection.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
367
lainer/Lainer1/FormLainerConfig.Designer.cs
generated
Normal file
367
lainer/Lainer1/FormLainerConfig.Designer.cs
generated
Normal file
@ -0,0 +1,367 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
partial class FormLainerConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelSuper = new Label();
|
||||
labelBase = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelColorCyan = new Panel();
|
||||
panelColorGray = new Panel();
|
||||
panelColorBlue = new Panel();
|
||||
panelColorGreen = new Panel();
|
||||
panelColorBlack = new Panel();
|
||||
panelColorPurple = new Panel();
|
||||
panelColorYellow = new Panel();
|
||||
panelColorRed = new Panel();
|
||||
checkBoxPool = new CheckBox();
|
||||
checkBoxDecks = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelweight = new Label();
|
||||
labelspeed = new Label();
|
||||
pictureBoxDragAndDrop = new PictureBox();
|
||||
panelDragAndDrop = new Panel();
|
||||
labelAddColor = new Label();
|
||||
labelColor = new Label();
|
||||
buttonDone = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).BeginInit();
|
||||
panelDragAndDrop.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelSuper);
|
||||
groupBoxParameters.Controls.Add(labelBase);
|
||||
groupBoxParameters.Controls.Add(groupBoxColors);
|
||||
groupBoxParameters.Controls.Add(checkBoxPool);
|
||||
groupBoxParameters.Controls.Add(checkBoxDecks);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(labelweight);
|
||||
groupBoxParameters.Controls.Add(labelspeed);
|
||||
groupBoxParameters.Location = new Point(12, 12);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(682, 426);
|
||||
groupBoxParameters.TabIndex = 0;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "параметры";
|
||||
//
|
||||
// labelSuper
|
||||
//
|
||||
labelSuper.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSuper.Location = new Point(489, 269);
|
||||
labelSuper.Name = "labelSuper";
|
||||
labelSuper.Size = new Size(124, 43);
|
||||
labelSuper.TabIndex = 8;
|
||||
labelSuper.Text = "продвинутый";
|
||||
labelSuper.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSuper.MouseDown += labelObject_mouseDown;
|
||||
//
|
||||
// labelBase
|
||||
//
|
||||
labelBase.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBase.Location = new Point(322, 269);
|
||||
labelBase.Name = "labelBase";
|
||||
labelBase.Size = new Size(116, 40);
|
||||
labelBase.TabIndex = 7;
|
||||
labelBase.Text = "простой";
|
||||
labelBase.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBase.MouseDown += labelObject_mouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelColorCyan);
|
||||
groupBoxColors.Controls.Add(panelColorGray);
|
||||
groupBoxColors.Controls.Add(panelColorBlue);
|
||||
groupBoxColors.Controls.Add(panelColorGreen);
|
||||
groupBoxColors.Controls.Add(panelColorBlack);
|
||||
groupBoxColors.Controls.Add(panelColorPurple);
|
||||
groupBoxColors.Controls.Add(panelColorYellow);
|
||||
groupBoxColors.Controls.Add(panelColorRed);
|
||||
groupBoxColors.Location = new Point(322, 26);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(354, 228);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "цвета";
|
||||
//
|
||||
// panelColorCyan
|
||||
//
|
||||
panelColorCyan.BackColor = Color.Cyan;
|
||||
panelColorCyan.Location = new Point(256, 124);
|
||||
panelColorCyan.Name = "panelColorCyan";
|
||||
panelColorCyan.Size = new Size(54, 57);
|
||||
panelColorCyan.TabIndex = 7;
|
||||
panelColorCyan.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorGray
|
||||
//
|
||||
panelColorGray.BackColor = SystemColors.ButtonShadow;
|
||||
panelColorGray.Location = new Point(178, 124);
|
||||
panelColorGray.Name = "panelColorGray";
|
||||
panelColorGray.Size = new Size(53, 55);
|
||||
panelColorGray.TabIndex = 6;
|
||||
panelColorGray.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorBlue
|
||||
//
|
||||
panelColorBlue.BackColor = Color.DarkBlue;
|
||||
panelColorBlue.Location = new Point(107, 126);
|
||||
panelColorBlue.Name = "panelColorBlue";
|
||||
panelColorBlue.Size = new Size(51, 53);
|
||||
panelColorBlue.TabIndex = 5;
|
||||
panelColorBlue.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorGreen
|
||||
//
|
||||
panelColorGreen.BackColor = Color.Green;
|
||||
panelColorGreen.Location = new Point(28, 129);
|
||||
panelColorGreen.Name = "panelColorGreen";
|
||||
panelColorGreen.Size = new Size(50, 50);
|
||||
panelColorGreen.TabIndex = 4;
|
||||
panelColorGreen.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorBlack
|
||||
//
|
||||
panelColorBlack.BackColor = SystemColors.ActiveCaptionText;
|
||||
panelColorBlack.Location = new Point(256, 37);
|
||||
panelColorBlack.Name = "panelColorBlack";
|
||||
panelColorBlack.Size = new Size(54, 50);
|
||||
panelColorBlack.TabIndex = 3;
|
||||
panelColorBlack.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorPurple
|
||||
//
|
||||
panelColorPurple.BackColor = Color.DarkOrchid;
|
||||
panelColorPurple.Location = new Point(178, 35);
|
||||
panelColorPurple.Name = "panelColorPurple";
|
||||
panelColorPurple.Size = new Size(53, 52);
|
||||
panelColorPurple.TabIndex = 2;
|
||||
panelColorPurple.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorYellow
|
||||
//
|
||||
panelColorYellow.BackColor = Color.Yellow;
|
||||
panelColorYellow.Location = new Point(107, 35);
|
||||
panelColorYellow.Name = "panelColorYellow";
|
||||
panelColorYellow.Size = new Size(51, 50);
|
||||
panelColorYellow.TabIndex = 1;
|
||||
panelColorYellow.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelColorRed
|
||||
//
|
||||
panelColorRed.BackColor = Color.IndianRed;
|
||||
panelColorRed.Location = new Point(28, 34);
|
||||
panelColorRed.Name = "panelColorRed";
|
||||
panelColorRed.Size = new Size(50, 51);
|
||||
panelColorRed.TabIndex = 0;
|
||||
panelColorRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// checkBoxPool
|
||||
//
|
||||
checkBoxPool.AutoSize = true;
|
||||
checkBoxPool.Location = new Point(34, 230);
|
||||
checkBoxPool.Name = "checkBoxPool";
|
||||
checkBoxPool.Size = new Size(88, 24);
|
||||
checkBoxPool.TabIndex = 5;
|
||||
checkBoxPool.Text = "бассейн";
|
||||
checkBoxPool.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxDecks
|
||||
//
|
||||
checkBoxDecks.AutoSize = true;
|
||||
checkBoxDecks.Location = new Point(34, 172);
|
||||
checkBoxDecks.Name = "checkBoxDecks";
|
||||
checkBoxDecks.Size = new Size(181, 24);
|
||||
checkBoxDecks.TabIndex = 4;
|
||||
checkBoxDecks.Text = "новый вид доп палуб";
|
||||
checkBoxDecks.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(129, 91);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new Size(150, 27);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(129, 47);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new Size(150, 27);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelweight
|
||||
//
|
||||
labelweight.AutoSize = true;
|
||||
labelweight.Location = new Point(19, 91);
|
||||
labelweight.Name = "labelweight";
|
||||
labelweight.Size = new Size(32, 20);
|
||||
labelweight.TabIndex = 1;
|
||||
labelweight.Text = "вес";
|
||||
//
|
||||
// labelspeed
|
||||
//
|
||||
labelspeed.AutoSize = true;
|
||||
labelspeed.Location = new Point(19, 43);
|
||||
labelspeed.Name = "labelspeed";
|
||||
labelspeed.Size = new Size(71, 20);
|
||||
labelspeed.TabIndex = 0;
|
||||
labelspeed.Text = "скорость";
|
||||
//
|
||||
// pictureBoxDragAndDrop
|
||||
//
|
||||
pictureBoxDragAndDrop.Location = new Point(13, 79);
|
||||
pictureBoxDragAndDrop.Name = "pictureBoxDragAndDrop";
|
||||
pictureBoxDragAndDrop.Size = new Size(355, 150);
|
||||
pictureBoxDragAndDrop.TabIndex = 1;
|
||||
pictureBoxDragAndDrop.TabStop = false;
|
||||
//pictureBoxDragAndDrop.Click += pictureBoxDragAndDrop_Click;
|
||||
//
|
||||
// panelDragAndDrop
|
||||
//
|
||||
panelDragAndDrop.AllowDrop = true;
|
||||
panelDragAndDrop.Controls.Add(labelAddColor);
|
||||
panelDragAndDrop.Controls.Add(labelColor);
|
||||
panelDragAndDrop.Controls.Add(pictureBoxDragAndDrop);
|
||||
panelDragAndDrop.Location = new Point(711, 24);
|
||||
panelDragAndDrop.Name = "panelDragAndDrop";
|
||||
panelDragAndDrop.Size = new Size(387, 242);
|
||||
panelDragAndDrop.TabIndex = 2;
|
||||
panelDragAndDrop.DragDrop += panelObject_DragDrop;
|
||||
panelDragAndDrop.DragEnter += panelObject_DragEnter;
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
labelAddColor.AllowDrop = true;
|
||||
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAddColor.Location = new Point(189, 14);
|
||||
labelAddColor.Name = "labelAddColor";
|
||||
labelAddColor.Size = new Size(179, 40);
|
||||
labelAddColor.TabIndex = 9;
|
||||
labelAddColor.Text = "дополнительный цвет";
|
||||
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAddColor.DragDrop += labelAddColor_DragDrop;
|
||||
labelAddColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(13, 14);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(116, 40);
|
||||
labelColor.TabIndex = 8;
|
||||
labelColor.Text = "цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += labelColor_DragDrop;
|
||||
labelColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// buttonDone
|
||||
//
|
||||
buttonDone.Location = new Point(700, 397);
|
||||
buttonDone.Name = "buttonDone";
|
||||
buttonDone.Size = new Size(152, 41);
|
||||
buttonDone.TabIndex = 3;
|
||||
buttonDone.Text = "готово";
|
||||
buttonDone.UseVisualStyleBackColor = true;
|
||||
buttonDone.Click += buttonDone_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(900, 397);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(169, 41);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormLainerConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1110, 450);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonDone);
|
||||
Controls.Add(panelDragAndDrop);
|
||||
Controls.Add(groupBoxParameters);
|
||||
Name = "FormLainerConfig";
|
||||
Text = "FormLainerConfig";
|
||||
DragDrop += panelObject_DragDrop;
|
||||
DragEnter += panelObject_DragEnter;
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.PerformLayout();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).EndInit();
|
||||
panelDragAndDrop.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private CheckBox checkBoxPool;
|
||||
private CheckBox checkBoxDecks;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelweight;
|
||||
private Label labelspeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelColorPurple;
|
||||
private Panel panelColorYellow;
|
||||
private Panel panelColorRed;
|
||||
private Label labelSuper;
|
||||
private Label labelBase;
|
||||
private Panel panelColorCyan;
|
||||
private Panel panelColorGray;
|
||||
private Panel panelColorBlue;
|
||||
private Panel panelColorGreen;
|
||||
private Panel panelColorBlack;
|
||||
private PictureBox pictureBoxDragAndDrop;
|
||||
private Panel panelDragAndDrop;
|
||||
private Label labelAddColor;
|
||||
private Label labelColor;
|
||||
private Button buttonDone;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
114
lainer/Lainer1/FormLainerConfig.cs
Normal file
114
lainer/Lainer1/FormLainerConfig.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.Entities;
|
||||
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public partial class FormLainerConfig : Form
|
||||
{
|
||||
DrawingEntity? _lainer = null;
|
||||
Action<DrawingEntity>? EventAddLainer;
|
||||
public FormLainerConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelColorBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelColorPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelColorGray.MouseDown += PanelColor_MouseDown;
|
||||
panelColorGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelColorRed.MouseDown += PanelColor_MouseDown;
|
||||
panelColorCyan.MouseDown += PanelColor_MouseDown;
|
||||
panelColorYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelColorBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
private void PanelColor_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
private void DrawLainer()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_lainer?.SetPosition(5, 5);
|
||||
_lainer?.DrawTransport(gr);
|
||||
pictureBoxDragAndDrop.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawingEntity> ev)
|
||||
{
|
||||
if (EventAddLainer == null)
|
||||
{
|
||||
EventAddLainer = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddLainer += ev;
|
||||
}
|
||||
}
|
||||
private void labelObject_mouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
private void buttonDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_lainer == null)
|
||||
return;
|
||||
EventAddLainer?.Invoke(_lainer);
|
||||
Close();
|
||||
}
|
||||
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 "labelBase":
|
||||
_lainer = new DrawingEntity((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, 729, 397);
|
||||
break;
|
||||
case "labelSuper":
|
||||
_lainer = new DrawningSuperLainer((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPool.Checked, checkBoxDecks.Checked, pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height);
|
||||
break;
|
||||
}
|
||||
DrawLainer();
|
||||
}
|
||||
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_lainer?.EntityLainer == null)
|
||||
return;
|
||||
Color bodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_lainer.EntityLainer.ChangeColor(bodyColor);
|
||||
DrawLainer();
|
||||
}
|
||||
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void labelAddColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_lainer?.EntityLainer == null) || (_lainer is DrawningSuperLainer == false))
|
||||
return;
|
||||
Color additionalColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((EntitySuperLainer)_lainer.EntityLainer).ChangeAddColor(additionalColor);
|
||||
DrawLainer();
|
||||
}
|
||||
}
|
||||
}
|
120
lainer/Lainer1/FormLainerConfig.resx
Normal file
120
lainer/Lainer1/FormLainerConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
11
lainer/Lainer1/IMoveableObject.cs
Normal file
11
lainer/Lainer1/IMoveableObject.cs
Normal file
@ -0,0 +1,11 @@
|
||||
//using ProjectLainer.Drawings;
|
||||
namespace ProjectLainer.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
26
lainer/Lainer1/Lainer1.csproj
Normal file
26
lainer/Lainer1/Lainer1.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<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>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
11
lainer/Lainer1/LainerDelegate.cs
Normal file
11
lainer/Lainer1/LainerDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectLainer.DrawningObjects;
|
||||
|
||||
namespace Lainers
|
||||
{
|
||||
public delegate void LainerDelegate(DrawingEntity lainer);
|
||||
}
|
188
lainer/Lainer1/LainerForm.Designer.cs
generated
Normal file
188
lainer/Lainer1/LainerForm.Designer.cs
generated
Normal file
@ -0,0 +1,188 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
partial class LainerForm : Form
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxLainer = new PictureBox();
|
||||
ButtonCreate = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonUp = new Button();
|
||||
ButtonCreateSuperLainer = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
ButtonStep = new Button();
|
||||
ButtonSelectLainer = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxLainer
|
||||
//
|
||||
pictureBoxLainer.Dock = DockStyle.Fill;
|
||||
pictureBoxLainer.Location = new Point(0, 0);
|
||||
pictureBoxLainer.Name = "pictureBoxLainer";
|
||||
pictureBoxLainer.Size = new Size(729, 397);
|
||||
pictureBoxLainer.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxLainer.TabIndex = 0;
|
||||
pictureBoxLainer.TabStop = false;
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonCreate.Location = new Point(12, 356);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(94, 29);
|
||||
ButtonCreate.TabIndex = 1;
|
||||
ButtonCreate.Text = "создать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Lainer1.Properties.Resources._3042406;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(659, 315);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 2;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Lainer1.Properties.Resources._2;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(587, 315);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 3;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Lainer1.Properties.Resources._1;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(623, 344);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 4;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Lainer1.Properties.Resources._3;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(623, 287);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 5;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += ButtonMove_Click;
|
||||
//
|
||||
// ButtonCreateSuperLainer
|
||||
//
|
||||
ButtonCreateSuperLainer.Location = new Point(137, 356);
|
||||
ButtonCreateSuperLainer.Name = "ButtonCreateSuperLainer";
|
||||
ButtonCreateSuperLainer.Size = new Size(192, 29);
|
||||
ButtonCreateSuperLainer.TabIndex = 6;
|
||||
ButtonCreateSuperLainer.Text = "создать супер лайнер";
|
||||
ButtonCreateSuperLainer.UseVisualStyleBackColor = true;
|
||||
ButtonCreateSuperLainer.Click += ButtonCreateSuperLainer_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "центр", "край" });
|
||||
comboBoxStrategy.Location = new Point(566, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(151, 28);
|
||||
comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// ButtonStep
|
||||
//
|
||||
ButtonStep.Location = new Point(623, 66);
|
||||
ButtonStep.Name = "ButtonStep";
|
||||
ButtonStep.Size = new Size(94, 29);
|
||||
ButtonStep.TabIndex = 8;
|
||||
ButtonStep.Text = "шаг";
|
||||
ButtonStep.UseVisualStyleBackColor = true;
|
||||
ButtonStep.Click += ButtonStep_Click;
|
||||
//
|
||||
// ButtonSelectLainer
|
||||
//
|
||||
ButtonSelectLainer.Location = new Point(369, 356);
|
||||
ButtonSelectLainer.Name = "ButtonSelectLainer";
|
||||
ButtonSelectLainer.Size = new Size(94, 29);
|
||||
ButtonSelectLainer.TabIndex = 9;
|
||||
ButtonSelectLainer.Text = "выбрать";
|
||||
ButtonSelectLainer.UseVisualStyleBackColor = true;
|
||||
ButtonSelectLainer.Click += ButtonSelectLainer_Click;
|
||||
//
|
||||
// LainerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(729, 397);
|
||||
Controls.Add(ButtonSelectLainer);
|
||||
Controls.Add(ButtonStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(ButtonCreateSuperLainer);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(pictureBoxLainer);
|
||||
Name = "LainerForm";
|
||||
Text = "LainerField";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxLainer;
|
||||
private Button ButtonCreate;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonUp;
|
||||
private Button ButtonCreateSuperLainer;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button ButtonStep;
|
||||
private Button ButtonSelectLainer;
|
||||
}
|
||||
}
|
131
lainer/Lainer1/LainerForm.cs
Normal file
131
lainer/Lainer1/LainerForm.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public partial class LainerForm : Form
|
||||
{
|
||||
private DrawingLainer? _drawningLainer;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
private AbstractStrategy? _strategy;
|
||||
public DrawingLainer? SelectedLainer { get; private set; }
|
||||
public LainerForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
SelectedLainer = null;
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxLainer.Width,
|
||||
pictureBoxLainer.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningLainer.DrawTransport(gr);
|
||||
pictureBoxLainer.Image = bmp;
|
||||
}
|
||||
private void ButtonCreateSuperLainer_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color mainColor = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
Color additColor = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
mainColor = dialog.Color;
|
||||
}
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
additColor = dialog.Color;
|
||||
}
|
||||
_drawningLainer = new DrawningSuperLainer(random.Next(100, 300),
|
||||
random.Next(1000, 3000), mainColor, additColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonCreate_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;
|
||||
}
|
||||
_drawningLainer = new DrawingLainer(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color,
|
||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningLainer.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningLainer.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningLainer.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningLainer.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void ButtonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningLainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(_drawningLainer.GetMoveableObject,
|
||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||
}
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
comboBoxStrategy.Enabled = false;
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
if (_strategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSelectLainer_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedLainer = _drawningLainer;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
120
lainer/Lainer1/LainerForm.resx
Normal file
120
lainer/Lainer1/LainerForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
84
lainer/Lainer1/LainerGenericCollection.cs
Normal file
84
lainer/Lainer1/LainerGenericCollection.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using ProjectLainer.MovementStrategy;
|
||||
using ProjectLainer.DrawningObjects;
|
||||
|
||||
namespace ProjectLainer.Generics
|
||||
{
|
||||
internal class LainersGenericCollection<T, U>
|
||||
where T : DrawingEntity
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
public LainersGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static bool operator +(LainersGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null && collect != null)
|
||||
return collect._collection.Insert(obj);
|
||||
return false;
|
||||
}
|
||||
public static T? operator -(LainersGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowLainers()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{//линия рамзетки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var lainer in _collection.GetLainers())
|
||||
{
|
||||
if (lainer != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
|
||||
lainer.SetPosition((inRow - 1 - (i % inRow)) * _placeSizeWidth, i / inRow * _placeSizeHeight);
|
||||
lainer.DrawTransport(g);
|
||||
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
lainer/Lainer1/LainersGenericStorage.cs
Normal file
47
lainer/Lainer1/LainersGenericStorage.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
namespace ProjectLainer.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции
|
||||
/// </summary>
|
||||
internal class LainersGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, LainersGenericCollection<DrawingEntity, DrawningObjectLainer>> _lainerStorages;
|
||||
public List<string> Keys => _lainerStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
public LainersGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_lainerStorages = new Dictionary<string, LainersGenericCollection<DrawingEntity, DrawningObjectLainer>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
if (!_lainerStorages.ContainsKey(name))
|
||||
{
|
||||
_lainerStorages.Add(name, new LainersGenericCollection<DrawingEntity, DrawningObjectLainer>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
}
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (_lainerStorages.ContainsKey(name))
|
||||
{
|
||||
_lainerStorages.Remove(name);
|
||||
}
|
||||
}
|
||||
public LainersGenericCollection<DrawingEntity, DrawningObjectLainer>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lainerStorages.ContainsKey(ind))
|
||||
{
|
||||
return _lainerStorages[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
58
lainer/Lainer1/MoveToBorder.cs
Normal file
58
lainer/Lainer1/MoveToBorder.cs
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLainer.MovementStrategy
|
||||
{
|
||||
public 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
lainer/Lainer1/MoveToCenter.cs
Normal file
50
lainer/Lainer1/MoveToCenter.cs
Normal file
@ -0,0 +1,50 @@
|
||||
namespace ProjectLainer.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
lainer/Lainer1/ObjectParameters.cs
Normal file
23
lainer/Lainer1/ObjectParameters.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace ProjectLainer.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;
|
||||
}
|
||||
}
|
||||
}
|
17
lainer/Lainer1/Program.cs
Normal file
17
lainer/Lainer1/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace ProjectLainer
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormLainerCollection());
|
||||
}
|
||||
}
|
||||
}
|
75
lainer/Lainer1/SetGeneric.cs
Normal file
75
lainer/Lainer1/SetGeneric.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace ProjectLainer.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
public bool Insert(T lainer)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Insert(lainer, 0);
|
||||
return true;
|
||||
}
|
||||
public bool Insert(T lainer, int position)
|
||||
{
|
||||
if (position < 0 || position > Count || _places.Count >= _maxCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.Insert(position, lainer);
|
||||
return true;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_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?> GetLainers(int? maxLainers = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxLainers.HasValue && i == maxLainers.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
lainer/Lainer1/Status.cs
Normal file
9
lainer/Lainer1/Status.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace ProjectLainer.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user