Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
1778910e97 | |||
9c6850737b | |||
fc2676cfef | |||
5a00ca2c70 | |||
1228318ad1 | |||
11f3168819 |
25
RPP/RPP.sln
Normal file
25
RPP/RPP.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.7.34024.191
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPP", "RPP\RPP.csproj", "{99723B18-4A25-45D0-821A-49A0C3D01FD0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{99723B18-4A25-45D0-821A-49A0C3D01FD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{99723B18-4A25-45D0-821A-49A0C3D01FD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{99723B18-4A25-45D0-821A-49A0C3D01FD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{99723B18-4A25-45D0-821A-49A0C3D01FD0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {943692C3-3EEF-4E93-B0FC-9EE335BE1041}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
71
RPP/RPP/AbstractStrategy.cs
Normal file
71
RPP/RPP/AbstractStrategy.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.MovementStrategy
|
||||||
|
{
|
||||||
|
internal 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(Direction.Left);
|
||||||
|
protected bool MoveRight() => MoveTo(Direction.Right);
|
||||||
|
protected bool MoveUp() => MoveTo(Direction.Up);
|
||||||
|
protected bool MoveDown() => MoveTo(Direction.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(Direction directionType)
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||||
|
{
|
||||||
|
_moveableObject.MoveObject(directionType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
RPP/RPP/AirbusGenericCollection.cs
Normal file
99
RPP/RPP/AirbusGenericCollection.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using RPP.DrawningObjects;
|
||||||
|
using RPP.MovementStrategy;
|
||||||
|
|
||||||
|
namespace RPP.Generics
|
||||||
|
{
|
||||||
|
public class AirbusGenericCollection<T, U>
|
||||||
|
where T : DrawningAirbus
|
||||||
|
where U : IMoveableObject
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
|
private readonly int _placeSizeWidth = 220;
|
||||||
|
|
||||||
|
private readonly int _placeSizeHeight = 120;
|
||||||
|
|
||||||
|
private readonly SetGeneric<T> _collection;
|
||||||
|
public IEnumerable<T?> GetAirbus => _collection.GetAirbus();
|
||||||
|
public AirbusGenericCollection(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 +(AirbusGenericCollection<T, U> collect, T? obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (bool)collect?._collection.Insert(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? operator -(AirbusGenericCollection<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 ShowCars()
|
||||||
|
{
|
||||||
|
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 width = _pictureWidth / _placeSizeWidth;
|
||||||
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var airbus in _collection.GetAirbus())
|
||||||
|
{
|
||||||
|
if (airbus != null)
|
||||||
|
{
|
||||||
|
airbus.SetPosition((width - 1 - (i % width)) * _placeSizeWidth + 12, (height - 1 - (i / width)) * _placeSizeHeight + 10);
|
||||||
|
airbus.DrawTransport(g);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
132
RPP/RPP/AirbusGenericStorage.cs
Normal file
132
RPP/RPP/AirbusGenericStorage.cs
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using RPP.MovementStrategy;
|
||||||
|
using RPP.DrawningObjects;
|
||||||
|
|
||||||
|
|
||||||
|
namespace RPP.Generics
|
||||||
|
{
|
||||||
|
internal class AirbusGenericStorage
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages;
|
||||||
|
|
||||||
|
public List<string> Keys => _airbusStorages.Keys.ToList();
|
||||||
|
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
public AirbusGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_airbusStorages = new Dictionary<string,
|
||||||
|
AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для добавления
|
||||||
|
if (_airbusStorages.ContainsKey(name)) return;
|
||||||
|
_airbusStorages[name] = new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для удаления
|
||||||
|
if (!_airbusStorages.ContainsKey(name)) return;
|
||||||
|
_airbusStorages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>?
|
||||||
|
this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// TODO Продумать логику получения набора
|
||||||
|
if(_airbusStorages.ContainsKey(ind)) return _airbusStorages[ind];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
foreach (KeyValuePair<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> record in _airbusStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawningAirbus? elem in record.Value.GetAirbus)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
|
{
|
||||||
|
writer.WriteLine("AirbusStorage");
|
||||||
|
writer.Write(data.ToString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader reader = new StreamReader(filename))
|
||||||
|
{
|
||||||
|
string checker = reader.ReadLine();
|
||||||
|
if (checker == null)
|
||||||
|
return false;
|
||||||
|
if (!checker.StartsWith("AirbusStorage"))
|
||||||
|
return false;
|
||||||
|
_airbusStorages.Clear();
|
||||||
|
string strs;
|
||||||
|
bool firstinit = true;
|
||||||
|
while ((strs = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (strs == null && firstinit)
|
||||||
|
return false;
|
||||||
|
if (strs == null)
|
||||||
|
break;
|
||||||
|
firstinit = false;
|
||||||
|
string name = strs.Split('|')[0];
|
||||||
|
AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
foreach (string data in strs.Split('|')[1].Split(';'))
|
||||||
|
{
|
||||||
|
DrawningAirbus? car =
|
||||||
|
data?.CreateDrawningAirbus(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (car != null)
|
||||||
|
{
|
||||||
|
if (!(collection + car))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
_airbusStorages.Add(name, collection);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
RPP/RPP/Direction.cs
Normal file
21
RPP/RPP/Direction.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum Direction
|
||||||
|
{
|
||||||
|
|
||||||
|
Up = 1,
|
||||||
|
|
||||||
|
Down = 2,
|
||||||
|
|
||||||
|
Left = 3,
|
||||||
|
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
166
RPP/RPP/DrawningAirbus.cs
Normal file
166
RPP/RPP/DrawningAirbus.cs
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
using RPP.Entities;
|
||||||
|
using RPP.MovementStrategy;
|
||||||
|
|
||||||
|
|
||||||
|
namespace RPP.DrawningObjects
|
||||||
|
|
||||||
|
{
|
||||||
|
public class DrawningAirbus
|
||||||
|
{
|
||||||
|
|
||||||
|
public EntityAirbus? _EntityAirbus { get; protected set; }
|
||||||
|
|
||||||
|
private int _pictureWidth;
|
||||||
|
|
||||||
|
private int _pictureHeight;
|
||||||
|
|
||||||
|
protected int _startPosX;
|
||||||
|
|
||||||
|
protected int _startPosY;
|
||||||
|
|
||||||
|
private readonly int _AirbusWidth = 200;
|
||||||
|
|
||||||
|
private readonly int _AirbusHeight = 100;
|
||||||
|
|
||||||
|
public int GetPosX => _startPosX;
|
||||||
|
|
||||||
|
public int GetPosY => _startPosY;
|
||||||
|
|
||||||
|
public int GetWidth => _AirbusWidth;
|
||||||
|
|
||||||
|
public int GetHeight => _AirbusHeight;
|
||||||
|
|
||||||
|
public bool CanMove(Direction direction)
|
||||||
|
{
|
||||||
|
if (_EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return direction switch
|
||||||
|
{
|
||||||
|
//влево
|
||||||
|
Direction.Left => _startPosX - _EntityAirbus.Step > 5,
|
||||||
|
//вверх
|
||||||
|
Direction.Up => _startPosY - _EntityAirbus.Step > 0,
|
||||||
|
// вправо
|
||||||
|
Direction.Right => _startPosX + _EntityAirbus.Step + _AirbusWidth < _pictureWidth,
|
||||||
|
Direction.Down => _startPosY + _EntityAirbus.Step + _AirbusHeight < _pictureHeight
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawningAirbus(int speed, double weight, Color bodyColor, int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
_EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected DrawningAirbus(int speed, double weight, Color bodyColor, int
|
||||||
|
width, int height, int airbusWidth, int airbusHeight)
|
||||||
|
{
|
||||||
|
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
_AirbusWidth = airbusWidth;
|
||||||
|
_AirbusHeight = airbusHeight;
|
||||||
|
_EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
public void SetBodyColor(Color bodyColor)
|
||||||
|
{
|
||||||
|
_EntityAirbus.ChangeColor(bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
public IMoveableObject GetMoveableObject => new DrawningObjectAirbus(this);
|
||||||
|
|
||||||
|
public void MoveTransport(Direction direction)
|
||||||
|
{
|
||||||
|
if (!CanMove(direction) || _EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
//влево
|
||||||
|
case Direction.Left:
|
||||||
|
if (_startPosX - _EntityAirbus.Step > 5)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)_EntityAirbus.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вверх
|
||||||
|
case Direction.Up:
|
||||||
|
if (_startPosY - _EntityAirbus.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)_EntityAirbus.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вправо
|
||||||
|
case Direction.Right:
|
||||||
|
if (_startPosX + _EntityAirbus.Step + _AirbusWidth < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)_EntityAirbus.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//вниз
|
||||||
|
case Direction.Down:
|
||||||
|
if (_startPosY + _EntityAirbus.Step + _AirbusHeight < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)_EntityAirbus.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public virtual void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (_EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(_EntityAirbus.BodyColor, 3);
|
||||||
|
//Тело
|
||||||
|
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 50, 170, 30);
|
||||||
|
g.DrawPie(pen, _startPosX - 5, _startPosY + 50, 20, 30, 90, 180);
|
||||||
|
Pen whitePen = new(Color.White, 3);
|
||||||
|
g.DrawLine(whitePen, _startPosX + 5, _startPosY + 52, _startPosX + 5, _startPosY + 79);
|
||||||
|
//Заднее крыло
|
||||||
|
g.DrawLine(pen, _startPosX, _startPosY, _startPosX + 50, _startPosY + 50);
|
||||||
|
g.DrawLine(pen, _startPosX, _startPosY, _startPosX, _startPosY + 52);
|
||||||
|
//Заднее боковые крылья
|
||||||
|
|
||||||
|
Pen bigPen = new Pen(_EntityAirbus.BodyColor, 8);
|
||||||
|
g.DrawPie(pen, _startPosX - 7, _startPosY + 45, 5, 10, 90, 180);
|
||||||
|
g.DrawLine(bigPen, _startPosX - 6, _startPosY + 48, _startPosX + 30, _startPosY + 48);
|
||||||
|
g.DrawLine(bigPen, _startPosX - 6, _startPosY + 52, _startPosX + 30, _startPosY + 52);
|
||||||
|
g.DrawPie(pen, _startPosX + 25, _startPosY + 45, 5, 9, 180, 270);
|
||||||
|
//Нос
|
||||||
|
g.DrawLine(pen, _startPosX + 175, _startPosY + 50, _startPosX + 200, _startPosY + 65);
|
||||||
|
g.DrawLine(pen, _startPosX + 200, _startPosY + 65, _startPosX + 175, _startPosY + 80);
|
||||||
|
g.DrawLine(pen, _startPosX + 175, _startPosY + 50, _startPosX + 175, _startPosY + 80);
|
||||||
|
g.DrawLine(pen, _startPosX + 175, _startPosY + 65, _startPosX + 200, _startPosY + 65);
|
||||||
|
//Крылья
|
||||||
|
g.DrawPie(pen, _startPosX + 55, _startPosY + 62, 5, 5, 90, 180);
|
||||||
|
g.DrawLine(bigPen, _startPosX + 56, _startPosY + 65, _startPosX + 140, _startPosY + 65);
|
||||||
|
g.DrawPie(pen, _startPosX + 139, _startPosY + 62, 5, 5, 180, 270);
|
||||||
|
//Задние шасси
|
||||||
|
g.DrawLine(pen, _startPosX + 55, _startPosY + 80, _startPosX + 55, _startPosY + 90);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 47, _startPosY + 90, 5, 5);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 57, _startPosY + 90, 5, 5);
|
||||||
|
//Передние шасси
|
||||||
|
g.DrawLine(pen, _startPosX + 165, _startPosY + 80, _startPosX + 165, _startPosY + 90);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 163, _startPosY + 91, 5, 5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
62
RPP/RPP/DrawningFlyAirbus.cs
Normal file
62
RPP/RPP/DrawningFlyAirbus.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using RPP.Entities;
|
||||||
|
|
||||||
|
namespace RPP.DrawningObjects
|
||||||
|
{
|
||||||
|
internal class DrawningFlyAirbus : DrawningAirbus
|
||||||
|
{
|
||||||
|
|
||||||
|
public DrawningFlyAirbus(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool compartment, bool engine, int width, int height) :
|
||||||
|
base(speed, weight, bodyColor, width, height, 200, 100)
|
||||||
|
{
|
||||||
|
if (_EntityAirbus != null)
|
||||||
|
{
|
||||||
|
_EntityAirbus = new EntityFlyAirbus(speed, weight, bodyColor,
|
||||||
|
additionalColor, compartment, engine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void SetAdditionalColor(Color additionalColor)
|
||||||
|
{
|
||||||
|
(_EntityAirbus as EntityFlyAirbus).ChangedAddColor(additionalColor);
|
||||||
|
}
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (_EntityAirbus is not EntityFlyAirbus FlyAirbus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush additionalBrush = new
|
||||||
|
SolidBrush(FlyAirbus.AdditionalColor);
|
||||||
|
base.DrawTransport(g);
|
||||||
|
// Пассажирский отсек
|
||||||
|
if (FlyAirbus.Compartment)
|
||||||
|
{
|
||||||
|
g.DrawPie(pen, _startPosX + 60, _startPosY + 28, 115, 45, 180, 180);
|
||||||
|
g.FillPie(additionalBrush, _startPosX + 60, _startPosY + 28, 115, 45, 180, 180);
|
||||||
|
}
|
||||||
|
// крыло
|
||||||
|
if (FlyAirbus.Engine)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, _startPosX + 95, _startPosY + 65, _startPosX + 95, _startPosY + 75);
|
||||||
|
Point[] pnts =
|
||||||
|
{
|
||||||
|
new Point(_startPosX + 83, _startPosY + 78),
|
||||||
|
new Point(_startPosX + 103, _startPosY + 73),
|
||||||
|
new Point(_startPosX + 103, _startPosY + 93),
|
||||||
|
new Point(_startPosX + 83, _startPosY + 88),
|
||||||
|
new Point(_startPosX + 83, _startPosY + 78)
|
||||||
|
};
|
||||||
|
|
||||||
|
g.DrawLines(pen, pnts);
|
||||||
|
g.FillPolygon(additionalBrush, pnts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
RPP/RPP/DrawningObjectAirbus.cs
Normal file
36
RPP/RPP/DrawningObjectAirbus.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using RPP.DrawningObjects;
|
||||||
|
|
||||||
|
namespace RPP.MovementStrategy
|
||||||
|
{
|
||||||
|
internal class DrawningObjectAirbus : IMoveableObject
|
||||||
|
{
|
||||||
|
private readonly DrawningAirbus? _drawningAirbus = null;
|
||||||
|
public DrawningObjectAirbus(DrawningAirbus drawningAirbus)
|
||||||
|
{
|
||||||
|
_drawningAirbus = drawningAirbus;
|
||||||
|
}
|
||||||
|
public ObjectParameters? GetObjectPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_drawningAirbus == null || _drawningAirbus._EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ObjectParameters(_drawningAirbus.GetPosX,
|
||||||
|
_drawningAirbus.GetPosY, _drawningAirbus.GetWidth, _drawningAirbus.GetHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int GetStep => (int)(_drawningAirbus?._EntityAirbus?.Step ?? 0);
|
||||||
|
public bool CheckCanMove(Direction direction) =>
|
||||||
|
_drawningAirbus?.CanMove(direction) ?? false;
|
||||||
|
public void MoveObject(Direction direction) =>
|
||||||
|
_drawningAirbus?.MoveTransport(direction);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
31
RPP/RPP/EntityAirbus.cs
Normal file
31
RPP/RPP/EntityAirbus.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.Entities
|
||||||
|
{
|
||||||
|
public class EntityAirbus
|
||||||
|
{
|
||||||
|
|
||||||
|
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 EntityAirbus(int speed, double weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
public void ChangeColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
RPP/RPP/EntityFlyAirbus.cs
Normal file
30
RPP/RPP/EntityFlyAirbus.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.Entities
|
||||||
|
{
|
||||||
|
internal class EntityFlyAirbus : EntityAirbus
|
||||||
|
{
|
||||||
|
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
|
||||||
|
public bool Compartment { get; private set; }
|
||||||
|
|
||||||
|
public bool Engine { get; private set; }
|
||||||
|
|
||||||
|
public EntityFlyAirbus(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool compartment, bool engine) : base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
Compartment = compartment;
|
||||||
|
Engine = engine;
|
||||||
|
}
|
||||||
|
public void ChangedAddColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
RPP/RPP/ExtentionDrawningAirbus.cs
Normal file
50
RPP/RPP/ExtentionDrawningAirbus.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using RPP.Entities;
|
||||||
|
|
||||||
|
namespace RPP.DrawningObjects
|
||||||
|
{
|
||||||
|
public static class ExtentionDrawningAirbus
|
||||||
|
{
|
||||||
|
public static DrawningAirbus? CreateDrawningAirbus(this string info, char
|
||||||
|
separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawningAirbus(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
if (strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawningFlyAirbus(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]),
|
||||||
|
Color.FromName(strs[3]),
|
||||||
|
Convert.ToBoolean(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5]), width, height);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static string GetDataForSave(this DrawningAirbus drawningAirbus,
|
||||||
|
char separatorForObject)
|
||||||
|
{
|
||||||
|
var plane = drawningAirbus._EntityAirbus;
|
||||||
|
if (plane == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str =
|
||||||
|
$"{plane.Speed}{separatorForObject}{plane.Weight}{separatorForObject}{plane.BodyColor.Name}";
|
||||||
|
if (plane is not EntityFlyAirbus FlyAirbus)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
$"{str}{separatorForObject}{FlyAirbus.AdditionalColor.Name}{separatorForObject}{FlyAirbus.Compartment}{separatorForObject}{FlyAirbus.Engine}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
191
RPP/RPP/FormAirbus.Designer.cs
generated
Normal file
191
RPP/RPP/FormAirbus.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
partial class FormAirbus
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
pictureBoxAirbus = new PictureBox();
|
||||||
|
buttonCreateAirbus = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
comboBoxStrategy = new ComboBox();
|
||||||
|
buttonCreateFlyAirbus = new Button();
|
||||||
|
ButtonStep = new Button();
|
||||||
|
ButtonSelectAirbus = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirbus).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAirbus
|
||||||
|
//
|
||||||
|
pictureBoxAirbus.BackColor = SystemColors.Window;
|
||||||
|
pictureBoxAirbus.Dock = DockStyle.Fill;
|
||||||
|
pictureBoxAirbus.Location = new Point(0, 0);
|
||||||
|
pictureBoxAirbus.Name = "pictureBoxAirbus";
|
||||||
|
pictureBoxAirbus.Size = new Size(859, 415);
|
||||||
|
pictureBoxAirbus.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBoxAirbus.TabIndex = 0;
|
||||||
|
pictureBoxAirbus.TabStop = false;
|
||||||
|
pictureBoxAirbus.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateAirbus
|
||||||
|
//
|
||||||
|
buttonCreateAirbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreateAirbus.Location = new Point(196, 342);
|
||||||
|
buttonCreateAirbus.Name = "buttonCreateAirbus";
|
||||||
|
buttonCreateAirbus.Size = new Size(145, 60);
|
||||||
|
buttonCreateAirbus.TabIndex = 1;
|
||||||
|
buttonCreateAirbus.Text = "Создать аэробус";
|
||||||
|
buttonCreateAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateAirbus.Click += ButtonCreateAirbus_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = Properties.Resources.buttonDown;
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonDown.Location = new Point(773, 370);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(26, 22);
|
||||||
|
buttonDown.TabIndex = 2;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackgroundImage = Properties.Resources.buttonLeft;
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonLeft.Location = new Point(741, 370);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(26, 22);
|
||||||
|
buttonLeft.TabIndex = 3;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
buttonLeft.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonUp.BackgroundImage = Properties.Resources.buttonUp;
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonUp.Location = new Point(773, 342);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(26, 22);
|
||||||
|
buttonUp.TabIndex = 4;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = Properties.Resources.buttonRight;
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonRight.Location = new Point(804, 370);
|
||||||
|
buttonRight.Name = "buttonRight";
|
||||||
|
buttonRight.Size = new Size(26, 22);
|
||||||
|
buttonRight.TabIndex = 5;
|
||||||
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
buttonRight.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// comboBoxStrategy
|
||||||
|
//
|
||||||
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
|
comboBoxStrategy.Items.AddRange(new object[] { "0", "1" });
|
||||||
|
comboBoxStrategy.Location = new Point(726, 21);
|
||||||
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
|
comboBoxStrategy.Size = new Size(121, 23);
|
||||||
|
comboBoxStrategy.TabIndex = 6;
|
||||||
|
comboBoxStrategy.SelectedIndexChanged += comboBoxStrategy_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonCreateFlyAirbus
|
||||||
|
//
|
||||||
|
buttonCreateFlyAirbus.Location = new Point(33, 342);
|
||||||
|
buttonCreateFlyAirbus.Name = "buttonCreateFlyAirbus";
|
||||||
|
buttonCreateFlyAirbus.Size = new Size(145, 60);
|
||||||
|
buttonCreateFlyAirbus.TabIndex = 7;
|
||||||
|
buttonCreateFlyAirbus.Text = "Создать пассажирский аэробус";
|
||||||
|
buttonCreateFlyAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateFlyAirbus.Click += buttonCreateFlyAirbus_Click;
|
||||||
|
//
|
||||||
|
// ButtonStep
|
||||||
|
//
|
||||||
|
ButtonStep.Location = new Point(772, 59);
|
||||||
|
ButtonStep.Name = "ButtonStep";
|
||||||
|
ButtonStep.Size = new Size(75, 23);
|
||||||
|
ButtonStep.TabIndex = 8;
|
||||||
|
ButtonStep.Text = "Шаг";
|
||||||
|
ButtonStep.UseVisualStyleBackColor = true;
|
||||||
|
ButtonStep.Click += ButtonStep_Click;
|
||||||
|
//
|
||||||
|
// ButtonSelectAirbus
|
||||||
|
//
|
||||||
|
ButtonSelectAirbus.Location = new Point(357, 342);
|
||||||
|
ButtonSelectAirbus.Name = "ButtonSelectAirbus";
|
||||||
|
ButtonSelectAirbus.Size = new Size(145, 61);
|
||||||
|
ButtonSelectAirbus.TabIndex = 9;
|
||||||
|
ButtonSelectAirbus.Text = "Смена самолета";
|
||||||
|
ButtonSelectAirbus.UseVisualStyleBackColor = true;
|
||||||
|
ButtonSelectAirbus.Click += ButtonSelectAirbus_Click;
|
||||||
|
//
|
||||||
|
// FormAirbus
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(859, 415);
|
||||||
|
Controls.Add(ButtonSelectAirbus);
|
||||||
|
Controls.Add(ButtonStep);
|
||||||
|
Controls.Add(buttonCreateFlyAirbus);
|
||||||
|
Controls.Add(comboBoxStrategy);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonCreateAirbus);
|
||||||
|
Controls.Add(pictureBoxAirbus);
|
||||||
|
Name = "FormAirbus";
|
||||||
|
Text = "Airbus";
|
||||||
|
Load += FormAirbus_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirbus).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAirbus;
|
||||||
|
private Button buttonCreateAirbus;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonRight;
|
||||||
|
private ComboBox comboBoxStrategy;
|
||||||
|
private Button buttonCreateFlyAirbus;
|
||||||
|
private Button ButtonStep;
|
||||||
|
private Button ButtonSelectAirbus;
|
||||||
|
}
|
||||||
|
}
|
159
RPP/RPP/FormAirbus.cs
Normal file
159
RPP/RPP/FormAirbus.cs
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
using RPP.DrawningObjects;
|
||||||
|
using RPP.MovementStrategy;
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
public partial class FormAirbus : Form
|
||||||
|
{
|
||||||
|
private DrawningAirbus? _drawningAirbus;
|
||||||
|
private AbstractStrategy? _abstractStrategy;
|
||||||
|
public DrawningAirbus? SelectedAirbus { get; private set; }
|
||||||
|
public FormAirbus()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_abstractStrategy = null;
|
||||||
|
SelectedAirbus = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBoxAirbus.Width, pictureBoxAirbus.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningAirbus.DrawTransport(gr);
|
||||||
|
pictureBoxAirbus.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreateFlyAirbus_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 AdditionColor = 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)
|
||||||
|
{
|
||||||
|
AdditionColor = dialog.Color;
|
||||||
|
}
|
||||||
|
_drawningAirbus = new DrawningFlyAirbus(random.Next(100, 300),
|
||||||
|
random.Next(1000, 3000),
|
||||||
|
MainColor, AdditionColor,
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
pictureBoxAirbus.Width, pictureBoxAirbus.Height);
|
||||||
|
_drawningAirbus.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreateAirbus_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;
|
||||||
|
}
|
||||||
|
_drawningAirbus = new DrawningAirbus(random.Next(100, 300),
|
||||||
|
random.Next(1000, 3000), color,
|
||||||
|
pictureBoxAirbus.Width, pictureBoxAirbus.Height);
|
||||||
|
_drawningAirbus.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((System.Windows.Forms.Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
_drawningAirbus.MoveTransport(Direction.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
_drawningAirbus.MoveTransport(Direction.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
_drawningAirbus.MoveTransport(Direction.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
_drawningAirbus.MoveTransport(Direction.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonStep_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxStrategy.Enabled)
|
||||||
|
{
|
||||||
|
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||||
|
switch
|
||||||
|
{
|
||||||
|
0 => new MoveToCenter(),
|
||||||
|
1 => new MoveToBorder(),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
if (_abstractStrategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_abstractStrategy.SetData(_drawningAirbus.GetMoveableObject, pictureBoxAirbus.Width,
|
||||||
|
pictureBoxAirbus.Height);
|
||||||
|
comboBoxStrategy.Enabled = false;
|
||||||
|
}
|
||||||
|
if (_abstractStrategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_abstractStrategy.MakeStep();
|
||||||
|
Draw();
|
||||||
|
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||||
|
{
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_abstractStrategy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSelectAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedAirbus = _drawningAirbus;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pictureBoxAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAirbus_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
RPP/RPP/FormAirbus.resx
Normal file
120
RPP/RPP/FormAirbus.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>
|
281
RPP/RPP/FormAirbusCollection.Designer.cs
generated
Normal file
281
RPP/RPP/FormAirbusCollection.Designer.cs
generated
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
partial class FormAirbusCollection
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
panel1 = new Panel();
|
||||||
|
panel2 = new Panel();
|
||||||
|
buttonDelObject = new Button();
|
||||||
|
listBoxStorages = new ListBox();
|
||||||
|
buttonAddObject = new Button();
|
||||||
|
textBoxStorageName = new TextBox();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
ButtonRefreshCollection = new Button();
|
||||||
|
ButtonRemoveAirbus = new Button();
|
||||||
|
maskedTextBoxNumber = new TextBox();
|
||||||
|
AddAirbusButton = new Button();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
menuToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
pictureBoxCollection = new PictureBox();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
panel2.SuspendLayout();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(panel2);
|
||||||
|
panel1.Controls.Add(ButtonRefreshCollection);
|
||||||
|
panel1.Controls.Add(ButtonRemoveAirbus);
|
||||||
|
panel1.Controls.Add(maskedTextBoxNumber);
|
||||||
|
panel1.Controls.Add(AddAirbusButton);
|
||||||
|
panel1.Controls.Add(menuStrip);
|
||||||
|
panel1.Dock = DockStyle.Right;
|
||||||
|
panel1.Location = new Point(682, 0);
|
||||||
|
panel1.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(232, 600);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
panel1.Paint += panel1_Paint;
|
||||||
|
//
|
||||||
|
// panel2
|
||||||
|
//
|
||||||
|
panel2.Controls.Add(buttonDelObject);
|
||||||
|
panel2.Controls.Add(listBoxStorages);
|
||||||
|
panel2.Controls.Add(buttonAddObject);
|
||||||
|
panel2.Controls.Add(textBoxStorageName);
|
||||||
|
panel2.Controls.Add(label2);
|
||||||
|
panel2.Controls.Add(label1);
|
||||||
|
panel2.Location = new Point(3, 36);
|
||||||
|
panel2.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panel2.Name = "panel2";
|
||||||
|
panel2.Size = new Size(219, 292);
|
||||||
|
panel2.TabIndex = 5;
|
||||||
|
panel2.Paint += panel2_Paint;
|
||||||
|
//
|
||||||
|
// buttonDelObject
|
||||||
|
//
|
||||||
|
buttonDelObject.Location = new Point(15, 240);
|
||||||
|
buttonDelObject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDelObject.Name = "buttonDelObject";
|
||||||
|
buttonDelObject.Size = new Size(197, 48);
|
||||||
|
buttonDelObject.TabIndex = 4;
|
||||||
|
buttonDelObject.Text = "Удалить набор";
|
||||||
|
buttonDelObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelObject.Click += ButtonDelObject_Click;
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
listBoxStorages.FormattingEnabled = true;
|
||||||
|
listBoxStorages.ItemHeight = 20;
|
||||||
|
listBoxStorages.Location = new Point(15, 127);
|
||||||
|
listBoxStorages.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
|
listBoxStorages.Size = new Size(196, 104);
|
||||||
|
listBoxStorages.TabIndex = 3;
|
||||||
|
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonAddObject
|
||||||
|
//
|
||||||
|
buttonAddObject.Location = new Point(15, 64);
|
||||||
|
buttonAddObject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAddObject.Name = "buttonAddObject";
|
||||||
|
buttonAddObject.Size = new Size(197, 55);
|
||||||
|
buttonAddObject.TabIndex = 2;
|
||||||
|
buttonAddObject.Text = "Добавить набор";
|
||||||
|
buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddObject.Click += ButtonAddObject_Click;
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(15, 25);
|
||||||
|
textBoxStorageName.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(196, 27);
|
||||||
|
textBoxStorageName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(17, 0);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(66, 20);
|
||||||
|
label2.TabIndex = 0;
|
||||||
|
label2.Text = "Наборы";
|
||||||
|
label2.Click += label2_Click;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(117, 1);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(0, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonRefreshCollection
|
||||||
|
//
|
||||||
|
ButtonRefreshCollection.Location = new Point(8, 531);
|
||||||
|
ButtonRefreshCollection.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||||
|
ButtonRefreshCollection.Size = new Size(217, 53);
|
||||||
|
ButtonRefreshCollection.TabIndex = 4;
|
||||||
|
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||||
|
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
|
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||||
|
//
|
||||||
|
// ButtonRemoveAirbus
|
||||||
|
//
|
||||||
|
ButtonRemoveAirbus.Location = new Point(6, 436);
|
||||||
|
ButtonRemoveAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonRemoveAirbus.Name = "ButtonRemoveAirbus";
|
||||||
|
ButtonRemoveAirbus.Size = new Size(217, 53);
|
||||||
|
ButtonRemoveAirbus.TabIndex = 3;
|
||||||
|
ButtonRemoveAirbus.Text = "Удалить аэробус";
|
||||||
|
ButtonRemoveAirbus.UseVisualStyleBackColor = true;
|
||||||
|
ButtonRemoveAirbus.Click += ButtonRemoveAirbus_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
maskedTextBoxNumber.Location = new Point(46, 397);
|
||||||
|
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
maskedTextBoxNumber.Size = new Size(111, 27);
|
||||||
|
maskedTextBoxNumber.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// AddAirbusButton
|
||||||
|
//
|
||||||
|
AddAirbusButton.Location = new Point(6, 336);
|
||||||
|
AddAirbusButton.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
AddAirbusButton.Name = "AddAirbusButton";
|
||||||
|
AddAirbusButton.Size = new Size(217, 53);
|
||||||
|
AddAirbusButton.TabIndex = 1;
|
||||||
|
AddAirbusButton.Text = "Добавить аэробус";
|
||||||
|
AddAirbusButton.UseVisualStyleBackColor = true;
|
||||||
|
AddAirbusButton.Click += AddAirbusButton_Click;
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { menuToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip.Size = new Size(232, 30);
|
||||||
|
menuStrip.TabIndex = 6;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// menuToolStripMenuItem
|
||||||
|
//
|
||||||
|
menuToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
menuToolStripMenuItem.Name = "menuToolStripMenuItem";
|
||||||
|
menuToolStripMenuItem.Size = new Size(65, 24);
|
||||||
|
menuToolStripMenuItem.Text = "Меню";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
SaveToolStripMenuItem.Text = "Сохранить";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
LoadToolStripMenuItem.Text = "Загрузить";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// pictureBoxCollection
|
||||||
|
//
|
||||||
|
pictureBoxCollection.Dock = DockStyle.Fill;
|
||||||
|
pictureBoxCollection.Location = new Point(0, 0);
|
||||||
|
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
|
pictureBoxCollection.Size = new Size(682, 600);
|
||||||
|
pictureBoxCollection.TabIndex = 1;
|
||||||
|
pictureBoxCollection.TabStop = false;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.FileName = "openFileDialog1";
|
||||||
|
//
|
||||||
|
// FormAirbusCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(914, 600);
|
||||||
|
Controls.Add(pictureBoxCollection);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormAirbusCollection";
|
||||||
|
Text = "FormFlyAirbus";
|
||||||
|
Load += FormFlyAirbus_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
panel2.ResumeLayout(false);
|
||||||
|
panel2.PerformLayout();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button AddAirbusButton;
|
||||||
|
private Label label1;
|
||||||
|
private PictureBox pictureBoxCollection;
|
||||||
|
private Button ButtonRefreshCollection;
|
||||||
|
private Button ButtonRemoveAirbus;
|
||||||
|
private TextBox maskedTextBoxNumber;
|
||||||
|
private Panel panel2;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Button buttonAddObject;
|
||||||
|
private Button buttonDelObject;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private ToolStripMenuItem menuToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
195
RPP/RPP/FormAirbusCollection.cs
Normal file
195
RPP/RPP/FormAirbusCollection.cs
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
using RPP.DrawningObjects;
|
||||||
|
using RPP.Generics;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
public partial class FormAirbusCollection : Form
|
||||||
|
{
|
||||||
|
private readonly AirbusGenericStorage _storage;
|
||||||
|
|
||||||
|
public FormAirbusCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storage = new AirbusGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormFlyAirbus_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
private void AddAirbus(DrawningAirbus Airbus)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (obj + Airbus)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowCars();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void AddAirbusButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var formAirbusConfig = new FormAirbusConfig();
|
||||||
|
formAirbusConfig.Show();
|
||||||
|
formAirbusConfig.AddEvent(AddAirbus);
|
||||||
|
}
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorages.SelectedIndex;
|
||||||
|
listBoxStorages.Items.Clear();
|
||||||
|
foreach (var 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 ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCars();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ButtonRemoveAirbus_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.ShowCars();
|
||||||
|
}
|
||||||
|
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.ShowCars();
|
||||||
|
}
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.SaveData(saveFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
ReloadObjects();
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panel2_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void label2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panel1_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
129
RPP/RPP/FormAirbusCollection.resx
Normal file
129
RPP/RPP/FormAirbusCollection.resx
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>291, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>152, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
378
RPP/RPP/FormAirbusConfig.Designer.cs
generated
Normal file
378
RPP/RPP/FormAirbusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,378 @@
|
|||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
partial class FormAirbusConfig
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
labelFly = new Label();
|
||||||
|
labelBase = new Label();
|
||||||
|
groupBoxColor = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxEngine = new CheckBox();
|
||||||
|
checkBoxCompartment = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
label2 = new Label();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
label1 = new Label();
|
||||||
|
panel9 = new Panel();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
labelColor = new Label();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBoxParameters.SuspendLayout();
|
||||||
|
groupBoxColor.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
panel9.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxParameters
|
||||||
|
//
|
||||||
|
groupBoxParameters.Controls.Add(labelFly);
|
||||||
|
groupBoxParameters.Controls.Add(labelBase);
|
||||||
|
groupBoxParameters.Controls.Add(groupBoxColor);
|
||||||
|
groupBoxParameters.Controls.Add(checkBoxEngine);
|
||||||
|
groupBoxParameters.Controls.Add(checkBoxCompartment);
|
||||||
|
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBoxParameters.Controls.Add(label2);
|
||||||
|
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBoxParameters.Controls.Add(label1);
|
||||||
|
groupBoxParameters.Location = new Point(14, 16);
|
||||||
|
groupBoxParameters.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBoxParameters.Name = "groupBoxParameters";
|
||||||
|
groupBoxParameters.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBoxParameters.Size = new Size(627, 368);
|
||||||
|
groupBoxParameters.TabIndex = 0;
|
||||||
|
groupBoxParameters.TabStop = false;
|
||||||
|
groupBoxParameters.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelFly
|
||||||
|
//
|
||||||
|
labelFly.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelFly.Location = new Point(446, 292);
|
||||||
|
labelFly.Name = "labelFly";
|
||||||
|
labelFly.Size = new Size(135, 47);
|
||||||
|
labelFly.TabIndex = 8;
|
||||||
|
labelFly.Text = "Продвинутый";
|
||||||
|
labelFly.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelFly.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelBase
|
||||||
|
//
|
||||||
|
labelBase.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelBase.Location = new Point(291, 292);
|
||||||
|
labelBase.Name = "labelBase";
|
||||||
|
labelBase.Size = new Size(129, 47);
|
||||||
|
labelBase.TabIndex = 7;
|
||||||
|
labelBase.Text = "Простой";
|
||||||
|
labelBase.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelBase.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBoxColor
|
||||||
|
//
|
||||||
|
groupBoxColor.Controls.Add(panelPurple);
|
||||||
|
groupBoxColor.Controls.Add(panelBlack);
|
||||||
|
groupBoxColor.Controls.Add(panelGray);
|
||||||
|
groupBoxColor.Controls.Add(panelWhite);
|
||||||
|
groupBoxColor.Controls.Add(panelYellow);
|
||||||
|
groupBoxColor.Controls.Add(panelBlue);
|
||||||
|
groupBoxColor.Controls.Add(panelGreen);
|
||||||
|
groupBoxColor.Controls.Add(panelRed);
|
||||||
|
groupBoxColor.Location = new Point(272, 40);
|
||||||
|
groupBoxColor.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBoxColor.Name = "groupBoxColor";
|
||||||
|
groupBoxColor.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBoxColor.Size = new Size(327, 223);
|
||||||
|
groupBoxColor.TabIndex = 6;
|
||||||
|
groupBoxColor.TabStop = false;
|
||||||
|
groupBoxColor.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(255, 129);
|
||||||
|
panelPurple.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(54, 59);
|
||||||
|
panelPurple.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(174, 129);
|
||||||
|
panelBlack.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(54, 59);
|
||||||
|
panelBlack.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(95, 129);
|
||||||
|
panelGray.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(54, 59);
|
||||||
|
panelGray.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(19, 129);
|
||||||
|
panelWhite.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(54, 59);
|
||||||
|
panelWhite.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(255, 43);
|
||||||
|
panelYellow.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(54, 60);
|
||||||
|
panelYellow.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(174, 43);
|
||||||
|
panelBlue.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(54, 60);
|
||||||
|
panelBlue.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Green;
|
||||||
|
panelGreen.Location = new Point(95, 43);
|
||||||
|
panelGreen.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(54, 60);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(19, 43);
|
||||||
|
panelRed.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(54, 59);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxEngine
|
||||||
|
//
|
||||||
|
checkBoxEngine.AutoSize = true;
|
||||||
|
checkBoxEngine.Location = new Point(17, 264);
|
||||||
|
checkBoxEngine.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxEngine.Name = "checkBoxEngine";
|
||||||
|
checkBoxEngine.Size = new Size(269, 24);
|
||||||
|
checkBoxEngine.TabIndex = 5;
|
||||||
|
checkBoxEngine.Text = "Признак наличия доп. двигателей";
|
||||||
|
checkBoxEngine.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxCompartment
|
||||||
|
//
|
||||||
|
checkBoxCompartment.AutoSize = true;
|
||||||
|
checkBoxCompartment.Location = new Point(17, 203);
|
||||||
|
checkBoxCompartment.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxCompartment.Name = "checkBoxCompartment";
|
||||||
|
checkBoxCompartment.Size = new Size(236, 24);
|
||||||
|
checkBoxCompartment.TabIndex = 4;
|
||||||
|
checkBoxCompartment.Text = "Признак наличия доп. отсека";
|
||||||
|
checkBoxCompartment.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(95, 89);
|
||||||
|
numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
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(79, 27);
|
||||||
|
numericUpDownWeight.TabIndex = 3;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(17, 89);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(36, 20);
|
||||||
|
label2.TabIndex = 2;
|
||||||
|
label2.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(95, 36);
|
||||||
|
numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
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(79, 27);
|
||||||
|
numericUpDownSpeed.TabIndex = 1;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(17, 39);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(76, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// panel9
|
||||||
|
//
|
||||||
|
panel9.AllowDrop = true;
|
||||||
|
panel9.Controls.Add(pictureBoxObject);
|
||||||
|
panel9.Location = new Point(675, 87);
|
||||||
|
panel9.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panel9.Name = "panel9";
|
||||||
|
panel9.Size = new Size(354, 244);
|
||||||
|
panel9.TabIndex = 1;
|
||||||
|
panel9.DragDrop += PanelObject_DragDrop;
|
||||||
|
panel9.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(27, 4);
|
||||||
|
pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(323, 236);
|
||||||
|
pictureBoxObject.TabIndex = 2;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(870, 35);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(133, 47);
|
||||||
|
labelAdditionalColor.TabIndex = 1;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += labelColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelColor
|
||||||
|
//
|
||||||
|
labelColor.AllowDrop = true;
|
||||||
|
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelColor.Location = new Point(703, 35);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(133, 47);
|
||||||
|
labelColor.TabIndex = 0;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += labelColor_DragDrop;
|
||||||
|
labelColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(703, 339);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(134, 45);
|
||||||
|
buttonAdd.TabIndex = 2;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonOk_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(870, 339);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(134, 45);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormAirbusConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1057, 400);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(labelAdditionalColor);
|
||||||
|
Controls.Add(labelColor);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(panel9);
|
||||||
|
Controls.Add(groupBoxParameters);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormAirbusConfig";
|
||||||
|
Text = "FormAirbusConfig";
|
||||||
|
Load += FormAirbusConfig_Load;
|
||||||
|
groupBoxParameters.ResumeLayout(false);
|
||||||
|
groupBoxParameters.PerformLayout();
|
||||||
|
groupBoxColor.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
panel9.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxParameters;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label label1;
|
||||||
|
private CheckBox checkBoxCompartment;
|
||||||
|
private GroupBox groupBoxColor;
|
||||||
|
private CheckBox checkBoxEngine;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private Label labelFly;
|
||||||
|
private Label labelBase;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panel9;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelColor;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
170
RPP/RPP/FormAirbusConfig.cs
Normal file
170
RPP/RPP/FormAirbusConfig.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using RPP.DrawningObjects;
|
||||||
|
using RPP.Entities;
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
public delegate void AirbusDelegate(DrawningAirbus Airbus);
|
||||||
|
public partial class FormAirbusConfig : Form
|
||||||
|
{
|
||||||
|
DrawningAirbus? _airbus = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningAirbus>? EventAddAirbus;
|
||||||
|
|
||||||
|
public FormAirbusConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += panelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += panelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += panelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += panelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += panelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += panelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += panelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += panelColor_MouseDown;
|
||||||
|
|
||||||
|
buttonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAirbusConfig_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовать машину
|
||||||
|
/// </summary>
|
||||||
|
private void DrawAirbus()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_airbus?.SetPosition(15, 5);
|
||||||
|
if (_airbus is DrawningFlyAirbus drawningFlyAirbus)
|
||||||
|
drawningFlyAirbus.DrawTransport(gr);
|
||||||
|
else
|
||||||
|
_airbus?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||||
|
DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelBase":
|
||||||
|
_airbus = new DrawningAirbus((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelFly":
|
||||||
|
_airbus = new DrawningFlyAirbus((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||||
|
checkBoxCompartment.Checked, checkBoxEngine.Checked, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawAirbus();
|
||||||
|
}
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev">Привязанный метод</param>
|
||||||
|
public void AddEvent(Action<DrawningAirbus> ev)
|
||||||
|
{
|
||||||
|
if (EventAddAirbus == null)
|
||||||
|
{
|
||||||
|
EventAddAirbus = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddAirbus += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление машины
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddAirbus?.Invoke(_airbus);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_airbus == null)
|
||||||
|
return;
|
||||||
|
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelColor":
|
||||||
|
_airbus.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAdditionalColor":
|
||||||
|
if (!(_airbus is DrawningFlyAirbus))
|
||||||
|
return;
|
||||||
|
(_airbus as DrawningFlyAirbus).SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawAirbus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
120
RPP/RPP/FormAirbusConfig.resx
Normal file
120
RPP/RPP/FormAirbusConfig.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>
|
21
RPP/RPP/IMoveableObject.cs
Normal file
21
RPP/RPP/IMoveableObject.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.MovementStrategy
|
||||||
|
{
|
||||||
|
public interface IMoveableObject
|
||||||
|
{
|
||||||
|
|
||||||
|
ObjectParameters? GetObjectPosition { get; }
|
||||||
|
|
||||||
|
int GetStep { get; }
|
||||||
|
|
||||||
|
bool CheckCanMove(Direction direction);
|
||||||
|
|
||||||
|
void MoveObject(Direction direction);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
49
RPP/RPP/MoveToBorder.cs
Normal file
49
RPP/RPP/MoveToBorder.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using RPP.MovementStrategy;
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
internal class MoveToBorder : AbstractStrategy
|
||||||
|
{
|
||||||
|
protected override bool IsTargetDestinaion()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
||||||
|
}
|
||||||
|
protected override void MoveToTarget()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var diffX = objParams.RightBorder - FieldWidth;
|
||||||
|
var diffY = objParams.DownBorder - FieldHeight;
|
||||||
|
if (diffX >= 0)
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
else if (diffY >= 0)
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
else if (Math.Abs(diffX) > Math.Abs(diffY))
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
RPP/RPP/MoveToCenter.cs
Normal file
56
RPP/RPP/MoveToCenter.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.MovementStrategy
|
||||||
|
{
|
||||||
|
internal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
RPP/RPP/ObjectParameters.cs
Normal file
36
RPP/RPP/ObjectParameters.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
RPP/RPP/Program.cs
Normal file
18
RPP/RPP/Program.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
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 FormAirbusCollection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
RPP/RPP/Properties/Resources.Designer.cs
generated
Normal file
103
RPP/RPP/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace RPP.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RPP.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap buttonDown {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("buttonDown", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap buttonLeft {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("buttonLeft", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap buttonRight {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("buttonRight", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap buttonUp {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("buttonUp", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
RPP/RPP/Properties/Resources.resx
Normal file
133
RPP/RPP/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="buttonLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\buttonLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\buttonRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\buttonDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\buttonUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
26
RPP/RPP/RPP.csproj
Normal file
26
RPP/RPP/RPP.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>
|
BIN
RPP/RPP/Resources/buttonDown.png
Normal file
BIN
RPP/RPP/Resources/buttonDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 549 B |
BIN
RPP/RPP/Resources/buttonLeft.png
Normal file
BIN
RPP/RPP/Resources/buttonLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 542 B |
BIN
RPP/RPP/Resources/buttonRight.png
Normal file
BIN
RPP/RPP/Resources/buttonRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 532 B |
BIN
RPP/RPP/Resources/buttonUp.png
Normal file
BIN
RPP/RPP/Resources/buttonUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 535 B |
91
RPP/RPP/SetGeneric.cs
Normal file
91
RPP/RPP/SetGeneric.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP.Generics
|
||||||
|
{
|
||||||
|
public 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?>(_maxCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Insert(T airbus)
|
||||||
|
{
|
||||||
|
return Insert(airbus, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Insert(T airbus, int position)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Count >= _maxCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_places.Insert(0, airbus);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (position >= Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_places.RemoveAt(position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
return null;
|
||||||
|
if (_places.Count <= position)
|
||||||
|
return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
return;
|
||||||
|
if (_places.Count <= position)
|
||||||
|
return;
|
||||||
|
_places[position] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<T?> GetAirbus(int? maxAirbus = null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _places.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if (maxAirbus.HasValue && i == maxAirbus.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
15
RPP/RPP/Status.cs
Normal file
15
RPP/RPP/Status.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RPP
|
||||||
|
{
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
InProgress = 1,
|
||||||
|
Finish = 2,
|
||||||
|
NotInit = 0
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user