Compare commits
No commits in common. "Laba7" and "main" have entirely different histories.
@ -1,121 +0,0 @@
|
||||
|
||||
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-стратегия перемещения объекта
|
||||
/// </summary>
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Перемещаемый объект
|
||||
/// </summary>
|
||||
private IMoveableObject? _moveableObject;
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
private Status _state = Status.NotInit;
|
||||
/// <summary>
|
||||
/// Ширина поля
|
||||
/// </summary>
|
||||
protected int FieldWidth { get; private set; }
|
||||
/// <summary>
|
||||
/// Высота поля
|
||||
/// </summary>
|
||||
protected int FieldHeight { get; private set; }
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
public Status GetStatus() { return _state; }
|
||||
/// <summary>
|
||||
/// Установка данных
|
||||
/// </summary>
|
||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
|
||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||
|
||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||
|
||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||
|
||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||
/// <summary>
|
||||
/// Параметры объекта
|
||||
/// </summary>
|
||||
protected ObjectParameters? GetObjectParameters =>
|
||||
_moveableObject?.GetObjectPosition;
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение к цели
|
||||
/// </summary>
|
||||
protected abstract void MoveToTarget();
|
||||
/// <summary>
|
||||
/// Достигнута ли цель
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
/// <param name="directionType">Направление</param>
|
||||
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="DirectionType.enum" />
|
||||
<None Remove="FormAirplaneConfig.Designer.cs~RF9e39eb.TMP" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="DirectionType.enum" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,11 +0,0 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public delegate void AirplaneDelegate(DrawningAirplane airplane);
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectAirFighter.Generics
|
||||
{
|
||||
internal class AirplaneslGenericCollection<T,U>
|
||||
where T :DrawningAirplane
|
||||
where U: IMoveableObject
|
||||
{
|
||||
public IEnumerable<T?> GetAirplanes => _collection.GetAirplanes();
|
||||
private readonly int _pictureWidth;
|
||||
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
private readonly int _placeSizeWidth = 166;
|
||||
|
||||
private readonly int _placeSizeHeight = 160;
|
||||
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public AirplaneslGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
|
||||
}
|
||||
|
||||
public static bool operator +(AirplaneslGenericCollection<T,U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
}
|
||||
|
||||
public static T? operator -(AirplaneslGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
collect._collection.Remove(pos);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
|
||||
public Bitmap ShowAirplanes()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var airplane in _collection.GetAirplanes())
|
||||
{
|
||||
|
||||
if (airplane != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
airplane.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth) - _placeSizeWidth / 24, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + (_placeSizeHeight - _placeSizeHeight * 170 / 1000) / 2);
|
||||
airplane.DrawTransport(g);
|
||||
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
namespace ProjectAirFighter.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
internal class AirplaneNotFoundException : ApplicationException
|
||||
{
|
||||
public AirplaneNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public AirplaneNotFoundException() : base() { }
|
||||
public AirplaneNotFoundException(string message) : base(message) { }
|
||||
public AirplaneNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected AirplaneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
|
@ -1,143 +0,0 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
using ProjectAirFighter.Generics;
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace ProjectAirFighter.Generics
|
||||
{
|
||||
internal class AirplanesGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>> _airplaneStorages;
|
||||
public List<string> Keys => _airplaneStorages.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 AirplanesGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_airplaneStorages = new Dictionary<string, AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string,
|
||||
AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>> record in _airplaneStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawningAirplane? elem in record.Value.GetAirplanes)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new Exception("Невалиданя операция, нет данных для сохранения");
|
||||
}
|
||||
string toWrite = $"AirplaneStorage{Environment.NewLine}{data}";
|
||||
var strs = toWrite.Split(new char[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
foreach (var str in strs)
|
||||
{
|
||||
sw.WriteLine(str);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new IOException("Файл не найден");
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
|
||||
|
||||
string str = sr.ReadLine();
|
||||
var strs = str.Split(new char[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
{
|
||||
throw new IOException("Нет данных для загрузки");
|
||||
}
|
||||
if (!strs[0].StartsWith("AirplaneStorage"))
|
||||
{
|
||||
throw new IOException("Неверный формат данных");
|
||||
}
|
||||
_airplaneStorages.Clear();
|
||||
do
|
||||
{
|
||||
string[] record = str.Split(_separatorForKeyValue,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 2)
|
||||
{
|
||||
str = sr.ReadLine();
|
||||
continue;
|
||||
}
|
||||
AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>
|
||||
collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords,
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningAirplane? airplane =
|
||||
elem?.CreateDrawningAirplane(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (airplane != null)
|
||||
{
|
||||
if (!(collection + airplane))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_airplaneStorages.Add(record[0], collection);
|
||||
|
||||
str = sr.ReadLine();
|
||||
} while (str != null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
_airplaneStorages.Add(name, new AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_airplaneStorages.ContainsKey(name))
|
||||
return;
|
||||
_airplaneStorages.Remove(name);
|
||||
}
|
||||
|
||||
public AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_airplaneStorages.ContainsKey(ind))
|
||||
return _airplaneStorages[ind];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
using ProjectAirFighter.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter.DrawningObjects
|
||||
{
|
||||
public class DrawningAirFighter : DrawningAirplane
|
||||
{
|
||||
public DrawningAirFighter(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool racket, bool wing, int width, int height) :
|
||||
base(speed, weight, bodyColor, width, height, 160, 160)
|
||||
{
|
||||
if (EntityAirplane != null)
|
||||
{
|
||||
EntityAirplane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, racket, wing);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeAddColor(Color col)
|
||||
{
|
||||
((EntityAirFighter)EntityAirplane).AdditionalColor = col;
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane is not EntityAirFighter airFighter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Brush additionalBrush = new SolidBrush(airFighter.AdditionalColor);
|
||||
Pen pen = new(Color.Black);
|
||||
base.DrawTransport(g);
|
||||
if (airFighter.Racket)
|
||||
{
|
||||
Brush brGrey = new SolidBrush(Color.LightGray);
|
||||
g.FillRectangle(brGrey, _startPosX + 70, _startPosY - 15, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY - 15, 10, 10);
|
||||
Point[] noseracketPoints =
|
||||
{
|
||||
new Point(_startPosX + 70, _startPosY -5),
|
||||
new Point(_startPosX + 70, _startPosY - 15),
|
||||
new Point(_startPosX + 60,_startPosY -10)
|
||||
};
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
g.FillPolygon(brRed, noseracketPoints);
|
||||
g.DrawPolygon(pen, noseracketPoints);
|
||||
|
||||
g.FillRectangle(brGrey, _startPosX + 70, _startPosY - 40, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY - 40, 10, 10);
|
||||
Point[] noseracketPoints2 =
|
||||
{
|
||||
new Point(_startPosX + 70, _startPosY -30),
|
||||
new Point(_startPosX + 70, _startPosY - 40),
|
||||
new Point(_startPosX + 60,_startPosY -35)
|
||||
};
|
||||
g.FillPolygon(brRed, noseracketPoints2);
|
||||
g.DrawPolygon(pen, noseracketPoints2);
|
||||
g.FillPolygon(brRed, noseracketPoints);
|
||||
g.DrawPolygon(pen, noseracketPoints);
|
||||
|
||||
g.FillRectangle(brGrey, _startPosX + 70, _startPosY + 59, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY + 59, 10, 10);
|
||||
Point[] noseracketPoints3 =
|
||||
{
|
||||
new Point(_startPosX + 70, _startPosY +59),
|
||||
new Point(_startPosX + 70, _startPosY + 69),
|
||||
new Point(_startPosX + 60,_startPosY + 64)
|
||||
};
|
||||
g.FillPolygon(brRed, noseracketPoints3);
|
||||
g.DrawPolygon(pen, noseracketPoints3);
|
||||
|
||||
g.FillRectangle(brGrey, _startPosX + 70, _startPosY + 34, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY + 34, 10, 10);
|
||||
Point[] noseracketPoints4 =
|
||||
{
|
||||
new Point(_startPosX + 70, _startPosY +34),
|
||||
new Point(_startPosX + 70, _startPosY + 44),
|
||||
new Point(_startPosX + 60,_startPosY + 39)
|
||||
};
|
||||
g.FillPolygon(brRed, noseracketPoints4);
|
||||
g.DrawPolygon(pen, noseracketPoints4);
|
||||
}
|
||||
if (airFighter.Wing)
|
||||
{
|
||||
Point[] doprightwingPoints =
|
||||
{
|
||||
new Point(_startPosX + 30, _startPosY + 4),
|
||||
new Point(_startPosX+30,_startPosY - 34),
|
||||
new Point(_startPosX+35,_startPosY - 34),
|
||||
new Point(_startPosX + 45, _startPosY + 4)
|
||||
|
||||
};
|
||||
g.FillPolygon(additionalBrush, doprightwingPoints);
|
||||
g.DrawPolygon(pen, doprightwingPoints);
|
||||
|
||||
Point[] doplefttwingPoints =
|
||||
{
|
||||
new Point(_startPosX + 30, _startPosY + 24),
|
||||
new Point(_startPosX + 30, _startPosY + 59),
|
||||
new Point(_startPosX+35,_startPosY + 59),
|
||||
new Point(_startPosX+45,_startPosY + 24)
|
||||
|
||||
};
|
||||
g.FillPolygon(additionalBrush, doplefttwingPoints);
|
||||
g.DrawPolygon(pen, doplefttwingPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirFighter.Entities;
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
|
||||
namespace ProjectAirFighter.DrawningObjects
|
||||
{
|
||||
public class DrawningAirplane
|
||||
{
|
||||
public EntityAirplane? EntityAirplane { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
char separator = '|';
|
||||
protected int _startPosY;
|
||||
protected readonly int _airplaneWidth = 163;
|
||||
protected readonly int _airplaneHeight = 160;
|
||||
protected readonly int _airplanewingHeight = 70;
|
||||
protected readonly int _airplanerwingkorpusHeight = 90;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _airplaneWidth;
|
||||
public int GetHeight => _airplaneHeight;
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectAirplane(this);
|
||||
|
||||
public DrawningAirplane(int speed, double weight, Color bodyColor,int width, int height)
|
||||
{
|
||||
if (width <= _airplaneWidth || height <= _airplanewingHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityAirplane = new EntityAirplane(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
protected DrawningAirplane(int speed, double weight, Color bodyColor, int
|
||||
width, int height, int airplaneWidth, int airplaneHeight)
|
||||
{
|
||||
if (width <= _airplaneWidth || height <= _airplanewingHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_airplaneWidth = airplaneWidth;
|
||||
_airplanewingHeight = airplaneHeight;
|
||||
EntityAirplane = new EntityAirplane(speed, weight, bodyColor);
|
||||
}
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
return;
|
||||
EntityAirplane.BodyColor= col;
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
return;
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
if (x + _airplaneWidth >= _pictureWidth || y + _airplaneHeight >= _pictureHeight)
|
||||
{
|
||||
_startPosX = 1;
|
||||
_startPosY = (_airplanewingHeight+_airplanerwingkorpusHeight)/2;
|
||||
}
|
||||
}
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityAirplane.Step > 0,
|
||||
|
||||
DirectionType.Up => _startPosY - EntityAirplane.Step - (_airplaneHeight - _airplaneHeight * 125 / 1000) / 2 > 0,
|
||||
|
||||
DirectionType.Right => _startPosX+ EntityAirplane.Step + _airplaneWidth < _pictureWidth,
|
||||
|
||||
DirectionType.Down => _startPosY + EntityAirplane.Step + _airplanerwingkorpusHeight < _pictureHeight,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityAirplane == null)
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
_startPosX -= (int)EntityAirplane.Step;
|
||||
break;
|
||||
|
||||
case DirectionType.Up:
|
||||
_startPosY -= (int)EntityAirplane.Step;
|
||||
break;
|
||||
|
||||
case DirectionType.Right:
|
||||
_startPosX += (int)EntityAirplane.Step;
|
||||
break;
|
||||
|
||||
case DirectionType.Down:
|
||||
_startPosY += (int)EntityAirplane.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
Brush br = new SolidBrush(EntityAirplane.BodyColor);
|
||||
Point[] nosePoints =
|
||||
{
|
||||
new Point(_startPosX + 20, _startPosY + 4),
|
||||
new Point(_startPosX + 20, _startPosY + 24),
|
||||
new Point(_startPosX-3,_startPosY + 12)
|
||||
};
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
g.FillPolygon(brBlack, nosePoints);
|
||||
g.DrawPolygon(pen, nosePoints);
|
||||
|
||||
Point[] rightwingPoints =
|
||||
{
|
||||
new Point(_startPosX + 80, _startPosY + 4),
|
||||
new Point(_startPosX+80,_startPosY - 64),
|
||||
new Point(_startPosX+85,_startPosY - 64),
|
||||
new Point(_startPosX + 100, _startPosY + 4)
|
||||
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, rightwingPoints);
|
||||
g.FillPolygon(br, rightwingPoints);
|
||||
|
||||
Point[] lefttwingPoints =
|
||||
{
|
||||
new Point(_startPosX + 80, _startPosY + 24),
|
||||
new Point(_startPosX + 100, _startPosY + 24),
|
||||
new Point(_startPosX+85,_startPosY + 94),
|
||||
new Point(_startPosX+80,_startPosY + 94)
|
||||
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, lefttwingPoints);
|
||||
g.FillPolygon(br, lefttwingPoints);
|
||||
|
||||
Point[] leftenginePoints =
|
||||
{
|
||||
new Point(_startPosX + 140, _startPosY + 24),
|
||||
new Point(_startPosX + 160, _startPosY + 24),
|
||||
new Point(_startPosX+160,_startPosY + 50),
|
||||
new Point(_startPosX+140,_startPosY + 32)
|
||||
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, leftenginePoints);
|
||||
g.FillPolygon(br, leftenginePoints);
|
||||
|
||||
Point[] rightenginePoints =
|
||||
{
|
||||
new Point(_startPosX + 140, _startPosY + 24),
|
||||
new Point(_startPosX + 160, _startPosY + 24),
|
||||
new Point(_startPosX+160,_startPosY - 16),
|
||||
new Point(_startPosX+140,_startPosY -4)
|
||||
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, rightenginePoints);
|
||||
g.FillPolygon(br, rightenginePoints);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 140, _airplaneHeight * 125 / 1000);
|
||||
g.FillRectangle(br, _startPosX + 20, _startPosY + 4, 140, _airplaneHeight * 125 / 1000);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
public class DrawningObjectAirplane: IMoveableObject
|
||||
{
|
||||
private readonly DrawningAirplane? _drawningAirplane = null;
|
||||
public DrawningObjectAirplane(DrawningAirplane drawningAirplane)
|
||||
{
|
||||
_drawningAirplane = drawningAirplane;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningAirplane == null || _drawningAirplane.EntityAirplane ==
|
||||
null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningAirplane.GetPosX,
|
||||
_drawningAirplane.GetPosY, _drawningAirplane.GetWidth, _drawningAirplane.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningAirplane?.EntityAirplane?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>
|
||||
_drawningAirplane?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>
|
||||
_drawningAirplane?.MoveTransport(direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter.Entities
|
||||
|
||||
{
|
||||
public class EntityAirFighter: EntityAirplane
|
||||
{
|
||||
public Color AdditionalColor { get; set; }
|
||||
public bool Racket { get; private set; }
|
||||
public bool Wing { get; private set; }
|
||||
|
||||
public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool racket, bool wing):
|
||||
base(speed,weight,bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Racket = racket;
|
||||
Wing = wing;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter.Entities
|
||||
{
|
||||
public class EntityAirplane
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
|
||||
public EntityAirplane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirFighter.Entities;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectAirFighter.DrawningObjects
|
||||
{
|
||||
public static class ExtentionDrawningAirplane {
|
||||
public static DrawningAirplane? CreateDrawningAirplane(this string info, char separatorForObject,
|
||||
int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningAirplane(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningAirFighter(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 DrawningAirplane drawningAirplane, char separatorForObject)
|
||||
{
|
||||
var airplane = drawningAirplane.EntityAirplane;
|
||||
if (airplane == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{airplane.Speed}{separatorForObject}{airplane.Weight}{separatorForObject}{airplane.BodyColor.Name}";
|
||||
if (airplane is not EntityAirFighter airfighter)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return
|
||||
$"{str}{separatorForObject}{airfighter.AdditionalColor.Name}{separatorForObject}{airfighter.Wing}{separatorForObject}{airfighter.Racket}";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
193
AirFighter/FormAirFighter.Designer.cs
generated
193
AirFighter/FormAirFighter.Designer.cs
generated
@ -1,193 +0,0 @@
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
partial class FormAirFighter
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxAirFighter = new System.Windows.Forms.PictureBox();
|
||||
this.buttonAirplane = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||
this.buttonStep = new System.Windows.Forms.Button();
|
||||
this.buttonCreateAirFighter = new System.Windows.Forms.Button();
|
||||
this.buttonSelectAirplane = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxAirFighter
|
||||
//
|
||||
this.pictureBoxAirFighter.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxAirFighter.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxAirFighter.Name = "pictureBoxAirFighter";
|
||||
this.pictureBoxAirFighter.Size = new System.Drawing.Size(1015, 736);
|
||||
this.pictureBoxAirFighter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxAirFighter.TabIndex = 0;
|
||||
this.pictureBoxAirFighter.TabStop = false;
|
||||
//
|
||||
// buttonAirplane
|
||||
//
|
||||
this.buttonAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonAirplane.Location = new System.Drawing.Point(186, 694);
|
||||
this.buttonAirplane.Name = "buttonAirplane";
|
||||
this.buttonAirplane.Size = new System.Drawing.Size(180, 40);
|
||||
this.buttonAirplane.TabIndex = 1;
|
||||
this.buttonAirplane.Text = "Создать";
|
||||
this.buttonAirplane.UseVisualStyleBackColor = true;
|
||||
this.buttonAirplane.Click += new System.EventHandler(this.ButtonCreateAirplane_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.png_clipart_computer_icons_graphics_arrow_symbol_arrow_angle_desktop_wallpaper;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(901, 694);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 2;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMoveClick);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.png_transparent_grammatical_person_paper_narration_direzione_didattica_statale_gestione_scuola_elementare_copy_print_right_arrow_miscellaneous_game_angle;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(973, 694);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 3;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMoveClick);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.kisspng_up_arrow_computer_icons_arrow_down_clip_art_5af6157c473cb4_0747815015260767962918;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(937, 658);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 4;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMoveClick);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.png_clipart_computer_icons_uma_musume_pretty_derby_fate_grand_order_saber_kemono_friends_three_arrow_game_angle;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(937, 694);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 5;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMoveClick);
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxStrategy.FormattingEnabled = true;
|
||||
this.comboBoxStrategy.Items.AddRange(new object[] {
|
||||
"Довести до центра",
|
||||
"Довести до края"});
|
||||
this.comboBoxStrategy.Location = new System.Drawing.Point(864, 0);
|
||||
this.comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBoxStrategy.TabIndex = 6;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
this.buttonStep.Location = new System.Drawing.Point(921, 43);
|
||||
this.buttonStep.Name = "buttonStep";
|
||||
this.buttonStep.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonStep.TabIndex = 7;
|
||||
this.buttonStep.Text = "Шаг";
|
||||
this.buttonStep.UseVisualStyleBackColor = true;
|
||||
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
|
||||
//
|
||||
// buttonCreateAirFighter
|
||||
//
|
||||
this.buttonCreateAirFighter.Location = new System.Drawing.Point(0, 696);
|
||||
this.buttonCreateAirFighter.Name = "buttonCreateAirFighter";
|
||||
this.buttonCreateAirFighter.Size = new System.Drawing.Size(180, 40);
|
||||
this.buttonCreateAirFighter.TabIndex = 8;
|
||||
this.buttonCreateAirFighter.Text = "Создать продвинутый";
|
||||
this.buttonCreateAirFighter.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateAirFighter.Click += new System.EventHandler(this.ButtonCreateAirFighter_Click);
|
||||
//
|
||||
// buttonSelectAirplane
|
||||
//
|
||||
this.buttonSelectAirplane.Location = new System.Drawing.Point(372, 696);
|
||||
this.buttonSelectAirplane.Name = "buttonSelectAirplane";
|
||||
this.buttonSelectAirplane.Size = new System.Drawing.Size(180, 40);
|
||||
this.buttonSelectAirplane.TabIndex = 9;
|
||||
this.buttonSelectAirplane.Text = "Выбрать";
|
||||
this.buttonSelectAirplane.UseVisualStyleBackColor = true;
|
||||
this.buttonSelectAirplane.Click += new System.EventHandler(this.buttonSelectAirplane_Click);
|
||||
//
|
||||
// FormAirFighter
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1015, 736);
|
||||
this.Controls.Add(this.buttonSelectAirplane);
|
||||
this.Controls.Add(this.buttonCreateAirFighter);
|
||||
this.Controls.Add(this.buttonStep);
|
||||
this.Controls.Add(this.comboBoxStrategy);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonAirplane);
|
||||
this.Controls.Add(this.pictureBoxAirFighter);
|
||||
this.Name = "FormAirFighter";
|
||||
this.Text = "Form1";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBoxAirFighter;
|
||||
private System.Windows.Forms.Button buttonAirplane;
|
||||
private System.Windows.Forms.Button buttonLeft;
|
||||
private System.Windows.Forms.Button buttonRight;
|
||||
private System.Windows.Forms.Button buttonUp;
|
||||
private System.Windows.Forms.Button buttonDown;
|
||||
public System.Windows.Forms.ComboBox comboBoxStrategy;
|
||||
private System.Windows.Forms.Button buttonStep;
|
||||
private System.Windows.Forms.Button buttonCreateAirFighter;
|
||||
private System.Windows.Forms.Button buttonSelectAirplane;
|
||||
}
|
||||
}
|
||||
|
@ -1,140 +0,0 @@
|
||||
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 ProjectAirFighter.DrawningObjects;
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public partial class FormAirFighter : Form
|
||||
{
|
||||
|
||||
private DrawningAirplane? _drawningAirplane;
|
||||
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
|
||||
public DrawningAirplane? SelectedAirplane { get; private set; }
|
||||
public FormAirFighter()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
SelectedAirplane = null;
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
return;
|
||||
|
||||
Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningAirplane.DrawTransport(gr);
|
||||
pictureBoxAirFighter.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonCreateAirplane_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
bodyColor = dialog.Color;
|
||||
}
|
||||
_drawningAirplane = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
bodyColor,pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||
_drawningAirplane.SetPosition(random.Next(10, 100), random.Next(70, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMoveClick(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
return;
|
||||
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningAirplane.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningAirplane.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningAirplane.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningAirplane.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonCreateAirFighter_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
Color additionalColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
bodyColor = dialog.Color;
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
additionalColor = dialog.Color;
|
||||
|
||||
_drawningAirplane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
|
||||
bodyColor,additionalColor, Convert.ToBoolean(random.Next(0, 2)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||
_drawningAirplane.SetPosition(random.Next(10, 100), random.Next(70, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
return;
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new
|
||||
DrawningObjectAirplane(_drawningAirplane), pictureBoxAirFighter.Width,
|
||||
pictureBoxAirFighter.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSelectAirplane_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedAirplane = _drawningAirplane;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
248
AirFighter/FormAirplaneCollection.Designer.cs
generated
248
AirFighter/FormAirplaneCollection.Designer.cs
generated
@ -1,248 +0,0 @@
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
partial class FormAirplaneCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.toolGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.kitGroupbox = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||
this.ButtonDelObject = new System.Windows.Forms.Button();
|
||||
this.ButtonAddObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.updateCollectionButton = new System.Windows.Forms.Button();
|
||||
this.deleteAirplaneButton = new System.Windows.Forms.Button();
|
||||
this.addAirplaneButton = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.toolGroupBox.SuspendLayout();
|
||||
this.kitGroupbox.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// toolGroupBox
|
||||
//
|
||||
this.toolGroupBox.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.toolGroupBox.Controls.Add(this.kitGroupbox);
|
||||
this.toolGroupBox.Controls.Add(this.updateCollectionButton);
|
||||
this.toolGroupBox.Controls.Add(this.deleteAirplaneButton);
|
||||
this.toolGroupBox.Controls.Add(this.addAirplaneButton);
|
||||
this.toolGroupBox.Controls.Add(this.menuStrip1);
|
||||
this.toolGroupBox.Location = new System.Drawing.Point(769, 12);
|
||||
this.toolGroupBox.Name = "toolGroupBox";
|
||||
this.toolGroupBox.Size = new System.Drawing.Size(232, 632);
|
||||
this.toolGroupBox.TabIndex = 0;
|
||||
this.toolGroupBox.TabStop = false;
|
||||
this.toolGroupBox.Text = "Инструменты";
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(7, 406);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(215, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 7;
|
||||
//
|
||||
// kitGroupbox
|
||||
//
|
||||
this.kitGroupbox.Controls.Add(this.textBoxStorageName);
|
||||
this.kitGroupbox.Controls.Add(this.ButtonDelObject);
|
||||
this.kitGroupbox.Controls.Add(this.ButtonAddObject);
|
||||
this.kitGroupbox.Controls.Add(this.listBoxStorages);
|
||||
this.kitGroupbox.Location = new System.Drawing.Point(7, 74);
|
||||
this.kitGroupbox.Name = "kitGroupbox";
|
||||
this.kitGroupbox.Size = new System.Drawing.Size(217, 280);
|
||||
this.kitGroupbox.TabIndex = 5;
|
||||
this.kitGroupbox.TabStop = false;
|
||||
this.kitGroupbox.Text = "Наборы";
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(17, 26);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(185, 27);
|
||||
this.textBoxStorageName.TabIndex = 9;
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
this.ButtonDelObject.Location = new System.Drawing.Point(23, 233);
|
||||
this.ButtonDelObject.Name = "ButtonDelObject";
|
||||
this.ButtonDelObject.Size = new System.Drawing.Size(184, 29);
|
||||
this.ButtonDelObject.TabIndex = 8;
|
||||
this.ButtonDelObject.Text = "Удалить набор";
|
||||
this.ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(23, 63);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(184, 29);
|
||||
this.ButtonAddObject.TabIndex = 7;
|
||||
this.ButtonAddObject.Text = "Добавить набор";
|
||||
this.ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 20;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(23, 107);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(185, 104);
|
||||
this.listBoxStorages.TabIndex = 6;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxStorages_SelectedIndexChanged);
|
||||
//
|
||||
// updateCollectionButton
|
||||
//
|
||||
this.updateCollectionButton.Location = new System.Drawing.Point(6, 505);
|
||||
this.updateCollectionButton.Name = "updateCollectionButton";
|
||||
this.updateCollectionButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.updateCollectionButton.TabIndex = 3;
|
||||
this.updateCollectionButton.Text = "Обновить коллекцию";
|
||||
this.updateCollectionButton.UseVisualStyleBackColor = true;
|
||||
this.updateCollectionButton.Click += new System.EventHandler(this.updateCollectionButton_Click);
|
||||
//
|
||||
// deleteAirplaneButton
|
||||
//
|
||||
this.deleteAirplaneButton.Location = new System.Drawing.Point(6, 449);
|
||||
this.deleteAirplaneButton.Name = "deleteAirplaneButton";
|
||||
this.deleteAirplaneButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.deleteAirplaneButton.TabIndex = 2;
|
||||
this.deleteAirplaneButton.Text = "Удалить самолёт";
|
||||
this.deleteAirplaneButton.UseVisualStyleBackColor = true;
|
||||
this.deleteAirplaneButton.Click += new System.EventHandler(this.deleteAirplaneButton_Click);
|
||||
//
|
||||
// addAirplaneButton
|
||||
//
|
||||
this.addAirplaneButton.Location = new System.Drawing.Point(8, 360);
|
||||
this.addAirplaneButton.Name = "addAirplaneButton";
|
||||
this.addAirplaneButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.addAirplaneButton.TabIndex = 0;
|
||||
this.addAirplaneButton.Text = "Добавить самолёт";
|
||||
this.addAirplaneButton.UseVisualStyleBackColor = true;
|
||||
this.addAirplaneButton.Click += new System.EventHandler(this.addAirplaneButton_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.файлToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(3, 23);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(226, 28);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
this.файлToolStripMenuItem.Size = new System.Drawing.Size(59, 24);
|
||||
this.файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
|
||||
this.SaveToolStripMenuItem.Text = "Сохранение";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
|
||||
this.LoadToolStripMenuItem.Text = "Загрузка";
|
||||
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(675, 632);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormAirplaneCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1017, 654);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Controls.Add(this.toolGroupBox);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormAirplaneCollection";
|
||||
this.Text = "FormMonorailCollection";
|
||||
this.toolGroupBox.ResumeLayout(false);
|
||||
this.toolGroupBox.PerformLayout();
|
||||
this.kitGroupbox.ResumeLayout(false);
|
||||
this.kitGroupbox.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox toolGroupBox;
|
||||
private Button updateCollectionButton;
|
||||
private Button deleteAirplaneButton;
|
||||
private Button addAirplaneButton;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private GroupBox kitGroupbox;
|
||||
private Button ButtonAddObject;
|
||||
private ListBox listBoxStorages;
|
||||
private Button ButtonDelObject;
|
||||
private TextBox textBoxStorageName;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
@ -1,228 +0,0 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
using ProjectAirFighter.Generics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectAirFighter.Exceptions;
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
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 System.Xml.Linq;
|
||||
using Serilog;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using Log = Serilog.Log;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public partial class FormAirplaneCollection : Form
|
||||
{
|
||||
private readonly AirplanesGenericStorage _storage;
|
||||
|
||||
public FormAirplaneCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new AirplanesGenericStorage(pictureBoxCollection.Width,
|
||||
pictureBoxCollection.Height);
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning("Не удалось сохранить");
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.LoadData(openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка прошла успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
foreach (var collection in _storage.Keys)
|
||||
{
|
||||
listBoxStorages.Items.Add(collection);
|
||||
}
|
||||
ReloadObjects();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning("Не удалось загрузить");
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowAirplanes();
|
||||
}
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
Log.Information($"Добавлен набор: {textBoxStorageName.Text}");
|
||||
|
||||
}
|
||||
private void deleteAirplaneButton_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);
|
||||
var q = obj - pos;
|
||||
MessageBox.Show("Объект удален");
|
||||
Log.Information($"Удален объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty} по номеру {pos}");
|
||||
pictureBoxCollection.Image = obj.ShowAirplanes();
|
||||
}
|
||||
catch (AirplaneNotFoundException ex)
|
||||
{
|
||||
Log.Warning($"Не получилось удалить объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
Log.Warning($"Было введено не число");
|
||||
MessageBox.Show("Введите число");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCollectionButton_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.ShowAirplanes();
|
||||
|
||||
}
|
||||
private void addAirplaneButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormAirplaneConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningAirplane>? airplaneDelegate = new((m) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
bool q = obj + m;
|
||||
MessageBox.Show("Объект добавлен");
|
||||
Log.Information($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
|
||||
pictureBoxCollection.Image = obj.ShowAirplanes();
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
Log.Warning($"Коллекция {listBoxStorages.SelectedItem.ToString() ?? string.Empty} переполнена");
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
});
|
||||
form.AddEvent(airplaneDelegate);
|
||||
}
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image =
|
||||
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAirplanes();
|
||||
|
||||
}
|
||||
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
string name = listBoxStorages.SelectedItem.ToString()
|
||||
?? string.Empty;
|
||||
_storage.DelSet(name);
|
||||
ReloadObjects();
|
||||
Log.Information($"Удален набор: {name}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>311, 17</value>
|
||||
</metadata>
|
||||
</root>
|
391
AirFighter/FormAirplaneConfig.Designer.cs
generated
391
AirFighter/FormAirplaneConfig.Designer.cs
generated
@ -1,391 +0,0 @@
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
partial class FormAirplaneConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.configGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.colorGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.yellowPanel = new System.Windows.Forms.Panel();
|
||||
this.bluePanel = new System.Windows.Forms.Panel();
|
||||
this.greenPanel = new System.Windows.Forms.Panel();
|
||||
this.purplePanel = new System.Windows.Forms.Panel();
|
||||
this.blackPanel = new System.Windows.Forms.Panel();
|
||||
this.greyPanel = new System.Windows.Forms.Panel();
|
||||
this.whitePanel = new System.Windows.Forms.Panel();
|
||||
this.redPanel = new System.Windows.Forms.Panel();
|
||||
this.airfighterLabel = new System.Windows.Forms.Label();
|
||||
this.airplaneLabel = new System.Windows.Forms.Label();
|
||||
this.checkwing = new System.Windows.Forms.CheckBox();
|
||||
this.checkracket = new System.Windows.Forms.CheckBox();
|
||||
this.numericWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.weightLabel = new System.Windows.Forms.Label();
|
||||
this.speedLabel = new System.Windows.Forms.Label();
|
||||
this.allowPanel = new System.Windows.Forms.Panel();
|
||||
this.addColorLabel = new System.Windows.Forms.Label();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.colorLabel = new System.Windows.Forms.Label();
|
||||
this.addButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.configGroupBox.SuspendLayout();
|
||||
this.colorGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit();
|
||||
this.allowPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// configGroupBox
|
||||
//
|
||||
this.configGroupBox.Controls.Add(this.colorGroupBox);
|
||||
this.configGroupBox.Controls.Add(this.airfighterLabel);
|
||||
this.configGroupBox.Controls.Add(this.airplaneLabel);
|
||||
this.configGroupBox.Controls.Add(this.checkwing);
|
||||
this.configGroupBox.Controls.Add(this.checkracket);
|
||||
this.configGroupBox.Controls.Add(this.numericWeight);
|
||||
this.configGroupBox.Controls.Add(this.numericSpeed);
|
||||
this.configGroupBox.Controls.Add(this.weightLabel);
|
||||
this.configGroupBox.Controls.Add(this.speedLabel);
|
||||
this.configGroupBox.Location = new System.Drawing.Point(11, 12);
|
||||
this.configGroupBox.Name = "configGroupBox";
|
||||
this.configGroupBox.Size = new System.Drawing.Size(446, 279);
|
||||
this.configGroupBox.TabIndex = 0;
|
||||
this.configGroupBox.TabStop = false;
|
||||
this.configGroupBox.Text = "Параметры";
|
||||
//
|
||||
// colorGroupBox
|
||||
//
|
||||
this.colorGroupBox.Controls.Add(this.yellowPanel);
|
||||
this.colorGroupBox.Controls.Add(this.bluePanel);
|
||||
this.colorGroupBox.Controls.Add(this.greenPanel);
|
||||
this.colorGroupBox.Controls.Add(this.purplePanel);
|
||||
this.colorGroupBox.Controls.Add(this.blackPanel);
|
||||
this.colorGroupBox.Controls.Add(this.greyPanel);
|
||||
this.colorGroupBox.Controls.Add(this.whitePanel);
|
||||
this.colorGroupBox.Controls.Add(this.redPanel);
|
||||
this.colorGroupBox.Location = new System.Drawing.Point(171, 23);
|
||||
this.colorGroupBox.Name = "colorGroupBox";
|
||||
this.colorGroupBox.Size = new System.Drawing.Size(234, 143);
|
||||
this.colorGroupBox.TabIndex = 7;
|
||||
this.colorGroupBox.TabStop = false;
|
||||
this.colorGroupBox.Text = "Цвета";
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
this.yellowPanel.AllowDrop = true;
|
||||
this.yellowPanel.BackColor = System.Drawing.Color.Yellow;
|
||||
this.yellowPanel.Location = new System.Drawing.Point(174, 27);
|
||||
this.yellowPanel.Name = "yellowPanel";
|
||||
this.yellowPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.yellowPanel.TabIndex = 3;
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
this.bluePanel.AllowDrop = true;
|
||||
this.bluePanel.BackColor = System.Drawing.Color.Blue;
|
||||
this.bluePanel.Location = new System.Drawing.Point(118, 27);
|
||||
this.bluePanel.Name = "bluePanel";
|
||||
this.bluePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.bluePanel.TabIndex = 2;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
this.greenPanel.AllowDrop = true;
|
||||
this.greenPanel.BackColor = System.Drawing.Color.Green;
|
||||
this.greenPanel.Location = new System.Drawing.Point(62, 27);
|
||||
this.greenPanel.Name = "greenPanel";
|
||||
this.greenPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.greenPanel.TabIndex = 1;
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
this.purplePanel.AllowDrop = true;
|
||||
this.purplePanel.BackColor = System.Drawing.Color.Purple;
|
||||
this.purplePanel.Location = new System.Drawing.Point(174, 83);
|
||||
this.purplePanel.Name = "purplePanel";
|
||||
this.purplePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.purplePanel.TabIndex = 3;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
this.blackPanel.AllowDrop = true;
|
||||
this.blackPanel.BackColor = System.Drawing.Color.Black;
|
||||
this.blackPanel.Location = new System.Drawing.Point(118, 83);
|
||||
this.blackPanel.Name = "blackPanel";
|
||||
this.blackPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.blackPanel.TabIndex = 2;
|
||||
//
|
||||
// greyPanel
|
||||
//
|
||||
this.greyPanel.AllowDrop = true;
|
||||
this.greyPanel.BackColor = System.Drawing.Color.Silver;
|
||||
this.greyPanel.Location = new System.Drawing.Point(62, 83);
|
||||
this.greyPanel.Name = "greyPanel";
|
||||
this.greyPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.greyPanel.TabIndex = 1;
|
||||
//
|
||||
// whitePanel
|
||||
//
|
||||
this.whitePanel.AllowDrop = true;
|
||||
this.whitePanel.BackColor = System.Drawing.Color.White;
|
||||
this.whitePanel.Location = new System.Drawing.Point(6, 83);
|
||||
this.whitePanel.Name = "whitePanel";
|
||||
this.whitePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.whitePanel.TabIndex = 1;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
this.redPanel.AllowDrop = true;
|
||||
this.redPanel.BackColor = System.Drawing.Color.Red;
|
||||
this.redPanel.Location = new System.Drawing.Point(6, 27);
|
||||
this.redPanel.Name = "redPanel";
|
||||
this.redPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.redPanel.TabIndex = 0;
|
||||
//
|
||||
// airfighterLabel
|
||||
//
|
||||
this.airfighterLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.airfighterLabel.Location = new System.Drawing.Point(297, 169);
|
||||
this.airfighterLabel.Name = "airfighterLabel";
|
||||
this.airfighterLabel.Size = new System.Drawing.Size(120, 50);
|
||||
this.airfighterLabel.TabIndex = 9;
|
||||
this.airfighterLabel.Text = "Продвинутый";
|
||||
this.airfighterLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// airplaneLabel
|
||||
//
|
||||
this.airplaneLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.airplaneLabel.Location = new System.Drawing.Point(171, 169);
|
||||
this.airplaneLabel.Name = "airplaneLabel";
|
||||
this.airplaneLabel.Size = new System.Drawing.Size(120, 50);
|
||||
this.airplaneLabel.TabIndex = 8;
|
||||
this.airplaneLabel.Text = "Простой";
|
||||
this.airplaneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// checkwing
|
||||
//
|
||||
this.checkwing.AutoSize = true;
|
||||
this.checkwing.Location = new System.Drawing.Point(6, 163);
|
||||
this.checkwing.Name = "checkwing";
|
||||
this.checkwing.Size = new System.Drawing.Size(183, 24);
|
||||
this.checkwing.TabIndex = 5;
|
||||
this.checkwing.Text = "наличие доп крыльев";
|
||||
this.checkwing.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkracket
|
||||
//
|
||||
this.checkracket.AutoSize = true;
|
||||
this.checkracket.Location = new System.Drawing.Point(6, 132);
|
||||
this.checkracket.Name = "checkracket";
|
||||
this.checkracket.Size = new System.Drawing.Size(132, 24);
|
||||
this.checkracket.TabIndex = 4;
|
||||
this.checkracket.Text = "наличие ракет";
|
||||
this.checkracket.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericWeight
|
||||
//
|
||||
this.numericWeight.Location = new System.Drawing.Point(6, 99);
|
||||
this.numericWeight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWeight.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWeight.Name = "numericWeight";
|
||||
this.numericWeight.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericWeight.TabIndex = 3;
|
||||
this.numericWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericSpeed
|
||||
//
|
||||
this.numericSpeed.Location = new System.Drawing.Point(6, 45);
|
||||
this.numericSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericSpeed.Name = "numericSpeed";
|
||||
this.numericSpeed.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericSpeed.TabIndex = 2;
|
||||
this.numericSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// weightLabel
|
||||
//
|
||||
this.weightLabel.AutoSize = true;
|
||||
this.weightLabel.Location = new System.Drawing.Point(6, 76);
|
||||
this.weightLabel.Name = "weightLabel";
|
||||
this.weightLabel.Size = new System.Drawing.Size(33, 20);
|
||||
this.weightLabel.TabIndex = 1;
|
||||
this.weightLabel.Text = "Вес";
|
||||
//
|
||||
// speedLabel
|
||||
//
|
||||
this.speedLabel.AutoSize = true;
|
||||
this.speedLabel.Location = new System.Drawing.Point(6, 23);
|
||||
this.speedLabel.Name = "speedLabel";
|
||||
this.speedLabel.Size = new System.Drawing.Size(73, 20);
|
||||
this.speedLabel.TabIndex = 0;
|
||||
this.speedLabel.Text = "Скорость";
|
||||
//
|
||||
// allowPanel
|
||||
//
|
||||
this.allowPanel.AllowDrop = true;
|
||||
this.allowPanel.Controls.Add(this.addColorLabel);
|
||||
this.allowPanel.Controls.Add(this.pictureBox);
|
||||
this.allowPanel.Controls.Add(this.colorLabel);
|
||||
this.allowPanel.Location = new System.Drawing.Point(463, 12);
|
||||
this.allowPanel.Name = "allowPanel";
|
||||
this.allowPanel.Size = new System.Drawing.Size(819, 642);
|
||||
this.allowPanel.TabIndex = 1;
|
||||
this.allowPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragDrop);
|
||||
this.allowPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragEnter);
|
||||
//
|
||||
// addColorLabel
|
||||
//
|
||||
this.addColorLabel.AllowDrop = true;
|
||||
this.addColorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.addColorLabel.Location = new System.Drawing.Point(470, 17);
|
||||
this.addColorLabel.Name = "addColorLabel";
|
||||
this.addColorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
this.addColorLabel.TabIndex = 2;
|
||||
this.addColorLabel.Text = "Доп. цвет";
|
||||
this.addColorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.addColorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragDrop);
|
||||
this.addColorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Location = new System.Drawing.Point(17, 51);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(787, 575);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// colorLabel
|
||||
//
|
||||
this.colorLabel.AllowDrop = true;
|
||||
this.colorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.colorLabel.Location = new System.Drawing.Point(172, 10);
|
||||
this.colorLabel.Name = "colorLabel";
|
||||
this.colorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
this.colorLabel.TabIndex = 1;
|
||||
this.colorLabel.Text = "Цвет";
|
||||
this.colorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.colorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop);
|
||||
this.colorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
this.addButton.Location = new System.Drawing.Point(710, 660);
|
||||
this.addButton.Name = "addButton";
|
||||
this.addButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.addButton.TabIndex = 2;
|
||||
this.addButton.Text = "Добавить";
|
||||
this.addButton.UseVisualStyleBackColor = true;
|
||||
this.addButton.Click += new System.EventHandler(this.addButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Location = new System.Drawing.Point(1042, 660);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.cancelButton.TabIndex = 3;
|
||||
this.cancelButton.Text = "Отменить";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormAirplaneConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1294, 701);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.addButton);
|
||||
this.Controls.Add(this.allowPanel);
|
||||
this.Controls.Add(this.configGroupBox);
|
||||
this.Name = "FormAirplaneConfig";
|
||||
this.Text = "FormMonorailConfig";
|
||||
this.configGroupBox.ResumeLayout(false);
|
||||
this.configGroupBox.PerformLayout();
|
||||
this.colorGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit();
|
||||
this.allowPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox configGroupBox;
|
||||
private CheckBox checkracket;
|
||||
private NumericUpDown numericWeight;
|
||||
private NumericUpDown numericSpeed;
|
||||
private Label weightLabel;
|
||||
private Label speedLabel;
|
||||
private CheckBox checkwing;
|
||||
private GroupBox colorGroupBox;
|
||||
private Panel panel5;
|
||||
private Panel panel4;
|
||||
private Panel panel3;
|
||||
private Panel panel2;
|
||||
private Panel redPanel;
|
||||
private Panel purplePanel;
|
||||
private Panel blackPanel;
|
||||
private Panel greyPanel;
|
||||
private Panel whitePanel;
|
||||
private Label airfighterLabel;
|
||||
private Label airplaneLabel;
|
||||
private Panel yellowPanel;
|
||||
private Panel bluePanel;
|
||||
private Panel greenPanel;
|
||||
private Panel allowPanel;
|
||||
private PictureBox pictureBox;
|
||||
private Label addColorLabel;
|
||||
private Label colorLabel;
|
||||
private Button addButton;
|
||||
private Button cancelButton;
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
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;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public partial class FormAirplaneConfig : Form
|
||||
{
|
||||
DrawningAirplane? _airplane = null;
|
||||
|
||||
private event Action<DrawningAirplane>? EventAddAirplane;
|
||||
public void AddEvent(Action<DrawningAirplane> ev)
|
||||
{
|
||||
if (EventAddAirplane == null)
|
||||
{
|
||||
EventAddAirplane = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddAirplane += ev;
|
||||
}
|
||||
}
|
||||
|
||||
public FormAirplaneConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
greyPanel.MouseDown += PanelColor_MouseDown;
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||
whitePanel.MouseDown += PanelColor_MouseDown;
|
||||
airplaneLabel.MouseDown += LabelObject_MouseDown;
|
||||
airfighterLabel.MouseDown += LabelObject_MouseDown;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
public void DrawAirplane()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_airplane?.SetPosition(5, 70);
|
||||
_airplane?.DrawTransport(gr);
|
||||
pictureBox.Image = bmp;
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "airplaneLabel":
|
||||
_airplane = new DrawningAirplane((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
break;
|
||||
case "airfighterLabel":
|
||||
_airplane = new DrawningAirFighter((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, Color.Silver, checkracket.Checked, checkwing.Checked, pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
break;
|
||||
}
|
||||
colorLabel.BackColor = Color.Empty;
|
||||
addColorLabel.BackColor = Color.Empty;
|
||||
DrawAirplane();
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddAirplane?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
|
||||
private void colorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_airplane == null)
|
||||
return;
|
||||
colorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_airplane.ChangeColor(colorLabel.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
private void colorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_airplane == null) || (_airplane is DrawningAirFighter == false))
|
||||
return;
|
||||
addColorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((DrawningAirFighter)_airplane).ChangeAddColor(addColorLabel.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,28 +0,0 @@
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с перемещаемым объектом
|
||||
/// </summary>
|
||||
public interface IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение координаты X объекта
|
||||
/// </summary>
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
int GetStep { get; }
|
||||
/// <summary>
|
||||
/// Проверка, можно ли переместиться по нужному направлению
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using ProjectAirFighter.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.RightBorder - (FieldWidth - 1);
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX < 0)
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.DownBorder - (FieldHeight - 1);
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY < 0)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
namespace ProjectAirFighter.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 * 125 / 1000 + (_height-_height * 125 / 1000)/2 ;
|
||||
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
|
||||
public int ObjectMiddleVertical => _y +(_height - _height * 125 / 1000) / 2 / 2;
|
||||
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System.Drawing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using System.Drawing;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Formatting.Json;
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.File("log.txt")
|
||||
.MinimumLevel.Debug()
|
||||
.CreateLogger();
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FormAirplaneCollection());
|
||||
}
|
||||
}
|
||||
}
|
106
AirFighter/Properties/Resources.Designer.cs
generated
106
AirFighter/Properties/Resources.Designer.cs
generated
@ -1,106 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AirFighter.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("AirFighter.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap kisspng_up_arrow_computer_icons_arrow_down_clip_art_5af6157c473cb4_0747815015260767962918 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("kisspng-up-arrow-computer-icons-arrow-down-clip-art-5af6157c473cb4.07478150152607" +
|
||||
"67962918", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap png_clipart_computer_icons_graphics_arrow_symbol_arrow_angle_desktop_wallpaper {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("png-clipart-computer-icons-graphics-arrow-symbol-arrow-angle-desktop-wallpaper", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap png_clipart_computer_icons_uma_musume_pretty_derby_fate_grand_order_saber_kemono_friends_three_arrow_game_angle {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-" +
|
||||
"friends-three-arrow-game-angle", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap png_transparent_grammatical_person_paper_narration_direzione_didattica_statale_gestione_scuola_elementare_copy_print_right_arrow_miscellaneous_game_angle {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-ge" +
|
||||
"stione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB |
@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirFighter.Exceptions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectAirFighter.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
|
||||
public int Count => _places.Count;
|
||||
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
|
||||
public bool Insert(T airplane)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
Insert(airplane, 0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public bool Insert(T airplane, int position)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
if (!(position >= 0 && position <= Count))
|
||||
return false;
|
||||
_places.Insert(position, airplane);
|
||||
return true;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
throw new AirplaneNotFoundException(position);
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
return null;
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
|
||||
return;
|
||||
_places.Insert(position, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetAirplanes(int? maxAirplanes = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxAirplanes.HasValue && i == maxAirplanes.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
namespace ProjectAirFighter.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Статус выполнения операции перемещения
|
||||
/// </summary>
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ProjectAirFighter.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) { }
|
||||
}
|
||||
}
|
39
WinFormsApp1/Form1.Designer.cs
generated
Normal file
39
WinFormsApp1/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
10
WinFormsApp1/Form1.cs
Normal file
10
WinFormsApp1/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -117,17 +117,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="png-clipart-computer-icons-graphics-arrow-symbol-arrow-angle-desktop-wallpaper" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\png-clipart-computer-icons-graphics-arrow-symbol-arrow-angle-desktop-wallpaper.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="kisspng-up-arrow-computer-icons-arrow-down-clip-art-5af6157c473cb4.0747815015260767962918" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\kisspng-up-arrow-computer-icons-arrow-down-clip-art-5af6157c473cb4.0747815015260767962918.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
17
WinFormsApp1/Program.cs
Normal file
17
WinFormsApp1/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
11
WinFormsApp1/WinFormsApp1.csproj
Normal file
11
WinFormsApp1/WinFormsApp1.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33530.505
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirFighter", "AirFighter.csproj", "{22602141-1DD8-4CA2-ACE8-935BC23A9C30}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsApp1", "WinFormsApp1.csproj", "{855C52EB-A23F-42BD-875C-C5703182C585}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +11,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{22602141-1DD8-4CA2-ACE8-935BC23A9C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{22602141-1DD8-4CA2-ACE8-935BC23A9C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{22602141-1DD8-4CA2-ACE8-935BC23A9C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{22602141-1DD8-4CA2-ACE8-935BC23A9C30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{855C52EB-A23F-42BD-875C-C5703182C585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{855C52EB-A23F-42BD-875C-C5703182C585}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{855C52EB-A23F-42BD-875C-C5703182C585}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{855C52EB-A23F-42BD-875C-C5703182C585}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2CDBC790-EBFB-4261-A416-9D0938E15A56}
|
||||
SolutionGuid = {599F48E4-DA50-4BFB-9FCF-C72D7D505673}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Loading…
Reference in New Issue
Block a user