Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
lainer/Lainer1/EntityLainer.cs
Normal file
16
lainer/Lainer1/EntityLainer.cs
Normal file
@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
16
lainer/Lainer1/EntitySuperLainer.cs
Normal file
16
lainer/Lainer1/EntitySuperLainer.cs
Normal file
@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
109
lainer/Lainer1/FormLainerCollection.Designer.cs
generated
Normal file
109
lainer/Lainer1/FormLainerCollection.Designer.cs
generated
Normal file
@ -0,0 +1,109 @@
|
||||
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();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location = new Point(16, 14);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(781, 297);
|
||||
pictureBoxCollection.TabIndex = 0;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// ButtonAddLainer
|
||||
//
|
||||
ButtonAddLainer.Location = new Point(813, 40);
|
||||
ButtonAddLainer.Name = "ButtonAddLainer";
|
||||
ButtonAddLainer.Size = new Size(154, 52);
|
||||
ButtonAddLainer.TabIndex = 1;
|
||||
ButtonAddLainer.Text = "добавить лайнер";
|
||||
ButtonAddLainer.UseVisualStyleBackColor = true;
|
||||
ButtonAddLainer.Click += ButtonAddLainer_Click;
|
||||
//
|
||||
// ButtonRemove
|
||||
//
|
||||
ButtonRemove.Location = new Point(812, 158);
|
||||
ButtonRemove.Name = "ButtonRemove";
|
||||
ButtonRemove.Size = new Size(139, 65);
|
||||
ButtonRemove.TabIndex = 2;
|
||||
ButtonRemove.Text = "удалить лайнер";
|
||||
ButtonRemove.UseVisualStyleBackColor = true;
|
||||
ButtonRemove.Click += ButtonRemove_Click;
|
||||
//
|
||||
// ButtonRefresh
|
||||
//
|
||||
ButtonRefresh.Location = new Point(803, 247);
|
||||
ButtonRefresh.Name = "ButtonRefresh";
|
||||
ButtonRefresh.Size = new Size(164, 54);
|
||||
ButtonRefresh.TabIndex = 3;
|
||||
ButtonRefresh.Text = "обновить коллекцию";
|
||||
ButtonRefresh.UseVisualStyleBackColor = true;
|
||||
ButtonRefresh.Click += ButtonRefresh_Click;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Location = new Point(826, 111);
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(125, 27);
|
||||
maskedTextBoxNumber.TabIndex = 4;
|
||||
//
|
||||
// FormLainerCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1003, 450);
|
||||
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;
|
||||
}
|
||||
}
|
59
lainer/Lainer1/FormLainerCollection.cs
Normal file
59
lainer/Lainer1/FormLainerCollection.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using ProjectLainer.Generics;
|
||||
using ProjectLainer.MovementStrategy;
|
||||
|
||||
namespace ProjectLainer
|
||||
{
|
||||
public partial class FormLainerCollection : Form
|
||||
{
|
||||
private readonly LainersGenericCollection<DrawingLainer, DrawningObjectLainer> _lainers;
|
||||
public FormLainerCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_lainers = new LainersGenericCollection<DrawingLainer, DrawningObjectLainer>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
private void ButtonAddLainer_Click(object sender, EventArgs e)
|
||||
{
|
||||
LainerForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_lainers + form.SelectedLainer)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (_lainers - pos == true)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
catch { MessageBox.Show("Не удалось удалить объект"); }
|
||||
|
||||
}
|
||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||||
}
|
||||
}
|
||||
}
|
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>
|
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>
|
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>
|
105
lainer/Lainer1/LainerGenericCollection.cs
Normal file
105
lainer/Lainer1/LainerGenericCollection.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using ProjectLainer.MovementStrategy;
|
||||
using ProjectLainer.DrawningObjects;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ProjectLainer.Generics
|
||||
{
|
||||
internal class LainersGenericCollection<T, U>
|
||||
where T : DrawingLainer
|
||||
where U : IMoveableObject
|
||||
{
|
||||
|
||||
private readonly int _pictureWidth;
|
||||
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
|
||||
public 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)
|
||||
{
|
||||
var value = collect._collection.Insert(obj);
|
||||
if(value <= collect._collection.Count && value >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
public static bool? operator -(LainersGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
{
|
||||
T? obj = collect?._collection.Get(pos);
|
||||
if (obj != null && collect != null)
|
||||
{
|
||||
return collect._collection.Remove(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(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)
|
||||
{
|
||||
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
{
|
||||
DrawingLainer? lainer = _collection.Get(i);
|
||||
if (lainer != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
|
||||
lainer.SetPosition((inRow - 1 - (i % inRow)) * _placeSizeWidth, i / inRow * _placeSizeHeight);
|
||||
lainer.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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());
|
||||
}
|
||||
}
|
||||
}
|
61
lainer/Lainer1/SetGeneric.cs
Normal file
61
lainer/Lainer1/SetGeneric.cs
Normal file
@ -0,0 +1,61 @@
|
||||
namespace ProjectLainer.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly T?[] _places;
|
||||
public int Count => _places.Length;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
|
||||
public int Insert(T lainer)
|
||||
{
|
||||
if (_places[Count - 1] != null)
|
||||
return Count;
|
||||
return Insert(lainer, 0);
|
||||
}
|
||||
public int Insert(T lainer, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
if (_places[position] != null)
|
||||
{
|
||||
int ind = position;
|
||||
while (ind < Count && _places[ind] != null)
|
||||
ind++;
|
||||
if (ind == Count)
|
||||
return Count;
|
||||
for (int i = ind - 1; i >= position; i--)
|
||||
_places[i + 1] = _places[i];
|
||||
}
|
||||
_places[position] = lainer;
|
||||
return position;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(position >= Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
public T? Get(int position)
|
||||
{
|
||||
if(position < Count && position >= 0)
|
||||
{
|
||||
return _places[position];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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…
Reference in New Issue
Block a user