Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
42340ec4b6 | |||
d95866ee89 | |||
4b53ad808a | |||
6018455bd6 | |||
4acd470e61 | |||
8d4cfb88f8 | |||
d745ee3256 | |||
eca2e72650 | |||
ca85f1e742 | |||
a4a92891e4 | |||
23aab7e7ff | |||
74809ae964 | |||
0e5c5075be | |||
026b4edb42 | |||
9049215779 | |||
96068db4e3 | |||
96e545ebe9 | |||
a417304c88 | |||
fd4f65371f | |||
c140837bbc | |||
c65afdd7f2 | |||
52cb0fbc5f | |||
e87befc5c8 | |||
e894512155 | |||
2cb8879ca8 | |||
4b83795a95 | |||
39427a0253 | |||
81df5ff147 | |||
cf522af8d5 | |||
b7fcd7442e | |||
f05bcfe958 | |||
|
b4c5865353 |
25
Airbus.sln
Normal file
25
Airbus.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.5.33530.505
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectAirbus", "AirBus\ProjectAirbus.csproj", "{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {68EF553D-50EC-43AA-B0A4-B69F4A00F3FD}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
166
Airbus/Drawnings/DrawningAirbus.cs
Normal file
166
Airbus/Drawnings/DrawningAirbus.cs
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
using ProjectAirbus.MovementStrategy;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Drawnings
|
||||||
|
{
|
||||||
|
public class DrawningAirbus
|
||||||
|
{
|
||||||
|
public EntityAirbus? EntityAirbus { get; protected set; }
|
||||||
|
private int _pictureWidth;
|
||||||
|
private int _pictureHeight;
|
||||||
|
|
||||||
|
protected int _startPosX;
|
||||||
|
protected int _startPosY;
|
||||||
|
|
||||||
|
protected readonly int _airbusWidth = 89;
|
||||||
|
protected readonly int _airbusHeight = 34;
|
||||||
|
|
||||||
|
// Получение объекта IMoveableObject из объекта DrawningCar
|
||||||
|
public IMoveableObject GetMoveableObject => new DrawningObjectAirbus(this);
|
||||||
|
|
||||||
|
// доработки для интерфейса
|
||||||
|
public int GetPosX => _startPosX;
|
||||||
|
public int GetPosY => _startPosY;
|
||||||
|
public int GetWidth => _airbusWidth;
|
||||||
|
public int GetHeight => _airbusHeight;
|
||||||
|
|
||||||
|
public DrawningAirbus(int speed, double weight, Color bodyColor, int
|
||||||
|
width, int height)
|
||||||
|
{
|
||||||
|
if (width < _airbusWidth || height < _airbusHeight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
protected DrawningAirbus(int speed, double weight, Color bodyColor, int width, int height, int carWidth, int carHeight)
|
||||||
|
{
|
||||||
|
if (width < _airbusWidth || height < _airbusHeight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
_airbusWidth = carWidth;
|
||||||
|
_airbusHeight = carHeight;
|
||||||
|
EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// доработка для интерфейса
|
||||||
|
// проверка, что может переместиться
|
||||||
|
public bool CanMove(DirectionType direction)
|
||||||
|
{
|
||||||
|
if (EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return direction switch
|
||||||
|
{
|
||||||
|
DirectionType.Left => _startPosX - EntityAirbus.Step > 0,
|
||||||
|
DirectionType.Up => _startPosY - EntityAirbus.Step > 0,
|
||||||
|
DirectionType.Right => _startPosX + _airbusWidth + EntityAirbus.Step < _pictureWidth,
|
||||||
|
DirectionType.Down => _startPosY + _airbusHeight + EntityAirbus.Step < _pictureHeight,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// изменение границы поля, когда закрываем конфиг
|
||||||
|
public void ChangeBordersPicture(int width, int height)
|
||||||
|
{
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (x >= _pictureWidth || y >= _pictureHeight)
|
||||||
|
{
|
||||||
|
x = _pictureWidth - _airbusWidth;
|
||||||
|
y = _pictureHeight - _airbusHeight;
|
||||||
|
}
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveTransport(DirectionType direction)
|
||||||
|
{
|
||||||
|
if (!CanMove(direction) || EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case DirectionType.Left:
|
||||||
|
_startPosX -= (int)EntityAirbus.Step;
|
||||||
|
break;
|
||||||
|
case DirectionType.Right:
|
||||||
|
_startPosX += (int)EntityAirbus.Step;
|
||||||
|
break;
|
||||||
|
case DirectionType.Up:
|
||||||
|
_startPosY -= (int)EntityAirbus.Step;
|
||||||
|
break;
|
||||||
|
case DirectionType.Down:
|
||||||
|
_startPosY += (int)EntityAirbus.Step;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// прорисовка
|
||||||
|
public virtual void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush bodyBrush = new SolidBrush(EntityAirbus.BodyColor);
|
||||||
|
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||||
|
|
||||||
|
// нос
|
||||||
|
Point point1 = new Point(_startPosX + 74, _startPosY + 15);
|
||||||
|
Point point2 = new Point(_startPosX + 88, _startPosY + 22);
|
||||||
|
Point point3 = new Point(_startPosX + 74, _startPosY + 27);
|
||||||
|
Point[] PointsNose = { point1, point2, point3 };
|
||||||
|
|
||||||
|
g.DrawPolygon(pen, PointsNose);
|
||||||
|
g.FillPolygon(brYellow, PointsNose);
|
||||||
|
|
||||||
|
// хвост
|
||||||
|
Point point4 = new Point(_startPosX + 4, _startPosY + 17);
|
||||||
|
Point point5 = new Point(_startPosX + 3, _startPosY);
|
||||||
|
Point point6 = new Point(_startPosX + 21, _startPosY + 17);
|
||||||
|
|
||||||
|
Point[] PointsTail = { point4, point5, point6 };
|
||||||
|
g.DrawPolygon(pen, PointsTail);
|
||||||
|
g.FillPolygon(brYellow, PointsTail);
|
||||||
|
|
||||||
|
// тело
|
||||||
|
g.DrawRectangle(pen, _startPosX + 2, _startPosY + 14, 72, 14);
|
||||||
|
g.FillRectangle(bodyBrush, _startPosX + 2, _startPosY + 14, 72, 14);
|
||||||
|
|
||||||
|
//шасси
|
||||||
|
g.DrawEllipse(pen, _startPosX + 21, _startPosY + 30, 3, 3);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 21, _startPosY + 30, 3, 3);
|
||||||
|
|
||||||
|
g.DrawEllipse(pen, _startPosX + 25, _startPosY + 30, 3, 3);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 25, _startPosY + 30, 3, 3);
|
||||||
|
|
||||||
|
g.DrawEllipse(pen, _startPosX + 70, _startPosY + 30, 3, 3);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 70, _startPosY + 30, 3, 3);
|
||||||
|
|
||||||
|
// Крыло
|
||||||
|
g.DrawEllipse(pen, _startPosX + 24, _startPosY + 20, 31, 4);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 24, _startPosY + 20, 31, 4);
|
||||||
|
|
||||||
|
// двигатель у хвоста
|
||||||
|
g.DrawEllipse(pen, _startPosX, _startPosY + 14, 14, 5);
|
||||||
|
g.FillEllipse(brYellow, _startPosX, _startPosY + 14, 14, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
Airbus/Drawnings/DrawningPlane.cs
Normal file
48
Airbus/Drawnings/DrawningPlane.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Drawnings
|
||||||
|
{
|
||||||
|
public class DrawningPlane : DrawningAirbus
|
||||||
|
{
|
||||||
|
public DrawningPlane(int speed, double weight, Color bodyColor, Color additionalColor,bool isCompartment, bool isAdditionalEngine, int width, int height) :
|
||||||
|
base (speed, weight, bodyColor, width, height, 110, 60)
|
||||||
|
{
|
||||||
|
if (EntityAirbus != null)
|
||||||
|
{
|
||||||
|
EntityAirbus = new EntityPlane(speed, weight, bodyColor, additionalColor, isCompartment, isAdditionalEngine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAirbus is not EntityPlane superAirbus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush bodyBrush = new SolidBrush(EntityAirbus.BodyColor);
|
||||||
|
Brush additionalBrush = new SolidBrush(superAirbus.AdditionalColor);
|
||||||
|
|
||||||
|
// доп отсек
|
||||||
|
if (superAirbus.IsCompartment)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(pen, _startPosX + 51, _startPosY + 10, 24, 10);
|
||||||
|
g.FillEllipse(bodyBrush, _startPosX + 51, _startPosY + 10, 24, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.DrawTransport(g);
|
||||||
|
|
||||||
|
// доп двигатель
|
||||||
|
if (superAirbus.IsAdditionalEngine)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(pen, _startPosX, _startPosY + 20, 11, 5);
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX, _startPosY + 20, 11, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
Airbus/Drawnings/ExtentionDrawningAirbus.cs
Normal file
50
Airbus/Drawnings/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 ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Drawnings
|
||||||
|
{
|
||||||
|
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 DrawningPlane(
|
||||||
|
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 airbus = drawningAirbus.EntityAirbus;
|
||||||
|
if (airbus == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str = $"{airbus.Speed}{separatorForObject}{airbus.Weight}{separatorForObject}{airbus.BodyColor.Name}";
|
||||||
|
if (airbus is not EntityPlane plane)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{separatorForObject}{plane.AdditionalColor.Name}{separatorForObject}{plane.IsCompartment}{separatorForObject}{plane.IsAdditionalEngine}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Airbus/Entities/DirectionType.cs
Normal file
16
Airbus/Entities/DirectionType.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Entities
|
||||||
|
{
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
Up = 1,
|
||||||
|
Down = 2,
|
||||||
|
Left = 3,
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
29
Airbus/Entities/EntityAirbus.cs
Normal file
29
Airbus/Entities/EntityAirbus.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.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 ChangeBodyColor(Color bodyColor)
|
||||||
|
{
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Airbus/Entities/EntityPlane.cs
Normal file
28
Airbus/Entities/EntityPlane.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Entities
|
||||||
|
{
|
||||||
|
public class EntityPlane : EntityAirbus
|
||||||
|
{
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
public bool IsCompartment { get; private set; }
|
||||||
|
public bool IsAdditionalEngine { get; private set; }
|
||||||
|
|
||||||
|
public EntityPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool isCompartment, bool isAdditionalEngine) :
|
||||||
|
base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
IsCompartment = isCompartment;
|
||||||
|
IsAdditionalEngine = isAdditionalEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeColorAdditional(Color additionalColor)
|
||||||
|
{
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
Airbus/Exceptions/AirbusNotFoundException.cs
Normal file
19
Airbus/Exceptions/AirbusNotFoundException.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class AirbusNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public AirbusNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||||
|
public AirbusNotFoundException() : base() { }
|
||||||
|
public AirbusNotFoundException(string message) : base(message) { }
|
||||||
|
public AirbusNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected AirbusNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
19
Airbus/Exceptions/StorageOverflowException.cs
Normal file
19
Airbus/Exceptions/StorageOverflowException.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class StorageOverflowException : ApplicationException
|
||||||
|
{
|
||||||
|
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
||||||
|
public StorageOverflowException() : base() { }
|
||||||
|
public StorageOverflowException (string message) : base(message) { }
|
||||||
|
public StorageOverflowException (string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
256
Airbus/FormAirbusCollection.Designer.cs
generated
Normal file
256
Airbus/FormAirbusCollection.Designer.cs
generated
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
buttonAddAirbus = new Button();
|
||||||
|
pictureBoxCollection = new PictureBox();
|
||||||
|
labelInstruments = new Label();
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonDeleteAirbus = new Button();
|
||||||
|
colorDialog = new ColorDialog();
|
||||||
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
listBoxStorages = new ListBox();
|
||||||
|
buttonAddStorage = new Button();
|
||||||
|
buttonDeleteStorage = new Button();
|
||||||
|
textBoxStorageName = new TextBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonAddAirbus
|
||||||
|
//
|
||||||
|
buttonAddAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonAddAirbus.Location = new Point(654, 443);
|
||||||
|
buttonAddAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAddAirbus.Name = "buttonAddAirbus";
|
||||||
|
buttonAddAirbus.Size = new Size(157, 37);
|
||||||
|
buttonAddAirbus.TabIndex = 0;
|
||||||
|
buttonAddAirbus.Text = "Добавить самолёт";
|
||||||
|
buttonAddAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddAirbus.Click += buttonAddAirbus_Click;
|
||||||
|
//
|
||||||
|
// pictureBoxCollection
|
||||||
|
//
|
||||||
|
pictureBoxCollection.Location = new Point(0, 28);
|
||||||
|
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
|
pictureBoxCollection.Size = new Size(630, 556);
|
||||||
|
pictureBoxCollection.TabIndex = 1;
|
||||||
|
pictureBoxCollection.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelInstruments
|
||||||
|
//
|
||||||
|
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
labelInstruments.AutoSize = true;
|
||||||
|
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelInstruments.Location = new Point(654, 23);
|
||||||
|
labelInstruments.Name = "labelInstruments";
|
||||||
|
labelInstruments.Size = new Size(136, 28);
|
||||||
|
labelInstruments.TabIndex = 2;
|
||||||
|
labelInstruments.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonUpdate.Location = new Point(654, 173);
|
||||||
|
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(150, 33);
|
||||||
|
buttonUpdate.TabIndex = 3;
|
||||||
|
buttonUpdate.Text = "Обновить набор";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonDeleteAirbus
|
||||||
|
//
|
||||||
|
buttonDeleteAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonDeleteAirbus.Location = new Point(654, 523);
|
||||||
|
buttonDeleteAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDeleteAirbus.Name = "buttonDeleteAirbus";
|
||||||
|
buttonDeleteAirbus.Size = new Size(157, 37);
|
||||||
|
buttonDeleteAirbus.TabIndex = 4;
|
||||||
|
buttonDeleteAirbus.Text = "Удалить самолёт";
|
||||||
|
buttonDeleteAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonDeleteAirbus.Click += buttonDeleteAirbus_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
maskedTextBoxNumber.Location = new Point(654, 487);
|
||||||
|
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
maskedTextBoxNumber.Mask = "00";
|
||||||
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
maskedTextBoxNumber.Size = new Size(157, 27);
|
||||||
|
maskedTextBoxNumber.TabIndex = 5;
|
||||||
|
maskedTextBoxNumber.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(654, 62);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(66, 20);
|
||||||
|
label1.TabIndex = 7;
|
||||||
|
label1.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
listBoxStorages.FormattingEnabled = true;
|
||||||
|
listBoxStorages.ItemHeight = 20;
|
||||||
|
listBoxStorages.Location = new Point(654, 213);
|
||||||
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
|
listBoxStorages.Size = new Size(150, 144);
|
||||||
|
listBoxStorages.TabIndex = 8;
|
||||||
|
listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonAddStorage
|
||||||
|
//
|
||||||
|
buttonAddStorage.Location = new Point(654, 136);
|
||||||
|
buttonAddStorage.Name = "buttonAddStorage";
|
||||||
|
buttonAddStorage.Size = new Size(150, 33);
|
||||||
|
buttonAddStorage.TabIndex = 9;
|
||||||
|
buttonAddStorage.Text = "Добавить набор";
|
||||||
|
buttonAddStorage.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddStorage.Click += buttonAddStorage_Click;
|
||||||
|
//
|
||||||
|
// buttonDeleteStorage
|
||||||
|
//
|
||||||
|
buttonDeleteStorage.Location = new Point(654, 364);
|
||||||
|
buttonDeleteStorage.Name = "buttonDeleteStorage";
|
||||||
|
buttonDeleteStorage.Size = new Size(150, 33);
|
||||||
|
buttonDeleteStorage.TabIndex = 10;
|
||||||
|
buttonDeleteStorage.Text = "Удалить набор";
|
||||||
|
buttonDeleteStorage.UseVisualStyleBackColor = true;
|
||||||
|
buttonDeleteStorage.Click += buttonDeleteStorage_Click;
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(654, 103);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(150, 27);
|
||||||
|
textBoxStorageName.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Size = new Size(827, 28);
|
||||||
|
menuStrip.TabIndex = 12;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// ToolStripMenuItem
|
||||||
|
//
|
||||||
|
ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
ToolStripMenuItem.Name = "ToolStripMenuItem";
|
||||||
|
ToolStripMenuItem.Size = new Size(59, 24);
|
||||||
|
ToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(166, 26);
|
||||||
|
SaveToolStripMenuItem.Text = "Сохранить";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(166, 26);
|
||||||
|
LoadToolStripMenuItem.Text = "Загрузить";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
saveFileDialog.OverwritePrompt = false;
|
||||||
|
//
|
||||||
|
// FormAirbusCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(827, 591);
|
||||||
|
Controls.Add(textBoxStorageName);
|
||||||
|
Controls.Add(buttonDeleteStorage);
|
||||||
|
Controls.Add(buttonAddStorage);
|
||||||
|
Controls.Add(listBoxStorages);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(buttonAddAirbus);
|
||||||
|
Controls.Add(maskedTextBoxNumber);
|
||||||
|
Controls.Add(buttonDeleteAirbus);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(labelInstruments);
|
||||||
|
Controls.Add(pictureBoxCollection);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormAirbusCollection";
|
||||||
|
Text = "Набор самолётов";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonAddAirbus;
|
||||||
|
private PictureBox pictureBoxCollection;
|
||||||
|
private Label labelInstruments;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonDeleteAirbus;
|
||||||
|
private ColorDialog colorDialog;
|
||||||
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private Label label1;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Button buttonAddStorage;
|
||||||
|
private Button buttonDeleteStorage;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
}
|
||||||
|
}
|
225
Airbus/FormAirbusCollection.cs
Normal file
225
Airbus/FormAirbusCollection.cs
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
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 Microsoft.Extensions.Logging;
|
||||||
|
using ProjectAirbus.Generics;
|
||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.Exceptions;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
public partial class FormAirbusCollection : Form
|
||||||
|
{
|
||||||
|
// Набор объектов
|
||||||
|
private readonly AirbusGenericStorage _storage;
|
||||||
|
// Логер
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public FormAirbusCollection(ILogger<FormAirbusCollection> logger)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storage = new AirbusGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обработка нажатия "Сохранение"
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.SaveData(saveFileDialog.FileName);
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation($"Файл сохранён по пути: {saveFileDialog.FileName}");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обработка нажатия "Загрузка"
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.LoadData(openFileDialog.FileName);
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation($"Файл загружен по пути: {openFileDialog.FileName}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
// заполнение лист бокс
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorages.SelectedIndex;
|
||||||
|
listBoxStorages.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||||
|
}
|
||||||
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// добавить набор в коллекцию
|
||||||
|
private void buttonAddStorage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storage.AddSet(textBoxStorageName.Text);
|
||||||
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// выбрать набор
|
||||||
|
private void listBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAirbus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// удалить набор
|
||||||
|
private void buttonDeleteStorage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||||
|
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_storage.DelSet(name);
|
||||||
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Удалён набор: {name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// добавить самолёт в набор
|
||||||
|
private void buttonAddAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var formAirbusConfig = new FormAirbusConfig();
|
||||||
|
formAirbusConfig.AddEvent(AddAirbusInSet);
|
||||||
|
formAirbusConfig.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddAirbusInSet(DrawningAirbus _airbus)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не выбран набор");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// меняем границы после закрытия конфига
|
||||||
|
_airbus.ChangeBordersPicture(Width, Height);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (obj + _airbus != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowAirbus();
|
||||||
|
_logger.LogInformation($"Добавлен объект: {_airbus.EntityAirbus.BodyColor}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (StorageOverflowException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// удалить самолёт
|
||||||
|
private void buttonDeleteAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
|
if (obj - pos)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBoxCollection.Image = obj.ShowAirbus();
|
||||||
|
_logger.LogInformation($"Удалён объект по позиции : {pos}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Неверный формат ввода");
|
||||||
|
_logger.LogWarning("Неверный формат ввода");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// обновить рисунок по набору
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBoxCollection.Image = obj.ShowAirbus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
135
Airbus/FormAirbusCollection.resx
Normal file
135
Airbus/FormAirbusCollection.resx
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?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="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>156, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>292, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>462, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>25</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
357
Airbus/FormAirbusConfig.Designer.cs
generated
Normal file
357
Airbus/FormAirbusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,357 @@
|
|||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
groupBoxConfig = new GroupBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
checkBoxAdditionalEngine = new CheckBox();
|
||||||
|
checkBoxCompartment = new CheckBox();
|
||||||
|
labelWeight = new Label();
|
||||||
|
labelSpeed = new Label();
|
||||||
|
groupBoxColors = new GroupBox();
|
||||||
|
panelSilver = new Panel();
|
||||||
|
panelOrange = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelViolet = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
labelComplexObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
panelRed = new Panel();
|
||||||
|
buttonOk = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
labelBodyColor = new Label();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
panelObject = new Panel();
|
||||||
|
groupBoxConfig.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxConfig
|
||||||
|
//
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxAdditionalEngine);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxCompartment);
|
||||||
|
groupBoxConfig.Controls.Add(labelWeight);
|
||||||
|
groupBoxConfig.Controls.Add(labelSpeed);
|
||||||
|
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||||
|
groupBoxConfig.Location = new Point(24, 16);
|
||||||
|
groupBoxConfig.Name = "groupBoxConfig";
|
||||||
|
groupBoxConfig.Size = new Size(620, 243);
|
||||||
|
groupBoxConfig.TabIndex = 0;
|
||||||
|
groupBoxConfig.TabStop = false;
|
||||||
|
groupBoxConfig.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(106, 88);
|
||||||
|
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 = 7;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(106, 41);
|
||||||
|
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 = 6;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// checkBoxAdditionalEngine
|
||||||
|
//
|
||||||
|
checkBoxAdditionalEngine.AutoSize = true;
|
||||||
|
checkBoxAdditionalEngine.Location = new Point(22, 151);
|
||||||
|
checkBoxAdditionalEngine.Name = "checkBoxAdditionalEngine";
|
||||||
|
checkBoxAdditionalEngine.Size = new Size(204, 24);
|
||||||
|
checkBoxAdditionalEngine.TabIndex = 4;
|
||||||
|
checkBoxAdditionalEngine.Text = "Добавить доп. двигатель";
|
||||||
|
checkBoxAdditionalEngine.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxCompartment
|
||||||
|
//
|
||||||
|
checkBoxCompartment.AutoSize = true;
|
||||||
|
checkBoxCompartment.Location = new Point(22, 186);
|
||||||
|
checkBoxCompartment.Name = "checkBoxCompartment";
|
||||||
|
checkBoxCompartment.Size = new Size(243, 24);
|
||||||
|
checkBoxCompartment.TabIndex = 3;
|
||||||
|
checkBoxCompartment.Text = "Добавить пассажирский отсек";
|
||||||
|
checkBoxCompartment.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
labelWeight.AutoSize = true;
|
||||||
|
labelWeight.Location = new Point(22, 95);
|
||||||
|
labelWeight.Name = "labelWeight";
|
||||||
|
labelWeight.Size = new Size(36, 20);
|
||||||
|
labelWeight.TabIndex = 2;
|
||||||
|
labelWeight.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
labelSpeed.AutoSize = true;
|
||||||
|
labelSpeed.Location = new Point(22, 43);
|
||||||
|
labelSpeed.Name = "labelSpeed";
|
||||||
|
labelSpeed.Size = new Size(80, 20);
|
||||||
|
labelSpeed.TabIndex = 1;
|
||||||
|
labelSpeed.Text = "Скорость: ";
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
groupBoxColors.Controls.Add(panelSilver);
|
||||||
|
groupBoxColors.Controls.Add(panelOrange);
|
||||||
|
groupBoxColors.Controls.Add(panelWhite);
|
||||||
|
groupBoxColors.Controls.Add(panelGreen);
|
||||||
|
groupBoxColors.Controls.Add(panelViolet);
|
||||||
|
groupBoxColors.Controls.Add(panelBlue);
|
||||||
|
groupBoxColors.Controls.Add(panelYellow);
|
||||||
|
groupBoxColors.Controls.Add(labelComplexObject);
|
||||||
|
groupBoxColors.Controls.Add(labelSimpleObject);
|
||||||
|
groupBoxColors.Controls.Add(panelRed);
|
||||||
|
groupBoxColors.Location = new Point(310, 21);
|
||||||
|
groupBoxColors.Name = "groupBoxColors";
|
||||||
|
groupBoxColors.Size = new Size(279, 212);
|
||||||
|
groupBoxColors.TabIndex = 0;
|
||||||
|
groupBoxColors.TabStop = false;
|
||||||
|
groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelSilver
|
||||||
|
//
|
||||||
|
panelSilver.BackColor = Color.Silver;
|
||||||
|
panelSilver.Location = new Point(148, 96);
|
||||||
|
panelSilver.Name = "panelSilver";
|
||||||
|
panelSilver.Size = new Size(40, 40);
|
||||||
|
panelSilver.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelOrange
|
||||||
|
//
|
||||||
|
panelOrange.BackColor = Color.DarkOrange;
|
||||||
|
panelOrange.Location = new Point(204, 96);
|
||||||
|
panelOrange.Name = "panelOrange";
|
||||||
|
panelOrange.Size = new Size(40, 40);
|
||||||
|
panelOrange.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(93, 96);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(40, 40);
|
||||||
|
panelWhite.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.LimeGreen;
|
||||||
|
panelGreen.Location = new Point(38, 96);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(40, 40);
|
||||||
|
panelGreen.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelViolet
|
||||||
|
//
|
||||||
|
panelViolet.BackColor = Color.MediumVioletRed;
|
||||||
|
panelViolet.Location = new Point(204, 43);
|
||||||
|
panelViolet.Name = "panelViolet";
|
||||||
|
panelViolet.Size = new Size(40, 40);
|
||||||
|
panelViolet.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.MediumBlue;
|
||||||
|
panelBlue.Location = new Point(148, 43);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(40, 40);
|
||||||
|
panelBlue.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(93, 43);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(40, 40);
|
||||||
|
panelYellow.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelComplexObject
|
||||||
|
//
|
||||||
|
labelComplexObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelComplexObject.Location = new Point(148, 157);
|
||||||
|
labelComplexObject.Name = "labelComplexObject";
|
||||||
|
labelComplexObject.RightToLeft = RightToLeft.No;
|
||||||
|
labelComplexObject.Size = new Size(120, 38);
|
||||||
|
labelComplexObject.TabIndex = 4;
|
||||||
|
labelComplexObject.Text = "Продвинутый";
|
||||||
|
labelComplexObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelComplexObject.MouseDown += labelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(14, 157);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(120, 38);
|
||||||
|
labelSimpleObject.TabIndex = 3;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(38, 43);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(40, 40);
|
||||||
|
panelRed.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonOk
|
||||||
|
//
|
||||||
|
buttonOk.Location = new Point(666, 212);
|
||||||
|
buttonOk.Name = "buttonOk";
|
||||||
|
buttonOk.Size = new Size(107, 43);
|
||||||
|
buttonOk.TabIndex = 0;
|
||||||
|
buttonOk.Text = "Добавить";
|
||||||
|
buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
buttonOk.Click += buttonOk_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(796, 212);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(107, 43);
|
||||||
|
buttonCancel.TabIndex = 1;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(18, 55);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(227, 109);
|
||||||
|
pictureBoxObject.TabIndex = 0;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelBodyColor
|
||||||
|
//
|
||||||
|
labelBodyColor.AllowDrop = true;
|
||||||
|
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelBodyColor.Location = new Point(18, 9);
|
||||||
|
labelBodyColor.Name = "labelBodyColor";
|
||||||
|
labelBodyColor.Size = new Size(107, 38);
|
||||||
|
labelBodyColor.TabIndex = 2;
|
||||||
|
labelBodyColor.Text = "Цвет";
|
||||||
|
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||||
|
labelBodyColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(138, 9);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(107, 38);
|
||||||
|
labelAdditionalColor.TabIndex = 3;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Controls.Add(labelAdditionalColor);
|
||||||
|
panelObject.Controls.Add(labelBodyColor);
|
||||||
|
panelObject.Location = new Point(650, 27);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(264, 171);
|
||||||
|
panelObject.TabIndex = 2;
|
||||||
|
panelObject.DragDrop += panelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += panelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// FormAirbusConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(952, 283);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(groupBoxConfig);
|
||||||
|
Controls.Add(buttonOk);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Name = "FormAirbusConfig";
|
||||||
|
Text = "Конструирование самолёта";
|
||||||
|
groupBoxConfig.ResumeLayout(false);
|
||||||
|
groupBoxConfig.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxConfig;
|
||||||
|
private CheckBox checkBoxAdditionalEngine;
|
||||||
|
private CheckBox checkBoxCompartment;
|
||||||
|
private Label labelWeight;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Panel panelRed;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonOk;
|
||||||
|
private Label labelComplexObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelBodyColor;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Panel panelSilver;
|
||||||
|
private Panel panelOrange;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelViolet;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelYellow;
|
||||||
|
}
|
||||||
|
}
|
157
Airbus/FormAirbusConfig.cs
Normal file
157
Airbus/FormAirbusConfig.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
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 ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
public partial class FormAirbusConfig : Form
|
||||||
|
{
|
||||||
|
// выбранный самолёт
|
||||||
|
DrawningAirbus? _airbus = null;
|
||||||
|
|
||||||
|
// событие
|
||||||
|
private event Action<DrawningAirbus> EventAddAirbus;
|
||||||
|
// конструктор
|
||||||
|
public FormAirbusConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelOrange.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelViolet.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelSilver.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
|
||||||
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// добавить событие
|
||||||
|
public void AddEvent(Action<DrawningAirbus> ev)
|
||||||
|
{
|
||||||
|
if (EventAddAirbus == null)
|
||||||
|
{
|
||||||
|
EventAddAirbus = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddAirbus += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// цвета
|
||||||
|
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 PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// перекрашиваем базовый
|
||||||
|
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_airbus == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Color bodyColor = (Color)e.Data?.GetData(typeof(Color));
|
||||||
|
_airbus.EntityAirbus.ChangeBodyColor(bodyColor);
|
||||||
|
DrawAirbus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// перекрашиваем доп
|
||||||
|
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_airbus == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Color addColor = (Color)e.Data?.GetData(typeof(Color));
|
||||||
|
if (_airbus is DrawningPlane)
|
||||||
|
{
|
||||||
|
EntityPlane _plane = _airbus.EntityAirbus as EntityPlane;
|
||||||
|
_plane.ChangeColorAdditional(addColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нельзя задать доп. цвет обычному самолёту");
|
||||||
|
}
|
||||||
|
DrawAirbus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// объект
|
||||||
|
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// передаём информацию при нажатии на label
|
||||||
|
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// что делаем при приеме информации
|
||||||
|
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_airbus = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||||
|
Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelComplexObject":
|
||||||
|
_airbus = new DrawningPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||||
|
Color.White, Color.Black, checkBoxCompartment.Checked, checkBoxAdditionalEngine.Checked,
|
||||||
|
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawAirbus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// добавить самолёт
|
||||||
|
private void buttonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_airbus == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EventAddAirbus?.Invoke(_airbus);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// отрисовать самолёт
|
||||||
|
private void DrawAirbus()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_airbus?.SetPosition(5, 5);
|
||||||
|
_airbus?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
120
Airbus/FormAirbusConfig.resx
Normal file
120
Airbus/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>
|
211
Airbus/FormPlane.Designer.cs
generated
Normal file
211
Airbus/FormPlane.Designer.cs
generated
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAirbus));
|
||||||
|
pictureAirBus = new PictureBox();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
buttonCreateSuperAirbus = new Button();
|
||||||
|
buttonStep = new Button();
|
||||||
|
comboBoxStrategy = new ComboBox();
|
||||||
|
buttonSelectedAirbus = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureAirBus).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureAirBus
|
||||||
|
//
|
||||||
|
pictureAirBus.Dock = DockStyle.Fill;
|
||||||
|
pictureAirBus.Location = new Point(0, 0);
|
||||||
|
pictureAirBus.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
pictureAirBus.Name = "pictureAirBus";
|
||||||
|
pictureAirBus.Size = new Size(903, 547);
|
||||||
|
pictureAirBus.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureAirBus.TabIndex = 0;
|
||||||
|
pictureAirBus.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUp.FlatAppearance.BorderColor = Color.Black;
|
||||||
|
buttonUp.FlatAppearance.BorderSize = 7;
|
||||||
|
buttonUp.Location = new Point(776, 412);
|
||||||
|
buttonUp.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(55, 59);
|
||||||
|
buttonUp.TabIndex = 1;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackColor = SystemColors.Control;
|
||||||
|
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonLeft.FlatAppearance.BorderColor = Color.Black;
|
||||||
|
buttonLeft.FlatAppearance.BorderSize = 7;
|
||||||
|
buttonLeft.Location = new Point(720, 472);
|
||||||
|
buttonLeft.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(55, 59);
|
||||||
|
buttonLeft.TabIndex = 2;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = false;
|
||||||
|
buttonLeft.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDown.FlatAppearance.BorderColor = Color.Black;
|
||||||
|
buttonDown.FlatAppearance.BorderSize = 7;
|
||||||
|
buttonDown.Location = new Point(776, 472);
|
||||||
|
buttonDown.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(55, 59);
|
||||||
|
buttonDown.TabIndex = 3;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonRight.FlatAppearance.BorderColor = Color.Black;
|
||||||
|
buttonRight.FlatAppearance.BorderSize = 7;
|
||||||
|
buttonRight.Location = new Point(832, 472);
|
||||||
|
buttonRight.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonRight.Name = "buttonRight";
|
||||||
|
buttonRight.Size = new Size(55, 59);
|
||||||
|
buttonRight.TabIndex = 4;
|
||||||
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
buttonRight.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.Location = new Point(14, 481);
|
||||||
|
buttonCreate.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(146, 50);
|
||||||
|
buttonCreate.TabIndex = 5;
|
||||||
|
buttonCreate.Text = "Создать аэробус";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += buttonCreate_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateSuperAirbus
|
||||||
|
//
|
||||||
|
buttonCreateSuperAirbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreateSuperAirbus.Location = new Point(166, 481);
|
||||||
|
buttonCreateSuperAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCreateSuperAirbus.Name = "buttonCreateSuperAirbus";
|
||||||
|
buttonCreateSuperAirbus.Size = new Size(145, 50);
|
||||||
|
buttonCreateSuperAirbus.TabIndex = 6;
|
||||||
|
buttonCreateSuperAirbus.Text = "Создать самолёт";
|
||||||
|
buttonCreateSuperAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateSuperAirbus.Click += buttonCreateSuperAirbus_Click;
|
||||||
|
//
|
||||||
|
// buttonStep
|
||||||
|
//
|
||||||
|
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonStep.Location = new Point(767, 68);
|
||||||
|
buttonStep.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonStep.Name = "buttonStep";
|
||||||
|
buttonStep.Size = new Size(120, 49);
|
||||||
|
buttonStep.TabIndex = 7;
|
||||||
|
buttonStep.Text = "Шаг";
|
||||||
|
buttonStep.UseVisualStyleBackColor = true;
|
||||||
|
buttonStep.Click += buttonStep_Click;
|
||||||
|
//
|
||||||
|
// comboBoxStrategy
|
||||||
|
//
|
||||||
|
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
|
comboBoxStrategy.Items.AddRange(new object[] { "1", "2" });
|
||||||
|
comboBoxStrategy.Location = new Point(711, 29);
|
||||||
|
comboBoxStrategy.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
|
comboBoxStrategy.Size = new Size(178, 28);
|
||||||
|
comboBoxStrategy.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// buttonSelectedAirbus
|
||||||
|
//
|
||||||
|
buttonSelectedAirbus.Location = new Point(427, 481);
|
||||||
|
buttonSelectedAirbus.Name = "buttonSelectedAirbus";
|
||||||
|
buttonSelectedAirbus.Size = new Size(137, 50);
|
||||||
|
buttonSelectedAirbus.TabIndex = 9;
|
||||||
|
buttonSelectedAirbus.Text = "Выбрать";
|
||||||
|
buttonSelectedAirbus.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectedAirbus.Click += buttonSelectedAirbus_Click;
|
||||||
|
//
|
||||||
|
// FormPlane
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(903, 547);
|
||||||
|
Controls.Add(buttonSelectedAirbus);
|
||||||
|
Controls.Add(comboBoxStrategy);
|
||||||
|
Controls.Add(buttonStep);
|
||||||
|
Controls.Add(buttonCreateSuperAirbus);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(pictureAirBus);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormPlane";
|
||||||
|
Text = "FormPlane";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureAirBus).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureAirBus;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonCreateSuperAirbus;
|
||||||
|
private Button buttonStep;
|
||||||
|
private ComboBox comboBoxStrategy;
|
||||||
|
private Button buttonSelectedAirbus;
|
||||||
|
}
|
||||||
|
}
|
144
Airbus/FormPlane.cs
Normal file
144
Airbus/FormPlane.cs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.MovementStrategy;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
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(pictureAirBus.Width, pictureAirBus.Height);
|
||||||
|
Graphics g = Graphics.FromImage(bmp);
|
||||||
|
_drawningAirbus.DrawTransport(g);
|
||||||
|
pictureAirBus.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// кнопка "Создать самолёт"
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
_drawningAirbus = new DrawningAirbus(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
color, pictureAirBus.Width, pictureAirBus.Height);
|
||||||
|
|
||||||
|
_drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200));
|
||||||
|
Draw();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// кнопка "Создать суперсамолёт"
|
||||||
|
private void buttonCreateSuperAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
//выбор основного цвета
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
//TODO дополнительного цвета
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
_drawningAirbus = new DrawningPlane(random.Next(200, 400), random.Next(1000, 3000),
|
||||||
|
color, dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
pictureAirBus.Width, pictureAirBus.Height);
|
||||||
|
|
||||||
|
_drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirbus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
_drawningAirbus.MoveTransport(DirectionType.Up); break;
|
||||||
|
case "buttonDown":
|
||||||
|
_drawningAirbus.MoveTransport(DirectionType.Down); break;
|
||||||
|
case "buttonLeft":
|
||||||
|
_drawningAirbus.MoveTransport(DirectionType.Left); break;
|
||||||
|
case "buttonRight":
|
||||||
|
_drawningAirbus.MoveTransport(DirectionType.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(new DrawningObjectAirbus(_drawningAirbus), pictureAirBus.Width, pictureAirBus.Height);
|
||||||
|
comboBoxStrategy.Enabled = false;
|
||||||
|
}
|
||||||
|
if (_abstractStrategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_abstractStrategy.MakeStep();
|
||||||
|
Draw();
|
||||||
|
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||||
|
{
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_abstractStrategy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSelectedAirbus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedAirbus = _drawningAirbus;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
239
Airbus/FormPlane.resx
Normal file
239
Airbus/FormPlane.resx
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
<?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.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
/9j/4AAQSkZJRgABAQEAYABgAAD/4QC2RXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAAB
|
||||||
|
AAAAJgAAAAAAAZKGAAcAAAB0AAAAOAAAAABDAFIARQBBAFQATwBSADoAIABnAGQALQBqAHAAZQBnACAA
|
||||||
|
dgAxAC4AMAAgACgAdQBzAGkAbgBnACAASQBKAEcAIABKAFAARQBHACAAdgA2ADIAKQAsACAAcQB1AGEA
|
||||||
|
bABpAHQAeQAgAD0AIAA2ADAACgAAAAAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcH
|
||||||
|
BgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwM
|
||||||
|
DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAJQAeAwEiAAIRAQMR
|
||||||
|
Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
|
||||||
|
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElK
|
||||||
|
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrC
|
||||||
|
w8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAAB
|
||||||
|
AgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj
|
||||||
|
M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5
|
||||||
|
eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm
|
||||||
|
5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A/foyAV+W/wDwcCf8F67r/gnLeaL8NfhJcaDq3xfu5INU
|
||||||
|
1g38BvLPw7pwYOkc6Ky/v7rGAm7ckJeQ7C8DN9J/8FjP+Cp/h/8A4JV/sq3HiiRdP1bx94iMmn+DdAuJ
|
||||||
|
D/xM7wAFp5VUh/sluGV5WBXho4w6vLHX8lfxO+JviL41fEjXPGHi7WLvxB4o8TXsmparqNyR5t3cSNln
|
||||||
|
IUBV5+UKoCqoVVCqAKAP7D/+Cbf/AAUB8H/8FLv2VNE+J3hFTYtdE2OtaNLMJrjw/qUaqZrSRgBu27ld
|
||||||
|
H2r5kckbhV34HvlfyDf8Ed/+CpOvf8Eqf2rLXxXGuoap8P8AxJ5On+NNDt3G6/swx2XMKkhWurYtI8WS
|
||||||
|
N4aWIsglLr/W18Lvil4f+Nnw40Pxd4T1a017w34lsYtS0zULVt0V3byqGR1zg8gjggEHggEEUAflx/wU
|
||||||
|
9/4NsvHX/BTH9r7W/idrf7R1vpen3EcVjoWiS+CWu4/D9jGMi3jcX8YbMhkkZ9ql2kJ4AAH87/xf8AN8
|
||||||
|
Jfi94u8JSXi6hJ4T12+0VrpYvJF0bW4kgMoTcxXd5e7aWbGcFjjNf3DV/E7+2N/yeN8YP+x717/05XH+
|
||||||
|
f8mgD1z/AIJF/wDBMu6/4Kw/tQ6x8M7Pxtb+AZNJ8LXXic6lLo51RZhDd2Vt5HlLPBjd9sDbtxx5ZG07
|
||||||
|
sr/R9/wRn/4Ji+Nv+CVvwX8ReAPEHxkb4peFbu/TUPD9h/wj7aWnhp38xrtY2a5nLRzyMknljYiSLK4B
|
||||||
|
aZzX45/8Ge3H/BUzxi3b/hVWqf8Ap30Wv6VKACvye+L/APwaLfA/4ufFrxT4um+J3xg0648Vazd6zNa2
|
||||||
|
9xprQ20tzO80iIWtC20M5xuJIGASTzRRQB7b/wAEvv8Ag3++GP8AwSt/aC1j4i+D/GnxD8Ta1q/h+bw4
|
||||||
|
0GuTWRtYreW5triRwsNtGxk32sQB3YC78qSQV+9KKKAP/9k=
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
/9j/4AAQSkZJRgABAQEAYABgAAD/4QC2RXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAAB
|
||||||
|
AAAAJgAAAAAAAZKGAAcAAAB0AAAAOAAAAABDAFIARQBBAFQATwBSADoAIABnAGQALQBqAHAAZQBnACAA
|
||||||
|
dgAxAC4AMAAgACgAdQBzAGkAbgBnACAASQBKAEcAIABKAFAARQBHACAAdgA2ADIAKQAsACAAcQB1AGEA
|
||||||
|
bABpAHQAeQAgAD0AIAA2ADAACgAAAAAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcH
|
||||||
|
BgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwM
|
||||||
|
DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAHgAlAwEiAAIRAQMR
|
||||||
|
Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
|
||||||
|
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElK
|
||||||
|
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrC
|
||||||
|
w8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAAB
|
||||||
|
AgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj
|
||||||
|
M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5
|
||||||
|
eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm
|
||||||
|
5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A/fqQ4Wvkr/gqf/wWM+FX/BKv4frJ4ouD4i8fataNcaB4
|
||||||
|
N0+dVvtT5ZFmmYgi1tN6kNO4I+SQRpK6+XXzZ/wXr/4OBJv+CcuqXHwk+GuizXfxf1bS4786xqloy6V4
|
||||||
|
dtpy6pcRo4H2yf5H2qMwowzIzlGgb+b74m/E7xJ8aviHrHi7xhrmqeJvFHiCc3Oo6rqU7T3V3JgKC7Hn
|
||||||
|
5VCqAuFVVVVAVQKAP6Jf+DbL/gp78X/+CmPx1/aO1v4na3DcafpcPh+XRNCsbYQ6d4fSZtTDxwA5dtwh
|
||||||
|
j3PIzM5TkgAAfrNX8PPgD4v+L/hLLeSeEvF3ivwm+oBFum0XWLjTmugm7YJDC679pdyN2cb2IxuNdJ/w
|
||||||
|
2N8Yv+iwfFn/AMLLUv8A49/n9aAP7YqK/J7/AINFvi/4t+Ln7D/xOm8XeKfE3iq4074gS29rNrOpz6hN
|
||||||
|
bRnTbBzGskrMwXcWbbnALE4yTRQB9y/8FAf+Cbfwp/4KXfB5fCPxO0RrprEyS6NrViywat4fmcANJazF
|
||||||
|
W27tqbo3Vo5Nih0faMfzBf8ABUn/AII7/Fb/AIJU+PFj8V2v/CSfD/VLprfQ/Gmn2rLp9+2CywTpkm0u
|
||||||
|
ioJ8l2Ifa5jeQI5X+vmsD4pfC7w38bPh9q3hPxdoel+JPDevQG11DTNStluLW7jPO10YEHkAjuCARggG
|
||||||
|
gD+Rj/gmX/wSL+KH/BWHVPG1n8M9Y8BaTJ4BisJdSPifUbu0WYXhuVi8n7Paz7sfZZN24LjcuN2Tt+sv
|
||||||
|
+IPb9qYfe8Y/s/4/7GHV/wD5V1+xn/BMX/gjP4L/AOCVvxr+MniDwB4i1a78K/FI6Z9g8P6hH5snhpbQ
|
||||||
|
3jNEt2XL3EbG7wnmKJESIB3mYl6+yKAPgv8A4N/v+CX3xB/4JW/sxeNPCHxF1jwfq+teJvFr65A3hy6u
|
||||||
|
Lm1itzZWkChpJ4IW8wvDJlQm0DadxJIUr70ooA//2Q==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
/9j/4AAQSkZJRgABAQEAYABgAAD/4QC2RXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAAB
|
||||||
|
AAAAJgAAAAAAAZKGAAcAAAB0AAAAOAAAAABDAFIARQBBAFQATwBSADoAIABnAGQALQBqAHAAZQBnACAA
|
||||||
|
dgAxAC4AMAAgACgAdQBzAGkAbgBnACAASQBKAEcAIABKAFAARQBHACAAdgA2ADIAKQAsACAAcQB1AGEA
|
||||||
|
bABpAHQAeQAgAD0AIAA2ADAACgAAAAAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcH
|
||||||
|
BgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwM
|
||||||
|
DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAJQAeAwEiAAIRAQMR
|
||||||
|
Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
|
||||||
|
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElK
|
||||||
|
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrC
|
||||||
|
w8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAAB
|
||||||
|
AgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj
|
||||||
|
M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5
|
||||||
|
eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm
|
||||||
|
5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A/fyv5Wv2qf8Agvj+2F4V/al+JukaT8cNZ0zSdH8X6vp1
|
||||||
|
jZwaJpPl2tvBfTRRRrutSxCoijLEk4ySTk1/VLX8Tv7Y3H7Y3xg/7HvXv/TlcUAfsh/wbN/8FV/2hv22
|
||||||
|
f2+/FXgz4rfE7UPGvhm18AXutwWV1pmn2/k3kOo6ZCkoeC3jfiO5mUru2ncCQSqkfulX81f/AAZ6/wDK
|
||||||
|
U7xj/wBkq1T/ANO+i1/SpQB+Bf8Awcw/Az9pD9j742SfG74f/Gf41W/wj8cXMUF/ZaZ411O2t/B2p7Qi
|
||||||
|
xCKKZVjtbjbmNgNqS74yV3wh/wAU9U1O61zVLq+vrq6vr6+me5ubm5laaa5ldizyO7EszsxLFmJJJJJJ
|
||||||
|
Nf26/Gn4M+F/2iPhR4g8DeNtFs/EXhTxRZSafqmnXIPl3MLjBGVIZWHBV0IdGCspVgCP5IP+CtH/AATH
|
||||||
|
8Uf8EsP2rL7wTqn27U/B+riTUPB3iCZBt1qwDAFXZQE+1QFljmQBcEpIFVJo8gHgfwx+MnjD4G+IpNZ8
|
||||||
|
D+LvFngvWLi2aykvvDur3OmXk0DujtAZLd0dkZ442KZILIhwSox/U9/wQW/Y3+MH7Ln7KE2vfHT4jfEX
|
||||||
|
xh8QviMbfU7jRvE+v3eqReELZFfyLSMXEjlLllkL3DLtG7y48HyBI/5w/wDBrx/wRlb4neJtL/ae+Jmm
|
||||||
|
xt4b0K7Mnw/0q5i3f2lexNg6s6kY8qB1It+paZWl+URRNJ/QNQAV4l+3X/wT5+Fv/BRv4T2fgv4raDJr
|
||||||
|
Wj6fqUOq2j2909pdWk0Zw3lzRkOqyRl4nAPKSNjDBWUooA9a8MeHdN8F+G9P0bR9PsdJ0fSbWKzsbGyg
|
||||||
|
W3trKBFCRxRRqAqIiqFVVAAAAAAFadFFAH//2Q==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
/9j/4AAQSkZJRgABAQEAYABgAAD/4QC2RXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAAB
|
||||||
|
AAAAJgAAAAAAAZKGAAcAAAB0AAAAOAAAAABDAFIARQBBAFQATwBSADoAIABnAGQALQBqAHAAZQBnACAA
|
||||||
|
dgAxAC4AMAAgACgAdQBzAGkAbgBnACAASQBKAEcAIABKAFAARQBHACAAdgA2ADIAKQAsACAAcQB1AGEA
|
||||||
|
bABpAHQAeQAgAD0AIAA2ADAACgAAAAAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcH
|
||||||
|
BgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwM
|
||||||
|
DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAHgAlAwEiAAIRAQMR
|
||||||
|
Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
|
||||||
|
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElK
|
||||||
|
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrC
|
||||||
|
w8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAAB
|
||||||
|
AgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj
|
||||||
|
M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5
|
||||||
|
eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm
|
||||||
|
5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A/fyiv5Wv+C+H7VPxS8K/8Fg/jhpOkfE34jaPpOmajp8F
|
||||||
|
nY6d4mvrO1tU/smybakUUqooLMzHAGSxJ5JNfIX/AA2N8Yx/zWD4s/8AhZal/wDHqAP1u+Bn/BzD42/Y
|
||||||
|
+/4KQfGf4f8AxukvvHHwjt/iP4g0yyv4Ldf7Y8HQxancQxCNVA+1WqKihoj+9RcmNn2iF/3J+DPxp8J/
|
||||||
|
tEfC7RfG3gbxBpnijwp4it/tOnapp84lt7lMlTgjoysrIyEBkdWVgGUgfxFanql1rmqXV9fXVzfX19M9
|
||||||
|
zc3NzK0s1zK7Fnd3YlmdmZmYsSSWYkkmvpb/AIJj/wDBWj4rf8EsPih/angm+XV/B+p3KzeIPB2oTsum
|
||||||
|
a0uArOpAJtrrYqhbiMEjYgkWZF8sgH9hVFeJf8E+f26/Cf8AwUb/AGW9B+K3guz1vT9H1p5rd7TVbUwX
|
||||||
|
FrcQuY5o9wzHKqupAkiZkOMZDBlUoA/Jr/gqv/wbN/H79tn/AIKGfE74reDPFXwgtfDPjW7s7qyg1vVt
|
||||||
|
Rtb+HytPtbdxIkVhMg+eF9pWQ5XaSFJKj59/4g9f2qP+hx/Z/wD/AAodX/8AlXX9KlFAH8PPxk+GOo/A
|
||||||
|
34w+LvA+syWVxrHgvXr7w7fSWTvLbzXNpcyW0hhZ1V2RniO0sqsQwyqk4H7Af8EZf+DXjU/ifLpvxM/a
|
||||||
|
e0vUNC8NsiXOlfD+QtbahqWcFX1MjD28WP8Al1GJmLfvTEFaKT9Hv2N/+CC3wn/Zc/bA+I3x016ZviN8
|
||||||
|
QvGHi7UvE+jXGp2SxWnhCO7u5bkR20G51e5Uy7TdOd2EXy0hzIH+6KAMzw74Y03wX4c0/R9H0+x0nR9J
|
||||||
|
to7KxsbO2WK2soI1CRxRRoAsaIoVVVQAAAAABRWnRQB//9k=
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
108
Airbus/Generics/AirbusGenericCollection.cs
Normal file
108
Airbus/Generics/AirbusGenericCollection.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.MovementStrategy;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Generics
|
||||||
|
{
|
||||||
|
internal class AirbusGenericCollection<T, U>
|
||||||
|
where T : DrawningAirbus
|
||||||
|
where U : IMoveableObject
|
||||||
|
{
|
||||||
|
public int count => _collection.Count;
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
// Размер занимаемого места 89х34
|
||||||
|
private readonly int _placeSizeWidth = 189;
|
||||||
|
private readonly int _placeSizeHeight = 134;
|
||||||
|
// коллекция
|
||||||
|
private readonly SetGeneric<T> _collection;
|
||||||
|
|
||||||
|
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 int operator +(AirbusGenericCollection<T, U> collect, T? obj)
|
||||||
|
{
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
return collect._collection.Insert(obj);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
public static bool operator -(AirbusGenericCollection<T, U> collect, int pos)
|
||||||
|
{
|
||||||
|
if (collect._collection.GetAirbus(pos) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return collect?._collection.Remove(pos) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// получение объектов коллекции
|
||||||
|
public IEnumerable<T?> GetAirbus => _collection.GetAirbus();
|
||||||
|
|
||||||
|
// получение объекта IMoveableObjecr
|
||||||
|
public U? GetU(int pos)
|
||||||
|
{
|
||||||
|
return (U?)_collection[pos]?.GetMoveableObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// вывод всего набора
|
||||||
|
public Bitmap ShowAirbus()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
DrawBackground(gr);
|
||||||
|
DrawObjects(gr);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// прорисовка фона
|
||||||
|
private void DrawBackground(Graphics gr)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black, 3);
|
||||||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||||
|
{
|
||||||
|
// линия разметки
|
||||||
|
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||||
|
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// прорисовка объекта
|
||||||
|
private void DrawObjects(Graphics g)
|
||||||
|
{
|
||||||
|
// координаты
|
||||||
|
int x = _pictureWidth / _placeSizeWidth - 1;
|
||||||
|
int y = _pictureHeight / _placeSizeHeight - 1;
|
||||||
|
|
||||||
|
foreach (var airbus in _collection.GetAirbus())
|
||||||
|
{
|
||||||
|
if (airbus != null)
|
||||||
|
{
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = _pictureWidth / _placeSizeWidth - 1;
|
||||||
|
--y;
|
||||||
|
}
|
||||||
|
airbus.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||||
|
airbus.DrawTransport(g);
|
||||||
|
--x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
172
Airbus/Generics/AirbusGenericStorage.cs
Normal file
172
Airbus/Generics/AirbusGenericStorage.cs
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.MovementStrategy;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.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)
|
||||||
|
{
|
||||||
|
// проверка, что нет набора с таким именем
|
||||||
|
foreach (string nameStorage in Keys)
|
||||||
|
{
|
||||||
|
if (nameStorage == name)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_airbusStorages.Add(name, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Удаление набора
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
if ( _airbusStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_airbusStorages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Доступ к набору
|
||||||
|
public AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>? this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_airbusStorages.ContainsKey(ind))
|
||||||
|
{
|
||||||
|
return _airbusStorages[ind];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Сохранение информации по автомобилям в хранилище в файл
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (_airbusStorages.Count == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалидная операция, нет данных для сохранения");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamWriter sw = File.CreateText(filename))
|
||||||
|
{
|
||||||
|
sw.WriteLine($"AirbusStorage");
|
||||||
|
|
||||||
|
foreach (var record in _airbusStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
|
||||||
|
if (record.Value.count <= 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалидная операция, нет данных для сохранения");
|
||||||
|
}
|
||||||
|
foreach (DrawningAirbus? elem in record.Value.GetAirbus)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
sw.WriteLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Загрузка информации по автомобилям в хранилище из файла
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Файл {filename} не найден");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader sr = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
// 1-ая строка
|
||||||
|
string? curLine = sr.ReadLine();
|
||||||
|
// пустая или не те данные
|
||||||
|
if (curLine == null || curLine.Length == 0 || !curLine.StartsWith("AirbusStorage"))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Неверный формат данных");
|
||||||
|
}
|
||||||
|
// очищаем
|
||||||
|
_airbusStorages.Clear();
|
||||||
|
|
||||||
|
// загружаем данные построчно
|
||||||
|
curLine = sr.ReadLine();
|
||||||
|
if (curLine == null || curLine.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Нет данных");
|
||||||
|
}
|
||||||
|
while (curLine != null)
|
||||||
|
{
|
||||||
|
// загружаем запись
|
||||||
|
if (!curLine.Contains(_separatorRecords))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Коллекция пуста");
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] record = curLine.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
// загружаем набор
|
||||||
|
AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
// record[0] - название набора, record[1] - куча объектов
|
||||||
|
|
||||||
|
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
foreach (string elem in set)
|
||||||
|
{
|
||||||
|
DrawningAirbus? airbus = elem?.CreateDrawningAirbus(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
// проверяем, не переполнится ли коллекция
|
||||||
|
if (airbus != null)
|
||||||
|
{
|
||||||
|
if (collection + airbus == -1)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалидная операция, ошибка добавления в коллекцию");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_airbusStorages.Add(record[0], collection);
|
||||||
|
curLine = sr.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
Airbus/Generics/SetGeneric.cs
Normal file
94
Airbus/Generics/SetGeneric.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using ProjectAirbus.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.Generics
|
||||||
|
{
|
||||||
|
internal class SetGeneric<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
// список объектов
|
||||||
|
private readonly List<T?> _places;
|
||||||
|
// кол-во объектов
|
||||||
|
public int Count => _places.Count;
|
||||||
|
// максимальное количество
|
||||||
|
private readonly int _maxCount;
|
||||||
|
|
||||||
|
public SetGeneric(int count)
|
||||||
|
{
|
||||||
|
_maxCount = count;
|
||||||
|
_places = new List<T?>(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Добавление объекта в начало набора
|
||||||
|
public int Insert(T airbus)
|
||||||
|
{
|
||||||
|
return Insert(airbus, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Добавление объекта в набор на конкретную позицию
|
||||||
|
public int Insert(T airbus, int position)
|
||||||
|
{
|
||||||
|
if (Count >= _maxCount)
|
||||||
|
{
|
||||||
|
throw new StorageOverflowException(_maxCount);
|
||||||
|
}
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("Индекс вне границ коллекции");
|
||||||
|
}
|
||||||
|
_places.Insert(position, airbus);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Удаление объекта из набора с конкретной позиции
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
throw new AirbusNotFoundException(position);
|
||||||
|
}
|
||||||
|
_places.RemoveAt(position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение объекта из набора по позиции
|
||||||
|
public T? this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || Count >= _maxCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_places.Insert(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
89
Airbus/MovementStrategy/AbstractStrategy.cs
Normal file
89
Airbus/MovementStrategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.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 (IsTargetDestination())
|
||||||
|
{
|
||||||
|
_state = Status.Finish;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MoveToTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// перемещения
|
||||||
|
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||||
|
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||||
|
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||||
|
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||||
|
|
||||||
|
// параметры
|
||||||
|
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||||
|
// шаг
|
||||||
|
protected int? GetStep()
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _moveableObject?.GetStep;
|
||||||
|
}
|
||||||
|
// перемещение
|
||||||
|
protected abstract void MoveToTarget();
|
||||||
|
|
||||||
|
// достигнута ли цель
|
||||||
|
protected abstract bool IsTargetDestination();
|
||||||
|
|
||||||
|
// попытка перемещения по направлению
|
||||||
|
private bool MoveTo(DirectionType directionType)
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||||
|
{
|
||||||
|
_moveableObject.MoveObject(directionType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
Airbus/MovementStrategy/DrawningObjectAirbus.cs
Normal file
39
Airbus/MovementStrategy/DrawningObjectAirbus.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.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(DirectionType direction) => _drawningAirbus?.CanMove(direction) ?? false;
|
||||||
|
|
||||||
|
public void MoveObject(DirectionType direction) => _drawningAirbus?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
}
|
15
Airbus/MovementStrategy/IMoveableObject.cs
Normal file
15
Airbus/MovementStrategy/IMoveableObject.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using ProjectAirbus.Drawnings;
|
||||||
|
using ProjectAirbus.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.MovementStrategy
|
||||||
|
{
|
||||||
|
public interface IMoveableObject
|
||||||
|
{
|
||||||
|
ObjectParameters? GetObjectPosition { get; }
|
||||||
|
|
||||||
|
int GetStep { get; }
|
||||||
|
bool CheckCanMove(DirectionType direction);
|
||||||
|
void MoveObject(DirectionType direction);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
61
Airbus/MovementStrategy/MoveToBorder.cs
Normal file
61
Airbus/MovementStrategy/MoveToBorder.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.MovementStrategy
|
||||||
|
{
|
||||||
|
internal class MoveToBorder : AbstractStrategy
|
||||||
|
{
|
||||||
|
|
||||||
|
// достигнута ли цель
|
||||||
|
protected override bool IsTargetDestination()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return objParams.RightBorder <= FieldWidth &&
|
||||||
|
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||||
|
objParams.DownBorder <= FieldHeight &&
|
||||||
|
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// движение к цели
|
||||||
|
protected override void MoveToTarget()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var diffX = FieldWidth;
|
||||||
|
if (Math.Abs(diffX) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffX < 0)
|
||||||
|
{
|
||||||
|
MoveLeft();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var diffY = FieldHeight;
|
||||||
|
if (Math.Abs(diffY) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffY < 0)
|
||||||
|
{
|
||||||
|
MoveUp();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
Airbus/MovementStrategy/MoveToCenter.cs
Normal file
59
Airbus/MovementStrategy/MoveToCenter.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirbus.MovementStrategy
|
||||||
|
{
|
||||||
|
internal class MoveToCenter : AbstractStrategy
|
||||||
|
{
|
||||||
|
// достигнута ли цель
|
||||||
|
protected override bool IsTargetDestination()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
Airbus/MovementStrategy/ObjectParameters.cs
Normal file
27
Airbus/MovementStrategy/ObjectParameters.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
namespace ProjectAirbus.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Airbus/MovementStrategy/Status.cs
Normal file
15
Airbus/MovementStrategy/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 ProjectAirbus.MovementStrategy
|
||||||
|
{
|
||||||
|
internal enum Status
|
||||||
|
{
|
||||||
|
NotInit,
|
||||||
|
InProgress,
|
||||||
|
Finish
|
||||||
|
}
|
||||||
|
}
|
45
Airbus/Program.cs
Normal file
45
Airbus/Program.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace ProjectAirbus
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormAirbusCollection>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormAirbusCollection>().AddLogging(option =>
|
||||||
|
{
|
||||||
|
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||||
|
string pathNeed = "";
|
||||||
|
for (int i = 0; i < path.Length - 3; i++)
|
||||||
|
{
|
||||||
|
pathNeed += path[i] + "\\";
|
||||||
|
}
|
||||||
|
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}serilog.json", optional: false, reloadOnChange: true).Build();
|
||||||
|
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||||
|
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddSerilog(logger);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
Airbus/ProjectAirbus.csproj
Normal file
46
Airbus/ProjectAirbus.csproj
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.7" />
|
||||||
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="serilog.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
|
||||||
|
|
||||||
|
</Project>
|
63
Airbus/Properties/Resources.Designer.cs
generated
Normal file
63
Airbus/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ProjectAirbus.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("ProjectAirbus.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Airbus/Properties/Resources.resx
Normal file
120
Airbus/Properties/Resources.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>
|
BIN
Airbus/images/KeyDown.jpg
Normal file
BIN
Airbus/images/KeyDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
Airbus/images/KeyLeft.jpg
Normal file
BIN
Airbus/images/KeyLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Airbus/images/KeyRight.jpg
Normal file
BIN
Airbus/images/KeyRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Airbus/images/KeyUp.jpg
Normal file
BIN
Airbus/images/KeyUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
20
Airbus/serilog.json
Normal file
20
Airbus/serilog.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Information",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "Logs/carlog.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "ProjectAirbus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user