Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d2629e9ec | |||
c768bdc104 | |||
e810b85e3b | |||
b4d3dfbd11 | |||
1284f2afaa | |||
05134ead4f | |||
6cfe8083f8 | |||
e396498be1 | |||
3ac1a746a0 | |||
eb8186c60a | |||
915ad90162 | |||
5b82c75d8d | |||
cb9551d76e | |||
253a47e5e7 | |||
64abc50ba4 | |||
669f8b4568 | |||
09aba1c075 | |||
3f2e056315 | |||
3c3737fc84 | |||
b8df03df51 | |||
87be0f7fb2 |
75
AirBomber/AbstractStrategy.cs
Normal file
75
AirBomber/AbstractStrategy.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.DrawningObjects;
|
||||
|
||||
namespace AirBomber.MovementStrategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMoveableObject? _moveableObject;
|
||||
private Status _state = Status.NotInit;
|
||||
protected int FieldWidth { get; private set; }
|
||||
protected int FieldHeight { get; private set; }
|
||||
public Status GetStatus() { return _state; }
|
||||
|
||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
_state = Status.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
protected bool MoveLeft() => MoveTo(Diraction.Left);
|
||||
protected bool MoveRight() => MoveTo(Diraction.Right);
|
||||
protected bool MoveUp() => MoveTo(Diraction.Up);
|
||||
protected bool MoveDown() => MoveTo(Diraction.Down);
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosit;
|
||||
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
|
||||
protected abstract void MoveToTarget();
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
|
||||
private bool MoveTo(Diraction directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
38
AirBomber/AirBomber.csproj
Normal file
38
AirBomber/AirBomber.csproj
Normal file
@ -0,0 +1,38 @@
|
||||
<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.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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>
|
25
AirBomber/AirBomber.sln
Normal file
25
AirBomber/AirBomber.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34031.279
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirBomber", "AirBomber.csproj", "{986B28E7-F9B9-4843-8FD5-B716158A33C1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{986B28E7-F9B9-4843-8FD5-B716158A33C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{986B28E7-F9B9-4843-8FD5-B716158A33C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{986B28E7-F9B9-4843-8FD5-B716158A33C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{986B28E7-F9B9-4843-8FD5-B716158A33C1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5CE3E52F-4CF8-4859-AD95-5AB1B892CFA0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
107
AirBomber/BomberGenericCollection.cs
Normal file
107
AirBomber/BomberGenericCollection.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.DrawningObjects;
|
||||
using AirBomber.MovementStrategy;
|
||||
using ProjectBomber.Generics;
|
||||
|
||||
|
||||
namespace AirBomber.Generics
|
||||
{
|
||||
internal class BomberGenericCollection<T, U>
|
||||
where T : DrawningBomber
|
||||
where U : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetPlane => _collection.GetPlane();
|
||||
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 155;
|
||||
private readonly int _placeSizeHeight = 185;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public BomberGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
|
||||
public static int operator +(BomberGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
|
||||
public static T? operator -(BomberGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
|
||||
public Bitmap ShowBomber()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black, 3);
|
||||
int numColumns = _pictureWidth / _placeSizeWidth;
|
||||
int numRows = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
for (int i = 0; i <= numColumns; i++)
|
||||
{
|
||||
for (int j = 0; j <= numRows; ++j)
|
||||
{
|
||||
int x = i * _placeSizeWidth;
|
||||
int y = j * _placeSizeHeight;
|
||||
g.DrawLine(pen, x, y, x + _placeSizeWidth / 2, y);
|
||||
}
|
||||
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, numRows * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
foreach (var air in _collection.GetPlane())
|
||||
{
|
||||
if (air != null)
|
||||
{
|
||||
// Вычисляем позицию объекта
|
||||
int row = _collection.GetPlane().ToList().IndexOf(air) / (_pictureWidth / _placeSizeWidth);
|
||||
int column = (_pictureWidth / _placeSizeWidth) - 1 - (_collection.GetPlane().ToList().IndexOf(air) % (_pictureWidth / _placeSizeWidth));
|
||||
int x = column * _placeSizeWidth;
|
||||
int y = row * _placeSizeHeight;
|
||||
|
||||
air.SetPosition(x, y);
|
||||
air.DrawBomber(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
170
AirBomber/BomberGenericStorage.cs
Normal file
170
AirBomber/BomberGenericStorage.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.DrawningObjects;
|
||||
using AirBomber.Exceptions;
|
||||
using AirBomber.MovementStrategy;
|
||||
|
||||
namespace AirBomber.Generics
|
||||
{
|
||||
internal class BomberGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>> _bomberStorage;
|
||||
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<string> Keys => _bomberStorage.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly char _separatorRecords = ';';
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public BomberGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_bomberStorage = new Dictionary<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
// TODO Прописать логику для добавления
|
||||
if (!_bomberStorage.ContainsKey(name))
|
||||
{
|
||||
var bomberCollection = new BomberGenericCollection<DrawningBomber, DrawningObjectBomber>(_pictureWidth, _pictureHeight);
|
||||
_bomberStorage.Add(name, bomberCollection);
|
||||
}
|
||||
}
|
||||
|
||||
public void DelSet(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления
|
||||
if (_bomberStorage.ContainsKey(name))
|
||||
{
|
||||
_bomberStorage.Remove(name);
|
||||
}
|
||||
}
|
||||
public BomberGenericCollection<DrawningBomber, DrawningObjectBomber>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения набора
|
||||
if (_bomberStorage.ContainsKey(ind))
|
||||
{
|
||||
return _bomberStorage[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>> record in _bomberStorage)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawningBomber? elem in record.Value.GetPlane)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Невалидная операция, нет данных для сохранения");
|
||||
}
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(filename))
|
||||
{
|
||||
writer.Write($"BomberStorage{Environment.NewLine}{data}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка информации по установкам в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
|
||||
using (StreamReader reader = new StreamReader(filename))
|
||||
{
|
||||
string cheker = reader.ReadLine();
|
||||
if (cheker == null)
|
||||
{
|
||||
throw new Exception("Нет данных для загрузки");
|
||||
}
|
||||
if (!cheker.StartsWith("BomberStorage"))
|
||||
{
|
||||
throw new FormatException("Неверный формат ввода");
|
||||
}
|
||||
_bomberStorage.Clear();
|
||||
string strs;
|
||||
bool firstinit = true;
|
||||
while ((strs = reader.ReadLine()) != null)
|
||||
{
|
||||
if (strs == null && firstinit)
|
||||
{
|
||||
throw new Exception("Нет данных для загрузки");
|
||||
}
|
||||
if (strs == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
firstinit = false;
|
||||
string name = strs.Split(_separatorForKeyValue)[0];
|
||||
BomberGenericCollection<DrawningBomber, DrawningObjectBomber> collection = new(_pictureWidth, _pictureHeight);
|
||||
foreach (string data in strs.Split(_separatorForKeyValue)[1].Split(_separatorRecords))
|
||||
{
|
||||
DrawningBomber? air =
|
||||
data?.CreateDrawningBomber(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (air != null)
|
||||
{
|
||||
try { _ = collection + air; }
|
||||
catch (BomberNotFoundException e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch (StorageOverflowException e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_bomberStorage.Add(name, collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
AirBomber/BomberNotFoundException.cs
Normal file
19
AirBomber/BomberNotFoundException.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
internal class BomberNotFoundException : ApplicationException
|
||||
{
|
||||
public BomberNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public BomberNotFoundException() : base() { }
|
||||
public BomberNotFoundException(string message) : base(message) { }
|
||||
public BomberNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected BomberNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
16
AirBomber/Direction.cs
Normal file
16
AirBomber/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public enum Diraction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
76
AirBomber/DrawningAirBomber.cs
Normal file
76
AirBomber/DrawningAirBomber.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.Entities;
|
||||
|
||||
namespace AirBomber.DrawningObjects
|
||||
{
|
||||
public class DrawningAirBomber : DrawningBomber
|
||||
{
|
||||
public DrawningAirBomber(int speed, int weight, Color bodycolor, Color dopcolor, bool toplivo, bool rocket, int width, int height) : base(speed, weight, bodycolor, width, height, 160, 185)
|
||||
{
|
||||
if (EntityBomber != null)
|
||||
{
|
||||
EntityBomber = new EntityAirBomber(speed, weight, bodycolor, dopcolor, toplivo, rocket);
|
||||
}
|
||||
}
|
||||
public override void DrawBomber(Graphics g)
|
||||
{
|
||||
if (EntityBomber is not EntityAirBomber airBomber)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopcolor = new SolidBrush(airBomber.DopColor);
|
||||
//отрисовка ракет
|
||||
if (airBomber.Rocket)
|
||||
{
|
||||
GraphicsPath rocket_1 = new GraphicsPath();
|
||||
rocket_1.AddLine(_startPosX + 70, _startPosY + 35, _startPosX + 80, _startPosY + 25);
|
||||
rocket_1.AddLine(_startPosX + 80, _startPosY + 25, _startPosX + 80, _startPosY + 45);
|
||||
rocket_1.CloseFigure();
|
||||
g.FillPath(dopcolor, rocket_1);
|
||||
g.DrawPath(Pens.Black, rocket_1);
|
||||
GraphicsPath rocket_2 = new GraphicsPath();
|
||||
rocket_2.AddLine(_startPosX + 70, _startPosY + 65, _startPosX + 80, _startPosY + 55);
|
||||
rocket_2.AddLine(_startPosX + 80, _startPosY + 55, _startPosX + 80, _startPosY + 75);
|
||||
rocket_2.CloseFigure();
|
||||
g.FillPath(dopcolor, rocket_2);
|
||||
g.DrawPath(Pens.Black, rocket_2);
|
||||
GraphicsPath rocket_3 = new GraphicsPath();
|
||||
rocket_3.AddLine(_startPosX + 70, _startPosY + 120, _startPosX + 80, _startPosY + 110);
|
||||
rocket_3.AddLine(_startPosX + 80, _startPosY + 110, _startPosX + 80, _startPosY + 130);
|
||||
rocket_3.CloseFigure();
|
||||
g.FillPath(dopcolor, rocket_3);
|
||||
g.DrawPath(Pens.Black, rocket_3);
|
||||
GraphicsPath rocket_4 = new GraphicsPath();
|
||||
rocket_4.AddLine(_startPosX + 70, _startPosY + 150, _startPosX + 80, _startPosY + 140);
|
||||
rocket_4.AddLine(_startPosX + 80, _startPosY + 140, _startPosX + 80, _startPosY + 160);
|
||||
rocket_4.CloseFigure();
|
||||
g.FillPath(dopcolor, rocket_4);
|
||||
g.DrawPath(Pens.Black, rocket_4);
|
||||
}
|
||||
if (airBomber.Toplivo)
|
||||
{
|
||||
//отрисовка баков
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 5, 8, 10);
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 25, 8, 10);
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 45, 8, 10);
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 130, 8, 10);
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 150, 8, 10);
|
||||
g.FillRectangle(dopcolor, _startPosX + 82, _startPosY + 170, 8, 10);
|
||||
}
|
||||
base.DrawBomber(g);
|
||||
}
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
if (EntityBomber is EntityAirBomber airbomber)
|
||||
{
|
||||
airbomber.setAddColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
170
AirBomber/DrawningBomber.cs
Normal file
170
AirBomber/DrawningBomber.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.Entities;
|
||||
using AirBomber.MovementStrategy;
|
||||
|
||||
namespace AirBomber.DrawningObjects
|
||||
{
|
||||
public class DrawningBomber
|
||||
{
|
||||
public EntityBomber? EntityBomber { get; protected set; }
|
||||
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected int _PlaneWidth = 160;
|
||||
protected int _PlaneHeight = 185;
|
||||
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _PlaneWidth;
|
||||
public int GetHeight => _PlaneHeight;
|
||||
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectBomber(this);
|
||||
|
||||
public DrawningBomber(int speed, double weight, Color bodycolor, int width, int height)
|
||||
{
|
||||
if (width < _pictureWidth || height < _pictureHeight)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid weight or height");
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityBomber = new EntityBomber(speed, weight, bodycolor);
|
||||
}
|
||||
|
||||
protected DrawningBomber(int speed, double weight, Color bodycolor, int width, int height, int planeWidth, int planeHeight)
|
||||
{
|
||||
if (width < _pictureWidth || height < _pictureHeight)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid width or height");
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_PlaneWidth = planeWidth;
|
||||
_PlaneHeight = planeHeight;
|
||||
EntityBomber = new EntityBomber(speed, weight, bodycolor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _PlaneWidth > _pictureWidth)
|
||||
{
|
||||
x = _pictureWidth - _PlaneWidth;
|
||||
}
|
||||
if (y < 0 || y + _PlaneWidth > _pictureHeight)
|
||||
{
|
||||
y = _pictureHeight - _PlaneWidth;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
public bool CanMove(Diraction direction)
|
||||
{
|
||||
if (EntityBomber == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int newPosX = _startPosX;
|
||||
int newPosY = _startPosY;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Diraction.Left:
|
||||
newPosX -= (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Right:
|
||||
newPosX += (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Up:
|
||||
newPosY -= (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Down:
|
||||
newPosY += (int)EntityBomber.Step;
|
||||
break;
|
||||
}
|
||||
|
||||
return newPosX >= 0 && newPosX <= _pictureWidth - _PlaneWidth &&
|
||||
newPosY >= 0 && newPosY <= _pictureHeight - _PlaneHeight;
|
||||
}
|
||||
|
||||
public void MoveTransport(Diraction diraction)
|
||||
{
|
||||
if (!CanMove(diraction) || EntityBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (diraction)
|
||||
{
|
||||
case Diraction.Left:
|
||||
_startPosX -= (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Right:
|
||||
_startPosX += (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Up:
|
||||
_startPosY -= (int)EntityBomber.Step;
|
||||
break;
|
||||
case Diraction.Down:
|
||||
_startPosY += (int)EntityBomber.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawBomber(Graphics g)
|
||||
{
|
||||
if (EntityBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodycolor = new SolidBrush(EntityBomber.BodyColor);
|
||||
//отрисовка крыла 1
|
||||
GraphicsPath fly_1 = new GraphicsPath();
|
||||
fly_1.AddLine(_startPosX + 80, _startPosY + 2, _startPosX + 80, _startPosY + 80);
|
||||
fly_1.AddLine(_startPosX + 80, _startPosY + 2, _startPosX + 90, _startPosY + 2);
|
||||
fly_1.AddLine(_startPosX + 90, _startPosY + 2, _startPosX + 100, _startPosY + 80);
|
||||
fly_1.AddLine(_startPosX + 100, _startPosY + 80, _startPosX + 80, _startPosY + 80);
|
||||
g.DrawPath(Pens.Black, fly_1);
|
||||
//отрисовка кабины пилота
|
||||
GraphicsPath treygol = new GraphicsPath();
|
||||
treygol.AddLine(_startPosX + 3, _startPosY + 95, _startPosX + 30, _startPosY + 80);
|
||||
treygol.AddLine(_startPosX + 30, _startPosY + 80, _startPosX + 30, _startPosY + 105);
|
||||
treygol.CloseFigure();
|
||||
g.FillPath(Brushes.Black, treygol);
|
||||
g.DrawPath(Pens.Black, treygol);
|
||||
//отрисовка корпуса
|
||||
g.FillRectangle(bodycolor, _startPosX + 30, _startPosY + 80, 120, 25);
|
||||
//отрисовка крыла 2
|
||||
GraphicsPath fly_2 = new GraphicsPath();
|
||||
fly_2.AddLine(_startPosX + 80, _startPosY + 105, _startPosX + 80, _startPosY + 185);
|
||||
fly_2.AddLine(_startPosX + 80, _startPosY + 185, _startPosX + 90, _startPosY + 185);
|
||||
fly_2.AddLine(_startPosX + 90, _startPosY + 185, _startPosX + 100, _startPosY + 105);
|
||||
fly_2.CloseFigure();
|
||||
g.DrawPath(Pens.Black, fly_2);
|
||||
//отриосвка хвоста
|
||||
GraphicsPath wing = new GraphicsPath();
|
||||
wing.AddLine(_startPosX + 135, _startPosY + 80, _startPosX + 135, _startPosY + 70);
|
||||
wing.AddLine(_startPosX + 135, _startPosY + 70, _startPosX + 150, _startPosY + 50);
|
||||
wing.AddLine(_startPosX + 150, _startPosY + 50, _startPosX + 150, _startPosY + 80);
|
||||
wing.CloseFigure();
|
||||
g.DrawPath(Pens.Black, wing);
|
||||
GraphicsPath wing_2 = new GraphicsPath();
|
||||
wing_2.AddLine(_startPosX + 135, _startPosY + 105, _startPosX + 135, _startPosY + 115);
|
||||
wing_2.AddLine(_startPosX + 135, _startPosY + 115, _startPosX + 150, _startPosY + 135);
|
||||
wing_2.AddLine(_startPosX + 150, _startPosY + 135, _startPosX + 150, _startPosY + 105);
|
||||
wing_2.CloseFigure();
|
||||
g.DrawPath(Pens.Black, wing_2);
|
||||
}
|
||||
public void setColor(Color color)
|
||||
{
|
||||
EntityBomber.setColor(color);
|
||||
}
|
||||
}
|
||||
}
|
33
AirBomber/DrawningObjectBomber .cs
Normal file
33
AirBomber/DrawningObjectBomber .cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.DrawningObjects;
|
||||
|
||||
namespace AirBomber.MovementStrategy
|
||||
{
|
||||
public class DrawningObjectBomber : IMoveableObject
|
||||
{
|
||||
private readonly DrawningBomber? _drawningBomber = null;
|
||||
|
||||
public DrawningObjectBomber(DrawningBomber drawningBomber)
|
||||
{
|
||||
_drawningBomber = drawningBomber;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosit
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningBomber == null || _drawningBomber.EntityBomber == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningBomber.GetPosX, _drawningBomber.GetPosY, _drawningBomber.GetWidth, _drawningBomber.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningBomber?.EntityBomber?.Step ?? 0);
|
||||
public bool CheckCanMove(Diraction direction) => _drawningBomber?.CanMove(direction) ?? false;
|
||||
public void MoveObject(Diraction direction) => _drawningBomber?.MoveTransport(direction);
|
||||
}
|
||||
}
|
20
AirBomber/EntityAirBomber.cs
Normal file
20
AirBomber/EntityAirBomber.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace AirBomber.Entities
|
||||
{
|
||||
public class EntityAirBomber : EntityBomber
|
||||
{
|
||||
public Color DopColor { get; private set; }
|
||||
public bool Toplivo { get; private set; }
|
||||
public bool Rocket { get; private set; }
|
||||
|
||||
public EntityAirBomber(int speed, double weight, Color bodycolor, Color dopcolor, bool toplivo, bool ropcket) : base(speed, weight, bodycolor)
|
||||
{
|
||||
DopColor = dopcolor;
|
||||
Toplivo = toplivo;
|
||||
Rocket = ropcket;
|
||||
}
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
DopColor = color;
|
||||
}
|
||||
}
|
||||
}
|
27
AirBomber/EntityBomber.cs
Normal file
27
AirBomber/EntityBomber.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber.Entities
|
||||
{
|
||||
public class EntityBomber
|
||||
{
|
||||
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 EntityBomber(int speed, double weight, Color bodycolor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodycolor;
|
||||
}
|
||||
public void setColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
62
AirBomber/ExtentionDrawningBomber.cs
Normal file
62
AirBomber/ExtentionDrawningBomber.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using AirBomber.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber.DrawningObjects
|
||||
{
|
||||
public static class ExtentionDrawningBomber
|
||||
{
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawningBomber? CreateDrawningBomber(this string info, char separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningBomber(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
else if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningAirBomber(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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningBomber">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningBomber drawningBomber,
|
||||
char separatorForAir)
|
||||
{
|
||||
var air = drawningBomber.EntityBomber;
|
||||
if (air == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str =
|
||||
$"{air.Speed}{separatorForAir}{air.Weight}{separatorForAir}{air.BodyColor.Name}";
|
||||
if (air is not EntityAirBomber airBomber)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{separatorForAir}{airBomber.DopColor.Name}{separatorForAir}{airBomber.Toplivo}{separatorForAir}{airBomber.Rocket}";
|
||||
}
|
||||
}
|
||||
}
|
186
AirBomber/FormAirBomber.Designer.cs
generated
Normal file
186
AirBomber/FormAirBomber.Designer.cs
generated
Normal file
@ -0,0 +1,186 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormAirBomber
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBox = new PictureBox();
|
||||
buttonRight = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonCreate = new Button();
|
||||
buttonCreateWarBomber = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
ButtonStep = new Button();
|
||||
ButtonSelectCar = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(800, 450);
|
||||
pictureBox.TabIndex = 0;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.right_arrow;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(713, 373);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 2;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.down;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(677, 401);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 3;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.left;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(641, 373);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 4;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.up_arrow;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(677, 345);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 5;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(223, 385);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(181, 59);
|
||||
buttonCreate.TabIndex = 6;
|
||||
buttonCreate.Text = "Создать самолёт";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonCreateWarBomber
|
||||
//
|
||||
buttonCreateWarBomber.Location = new Point(12, 385);
|
||||
buttonCreateWarBomber.Name = "buttonCreateWarBomber";
|
||||
buttonCreateWarBomber.Size = new Size(205, 59);
|
||||
buttonCreateWarBomber.TabIndex = 7;
|
||||
buttonCreateWarBomber.Text = "Создать военный самолёт";
|
||||
buttonCreateWarBomber.UseVisualStyleBackColor = true;
|
||||
buttonCreateWarBomber.Click += buttonCreateWarBomber_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "В центр", "В правый нижний угол" });
|
||||
comboBoxStrategy.Location = new Point(637, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(151, 28);
|
||||
comboBoxStrategy.TabIndex = 8;
|
||||
//
|
||||
// ButtonStep
|
||||
//
|
||||
ButtonStep.Location = new Point(694, 60);
|
||||
ButtonStep.Name = "ButtonStep";
|
||||
ButtonStep.Size = new Size(94, 29);
|
||||
ButtonStep.TabIndex = 9;
|
||||
ButtonStep.Text = "Шаг";
|
||||
ButtonStep.UseVisualStyleBackColor = true;
|
||||
ButtonStep.Click += ButtonStep_Click;
|
||||
//
|
||||
// ButtonSelectCar
|
||||
//
|
||||
ButtonSelectCar.Location = new Point(420, 391);
|
||||
ButtonSelectCar.Name = "ButtonSelectCar";
|
||||
ButtonSelectCar.Size = new Size(118, 53);
|
||||
ButtonSelectCar.TabIndex = 10;
|
||||
ButtonSelectCar.Text = "Выбрать";
|
||||
ButtonSelectCar.UseVisualStyleBackColor = true;
|
||||
ButtonSelectCar.Click += ButtonSelectCar_Click;
|
||||
//
|
||||
// FormAirBomber
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(ButtonSelectCar);
|
||||
Controls.Add(ButtonStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateWarBomber);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(pictureBox);
|
||||
Name = "FormAirBomber";
|
||||
Text = "Form1";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCreateWarBomber;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button ButtonStep;
|
||||
private Button ButtonSelectCar;
|
||||
}
|
||||
}
|
136
AirBomber/FormAirBomber.cs
Normal file
136
AirBomber/FormAirBomber.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using AirBomber.DrawningObjects;
|
||||
using AirBomber.MovementStrategy;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public partial class FormAirBomber : Form
|
||||
{
|
||||
private DrawningBomber? _drawningBomber;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawningBomber? SelectedBomber { get; private set; }
|
||||
|
||||
public FormAirBomber()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningBomber.DrawBomber(gr);
|
||||
pictureBox.Image = bmp;
|
||||
}
|
||||
|
||||
private void buttonCreate_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 mainColorDialog = new ColorDialog();
|
||||
if (mainColorDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
bodycolor = mainColorDialog.Color;
|
||||
}
|
||||
_drawningBomber = new DrawningBomber(random.Next(100, 300), random.Next(1000, 3000), bodycolor,
|
||||
pictureBox.Width, pictureBox.Height);
|
||||
_drawningBomber.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningBomber.MoveTransport(Diraction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningBomber.MoveTransport(Diraction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningBomber.MoveTransport(Diraction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningBomber.MoveTransport(Diraction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBottomRight(),
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new
|
||||
DrawningObjectBomber(_drawningBomber), pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateWarBomber_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
Color bodycolor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog mainColorDialog = new ColorDialog();
|
||||
if (mainColorDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
bodycolor = mainColorDialog.Color;
|
||||
}
|
||||
|
||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dopColorDialog = new ColorDialog();
|
||||
if (dopColorDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dopColor = dopColorDialog.Color;
|
||||
}
|
||||
|
||||
_drawningBomber = new DrawningAirBomber(random.Next(100, 300),
|
||||
random.Next(1000, 3000), bodycolor, dopColor,
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(1, 2)),
|
||||
pictureBox.Width, pictureBox.Height);
|
||||
_drawningBomber.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonSelectCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedBomber = _drawningBomber;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
120
AirBomber/FormAirBomber.resx
Normal file
120
AirBomber/FormAirBomber.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
261
AirBomber/FormBomberCollection.Designer.cs
generated
Normal file
261
AirBomber/FormBomberCollection.Designer.cs
generated
Normal file
@ -0,0 +1,261 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormBomberCollection
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
Tools = new GroupBox();
|
||||
Kit = new GroupBox();
|
||||
RemoveKit = new Button();
|
||||
AddKit = new Button();
|
||||
KitTextbox = new TextBox();
|
||||
listBoxStorages = new ListBox();
|
||||
ButtonRefreshCollection = new Button();
|
||||
ButtonRemoveBomber = new Button();
|
||||
ButtonAddBomber = new Button();
|
||||
MessageBoxBomber = new TextBox();
|
||||
PicBoxBomberCollection = new PictureBox();
|
||||
menuStrip = new MenuStrip();
|
||||
fileToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
saveFileDialog = new OpenFileDialog();
|
||||
Tools.SuspendLayout();
|
||||
Kit.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// Tools
|
||||
//
|
||||
Tools.Controls.Add(Kit);
|
||||
Tools.Controls.Add(ButtonRefreshCollection);
|
||||
Tools.Controls.Add(ButtonRemoveBomber);
|
||||
Tools.Controls.Add(ButtonAddBomber);
|
||||
Tools.Controls.Add(MessageBoxBomber);
|
||||
Tools.Location = new Point(471, 4);
|
||||
Tools.Margin = new Padding(3, 2, 3, 2);
|
||||
Tools.Name = "Tools";
|
||||
Tools.Padding = new Padding(3, 2, 3, 2);
|
||||
Tools.Size = new Size(219, 417);
|
||||
Tools.TabIndex = 0;
|
||||
Tools.TabStop = false;
|
||||
Tools.Text = "Инструменты";
|
||||
//
|
||||
// Kit
|
||||
//
|
||||
Kit.Controls.Add(RemoveKit);
|
||||
Kit.Controls.Add(AddKit);
|
||||
Kit.Controls.Add(KitTextbox);
|
||||
Kit.Controls.Add(listBoxStorages);
|
||||
Kit.Location = new Point(15, 25);
|
||||
Kit.Margin = new Padding(3, 2, 3, 2);
|
||||
Kit.Name = "Kit";
|
||||
Kit.Padding = new Padding(3, 2, 3, 2);
|
||||
Kit.Size = new Size(199, 212);
|
||||
Kit.TabIndex = 4;
|
||||
Kit.TabStop = false;
|
||||
Kit.Text = "Наборы";
|
||||
//
|
||||
// RemoveKit
|
||||
//
|
||||
RemoveKit.Location = new Point(10, 173);
|
||||
RemoveKit.Margin = new Padding(3, 2, 3, 2);
|
||||
RemoveKit.Name = "RemoveKit";
|
||||
RemoveKit.Size = new Size(169, 27);
|
||||
RemoveKit.TabIndex = 3;
|
||||
RemoveKit.Text = "Удалить набор";
|
||||
RemoveKit.UseVisualStyleBackColor = true;
|
||||
RemoveKit.Click += RemoveKit_Click;
|
||||
//
|
||||
// AddKit
|
||||
//
|
||||
AddKit.Location = new Point(10, 47);
|
||||
AddKit.Margin = new Padding(3, 2, 3, 2);
|
||||
AddKit.Name = "AddKit";
|
||||
AddKit.Size = new Size(169, 27);
|
||||
AddKit.TabIndex = 2;
|
||||
AddKit.Text = "Добавить набор";
|
||||
AddKit.UseVisualStyleBackColor = true;
|
||||
AddKit.Click += AddKit_Click;
|
||||
//
|
||||
// KitTextbox
|
||||
//
|
||||
KitTextbox.Location = new Point(13, 22);
|
||||
KitTextbox.Margin = new Padding(3, 2, 3, 2);
|
||||
KitTextbox.Name = "KitTextbox";
|
||||
KitTextbox.Size = new Size(166, 23);
|
||||
KitTextbox.TabIndex = 1;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 15;
|
||||
listBoxStorages.Location = new Point(10, 82);
|
||||
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(169, 79);
|
||||
listBoxStorages.TabIndex = 0;
|
||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
ButtonRefreshCollection.Location = new Point(24, 336);
|
||||
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
ButtonRefreshCollection.Size = new Size(169, 28);
|
||||
ButtonRefreshCollection.TabIndex = 3;
|
||||
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// ButtonRemoveBomber
|
||||
//
|
||||
ButtonRemoveBomber.Location = new Point(24, 301);
|
||||
ButtonRemoveBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
||||
ButtonRemoveBomber.Size = new Size(169, 31);
|
||||
ButtonRemoveBomber.TabIndex = 2;
|
||||
ButtonRemoveBomber.Text = "Удалить самолёт";
|
||||
ButtonRemoveBomber.UseVisualStyleBackColor = true;
|
||||
ButtonRemoveBomber.Click += ButtonRemoveBomber_Click;
|
||||
//
|
||||
// ButtonAddBomber
|
||||
//
|
||||
ButtonAddBomber.Location = new Point(24, 241);
|
||||
ButtonAddBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
ButtonAddBomber.Name = "ButtonAddBomber";
|
||||
ButtonAddBomber.Size = new Size(169, 31);
|
||||
ButtonAddBomber.TabIndex = 1;
|
||||
ButtonAddBomber.Text = "Добавить самолёт";
|
||||
ButtonAddBomber.UseVisualStyleBackColor = true;
|
||||
ButtonAddBomber.Click += ButtonAddBomber_Click;
|
||||
//
|
||||
// MessageBoxBomber
|
||||
//
|
||||
MessageBoxBomber.Location = new Point(24, 276);
|
||||
MessageBoxBomber.Margin = new Padding(3, 2, 3, 2);
|
||||
MessageBoxBomber.Name = "MessageBoxBomber";
|
||||
MessageBoxBomber.Size = new Size(169, 23);
|
||||
MessageBoxBomber.TabIndex = 0;
|
||||
//
|
||||
// PicBoxBomberCollection
|
||||
//
|
||||
PicBoxBomberCollection.Location = new Point(7, 28);
|
||||
PicBoxBomberCollection.Margin = new Padding(3, 2, 3, 2);
|
||||
PicBoxBomberCollection.Name = "PicBoxBomberCollection";
|
||||
PicBoxBomberCollection.Size = new Size(473, 422);
|
||||
PicBoxBomberCollection.TabIndex = 1;
|
||||
PicBoxBomberCollection.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
menuStrip.Size = new Size(700, 24);
|
||||
menuStrip.TabIndex = 2;
|
||||
menuStrip.Text = "Файл";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new Size(48, 20);
|
||||
fileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.Size = new Size(141, 22);
|
||||
SaveToolStripMenuItem.Text = "Сохранение";
|
||||
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
LoadToolStripMenuItem.Size = new Size(141, 22);
|
||||
LoadToolStripMenuItem.Text = "Загрузка";
|
||||
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.FileName = "saveFileDialog";
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormBomberCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(700, 467);
|
||||
Controls.Add(PicBoxBomberCollection);
|
||||
Controls.Add(Tools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormBomberCollection";
|
||||
Text = "FormBomberCollection";
|
||||
Tools.ResumeLayout(false);
|
||||
Tools.PerformLayout();
|
||||
Kit.ResumeLayout(false);
|
||||
Kit.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox Tools;
|
||||
private TextBox MessageBoxBomber;
|
||||
private PictureBox PicBoxBomberCollection;
|
||||
private Button ButtonRefreshCollection;
|
||||
private Button ButtonRemoveBomber;
|
||||
private Button ButtonAddBomber;
|
||||
private GroupBox Kit;
|
||||
private ListBox listBoxStorages;
|
||||
private Button RemoveKit;
|
||||
private Button AddKit;
|
||||
private TextBox KitTextbox;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem fileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private OpenFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
213
AirBomber/FormBomberCollection.cs
Normal file
213
AirBomber/FormBomberCollection.cs
Normal file
@ -0,0 +1,213 @@
|
||||
using AirBomber.DrawningObjects;
|
||||
using AirBomber.Generics;
|
||||
using AirBomber.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 AirBomber.Exceptions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public partial class FormBomberCollection : Form
|
||||
{
|
||||
private readonly BomberGenericStorage _bomber;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public FormBomberCollection(ILogger<FormBomberCollection> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_bomber = new BomberGenericStorage(PicBoxBomberCollection.Width, PicBoxBomberCollection.Height);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _bomber.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_bomber.Keys[i]);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||
>= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
||||
index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
}
|
||||
private void AddBomber(DrawningBomber bomber)
|
||||
{
|
||||
|
||||
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
_logger.LogWarning("Добавление пустого объекта");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_ = obj + bomber;
|
||||
|
||||
MessageBox.Show("Объект добавлен");
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
_logger.LogInformation($"Добавлен объект в набор {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
}
|
||||
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormBomberConfig form = new FormBomberConfig();
|
||||
form.Show();
|
||||
form.AddEvent(AddBomber);
|
||||
}
|
||||
|
||||
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning("Удаление объекта из несуществующего набора");
|
||||
return;
|
||||
}
|
||||
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(MessageBoxBomber.Text);
|
||||
try
|
||||
{
|
||||
if (obj - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||
_logger.LogInformation($"Удален объект из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
_logger.LogWarning($"Не удалось удалить объект из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
}
|
||||
catch (BomberNotFoundException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning($"{ex.Message} из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddKit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(KitTextbox.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning("Пустое название набора");
|
||||
return;
|
||||
}
|
||||
_bomber.AddSet(KitTextbox.Text);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Добавлен набор: {KitTextbox.Text}");
|
||||
}
|
||||
|
||||
private void RemoveKit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning("Удаление невыбранного набора");
|
||||
return;
|
||||
}
|
||||
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_bomber.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||
?? string.Empty);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Удален набор: {name}");
|
||||
}
|
||||
}
|
||||
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
PicBoxBomberCollection.Image =
|
||||
_bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBomber();
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_bomber.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Сохранение наборов в файл {saveFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_bomber.LoadData(openFileDialog.FileName);
|
||||
ReloadObjects();
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"Загрузились наборы из файла {openFileDialog.FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
132
AirBomber/FormBomberCollection.resx
Normal file
132
AirBomber/FormBomberCollection.resx
Normal file
@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>145, 1</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>315, 1</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>62</value>
|
||||
</metadata>
|
||||
</root>
|
363
AirBomber/FormBomberConfig.Designer.cs
generated
Normal file
363
AirBomber/FormBomberConfig.Designer.cs
generated
Normal file
@ -0,0 +1,363 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormBomberConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
hardLabel = new Label();
|
||||
easyLabel = new Label();
|
||||
colorGroupBox = new GroupBox();
|
||||
purplePanel = new Panel();
|
||||
blackPanel = new Panel();
|
||||
greyPanel = new Panel();
|
||||
whitePanel = new Panel();
|
||||
yellowPanel = new Panel();
|
||||
bluePanel = new Panel();
|
||||
greenPanel = new Panel();
|
||||
redPanel = new Panel();
|
||||
rocketCheckBox = new CheckBox();
|
||||
bakCheckBox = new CheckBox();
|
||||
WeightNumericUpDown = new NumericUpDown();
|
||||
SpeedNumericUpDown = new NumericUpDown();
|
||||
weight = new Label();
|
||||
speed = new Label();
|
||||
PanelColor = new Panel();
|
||||
labelDopColor = new Label();
|
||||
labelColor = new Label();
|
||||
pictureBoxConfig = new PictureBox();
|
||||
AddButton = new Button();
|
||||
buttonStop = new Button();
|
||||
groupBox1.SuspendLayout();
|
||||
colorGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit();
|
||||
PanelColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxConfig).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(hardLabel);
|
||||
groupBox1.Controls.Add(easyLabel);
|
||||
groupBox1.Controls.Add(colorGroupBox);
|
||||
groupBox1.Controls.Add(rocketCheckBox);
|
||||
groupBox1.Controls.Add(bakCheckBox);
|
||||
groupBox1.Controls.Add(WeightNumericUpDown);
|
||||
groupBox1.Controls.Add(SpeedNumericUpDown);
|
||||
groupBox1.Controls.Add(weight);
|
||||
groupBox1.Controls.Add(speed);
|
||||
groupBox1.Location = new Point(12, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(636, 296);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Параметры";
|
||||
//
|
||||
// hardLabel
|
||||
//
|
||||
hardLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
hardLabel.Location = new Point(421, 228);
|
||||
hardLabel.Name = "hardLabel";
|
||||
hardLabel.Size = new Size(127, 47);
|
||||
hardLabel.TabIndex = 8;
|
||||
hardLabel.Text = "Продвинутый";
|
||||
hardLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
hardLabel.MouseDown += LableObject_MouseDown;
|
||||
//
|
||||
// easyLabel
|
||||
//
|
||||
easyLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
easyLabel.Location = new Point(266, 228);
|
||||
easyLabel.Name = "easyLabel";
|
||||
easyLabel.Size = new Size(116, 47);
|
||||
easyLabel.TabIndex = 7;
|
||||
easyLabel.Text = "Простой";
|
||||
easyLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
easyLabel.MouseDown += LableObject_MouseDown;
|
||||
//
|
||||
// colorGroupBox
|
||||
//
|
||||
colorGroupBox.Controls.Add(purplePanel);
|
||||
colorGroupBox.Controls.Add(blackPanel);
|
||||
colorGroupBox.Controls.Add(greyPanel);
|
||||
colorGroupBox.Controls.Add(whitePanel);
|
||||
colorGroupBox.Controls.Add(yellowPanel);
|
||||
colorGroupBox.Controls.Add(bluePanel);
|
||||
colorGroupBox.Controls.Add(greenPanel);
|
||||
colorGroupBox.Controls.Add(redPanel);
|
||||
colorGroupBox.Location = new Point(248, 34);
|
||||
colorGroupBox.Name = "colorGroupBox";
|
||||
colorGroupBox.Size = new Size(315, 176);
|
||||
colorGroupBox.TabIndex = 6;
|
||||
colorGroupBox.TabStop = false;
|
||||
colorGroupBox.Text = "Цвета";
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
purplePanel.BackColor = Color.Purple;
|
||||
purplePanel.Location = new Point(250, 103);
|
||||
purplePanel.Name = "purplePanel";
|
||||
purplePanel.Size = new Size(50, 50);
|
||||
purplePanel.TabIndex = 3;
|
||||
purplePanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
blackPanel.BackColor = Color.Black;
|
||||
blackPanel.Location = new Point(174, 103);
|
||||
blackPanel.Name = "blackPanel";
|
||||
blackPanel.Size = new Size(50, 50);
|
||||
blackPanel.TabIndex = 4;
|
||||
blackPanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// greyPanel
|
||||
//
|
||||
greyPanel.BackColor = Color.Silver;
|
||||
greyPanel.Location = new Point(97, 103);
|
||||
greyPanel.Name = "greyPanel";
|
||||
greyPanel.Size = new Size(50, 50);
|
||||
greyPanel.TabIndex = 5;
|
||||
greyPanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// whitePanel
|
||||
//
|
||||
whitePanel.BackColor = Color.White;
|
||||
whitePanel.Location = new Point(18, 103);
|
||||
whitePanel.Name = "whitePanel";
|
||||
whitePanel.Size = new Size(50, 50);
|
||||
whitePanel.TabIndex = 2;
|
||||
whitePanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
yellowPanel.BackColor = Color.Yellow;
|
||||
yellowPanel.Location = new Point(250, 37);
|
||||
yellowPanel.Name = "yellowPanel";
|
||||
yellowPanel.Size = new Size(50, 50);
|
||||
yellowPanel.TabIndex = 1;
|
||||
yellowPanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
bluePanel.BackColor = Color.Blue;
|
||||
bluePanel.Location = new Point(174, 37);
|
||||
bluePanel.Name = "bluePanel";
|
||||
bluePanel.Size = new Size(50, 50);
|
||||
bluePanel.TabIndex = 1;
|
||||
bluePanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
greenPanel.BackColor = Color.FromArgb(0, 192, 0);
|
||||
greenPanel.Location = new Point(97, 37);
|
||||
greenPanel.Name = "greenPanel";
|
||||
greenPanel.Size = new Size(50, 50);
|
||||
greenPanel.TabIndex = 1;
|
||||
greenPanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
redPanel.BackColor = Color.Red;
|
||||
redPanel.Location = new Point(18, 37);
|
||||
redPanel.Name = "redPanel";
|
||||
redPanel.Size = new Size(50, 50);
|
||||
redPanel.TabIndex = 0;
|
||||
redPanel.MouseClick += PanelColor_MouseDown;
|
||||
//
|
||||
// rocketCheckBox
|
||||
//
|
||||
rocketCheckBox.AutoSize = true;
|
||||
rocketCheckBox.Location = new Point(15, 200);
|
||||
rocketCheckBox.Name = "rocketCheckBox";
|
||||
rocketCheckBox.Size = new Size(196, 24);
|
||||
rocketCheckBox.TabIndex = 5;
|
||||
rocketCheckBox.Text = "Признак наличия ракет";
|
||||
rocketCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// bakCheckBox
|
||||
//
|
||||
bakCheckBox.AutoSize = true;
|
||||
bakCheckBox.Location = new Point(15, 152);
|
||||
bakCheckBox.Name = "bakCheckBox";
|
||||
bakCheckBox.Size = new Size(199, 24);
|
||||
bakCheckBox.TabIndex = 4;
|
||||
bakCheckBox.Text = "Признак наличия баков";
|
||||
bakCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// WeightNumericUpDown
|
||||
//
|
||||
WeightNumericUpDown.Location = new Point(113, 82);
|
||||
WeightNumericUpDown.Name = "WeightNumericUpDown";
|
||||
WeightNumericUpDown.Size = new Size(83, 27);
|
||||
WeightNumericUpDown.TabIndex = 3;
|
||||
WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// SpeedNumericUpDown
|
||||
//
|
||||
SpeedNumericUpDown.Location = new Point(113, 34);
|
||||
SpeedNumericUpDown.Name = "SpeedNumericUpDown";
|
||||
SpeedNumericUpDown.Size = new Size(83, 27);
|
||||
SpeedNumericUpDown.TabIndex = 2;
|
||||
SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// weight
|
||||
//
|
||||
weight.AutoSize = true;
|
||||
weight.Location = new Point(15, 84);
|
||||
weight.Name = "weight";
|
||||
weight.Size = new Size(40, 20);
|
||||
weight.TabIndex = 1;
|
||||
weight.Text = "Вес: ";
|
||||
//
|
||||
// speed
|
||||
//
|
||||
speed.AutoSize = true;
|
||||
speed.Location = new Point(15, 41);
|
||||
speed.Name = "speed";
|
||||
speed.Size = new Size(80, 20);
|
||||
speed.TabIndex = 0;
|
||||
speed.Text = "Скорость: ";
|
||||
//
|
||||
// PanelColor
|
||||
//
|
||||
PanelColor.AllowDrop = true;
|
||||
PanelColor.Controls.Add(labelDopColor);
|
||||
PanelColor.Controls.Add(labelColor);
|
||||
PanelColor.Controls.Add(pictureBoxConfig);
|
||||
PanelColor.Location = new Point(654, 12);
|
||||
PanelColor.Name = "PanelColor";
|
||||
PanelColor.Size = new Size(304, 275);
|
||||
PanelColor.TabIndex = 2;
|
||||
PanelColor.DragDrop += PanelObject_DragDrop;
|
||||
PanelColor.DragEnter += PanelObject_DragEnter;
|
||||
PanelColor.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
labelDopColor.AllowDrop = true;
|
||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDopColor.Location = new Point(152, 12);
|
||||
labelDopColor.Name = "labelDopColor";
|
||||
labelDopColor.Size = new Size(144, 34);
|
||||
labelDopColor.TabIndex = 2;
|
||||
labelDopColor.Text = "Доп. цвет";
|
||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelDopColor.DragDrop += labelAddBoxColor_DragDrop;
|
||||
labelDopColor.DragEnter += LabelColor_DragEnter;
|
||||
labelDopColor.MouseDown += LableObject_MouseDown;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(12, 12);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(134, 34);
|
||||
labelColor.TabIndex = 1;
|
||||
labelColor.Text = "Цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += LabelBaseColor_DragDrop;
|
||||
labelColor.DragEnter += LabelColor_DragEnter;
|
||||
labelColor.MouseDown += LableObject_MouseDown;
|
||||
//
|
||||
// pictureBoxConfig
|
||||
//
|
||||
pictureBoxConfig.Location = new Point(12, 54);
|
||||
pictureBoxConfig.Name = "pictureBoxConfig";
|
||||
pictureBoxConfig.Size = new Size(284, 209);
|
||||
pictureBoxConfig.TabIndex = 0;
|
||||
pictureBoxConfig.TabStop = false;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(661, 293);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(139, 36);
|
||||
AddButton.TabIndex = 3;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// buttonStop
|
||||
//
|
||||
buttonStop.Location = new Point(806, 293);
|
||||
buttonStop.Name = "buttonStop";
|
||||
buttonStop.Size = new Size(131, 36);
|
||||
buttonStop.TabIndex = 4;
|
||||
buttonStop.Text = "Отмена";
|
||||
buttonStop.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormBomberConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(962, 337);
|
||||
Controls.Add(buttonStop);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(PanelColor);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "FormBomberConfig";
|
||||
Text = "FormBomberConfig";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
colorGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit();
|
||||
PanelColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxConfig).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBox1;
|
||||
private Label weight;
|
||||
private Label speed;
|
||||
private GroupBox colorGroupBox;
|
||||
private Panel purplePanel;
|
||||
private Panel blackPanel;
|
||||
private Panel greyPanel;
|
||||
private Panel whitePanel;
|
||||
private Panel yellowPanel;
|
||||
private Panel bluePanel;
|
||||
private Panel greenPanel;
|
||||
private Panel redPanel;
|
||||
private CheckBox rocketCheckBox;
|
||||
private CheckBox bakCheckBox;
|
||||
private NumericUpDown WeightNumericUpDown;
|
||||
private NumericUpDown SpeedNumericUpDown;
|
||||
private Label hardLabel;
|
||||
private Label easyLabel;
|
||||
private Panel PanelColor;
|
||||
private Label labelDopColor;
|
||||
private Label labelColor;
|
||||
private PictureBox pictureBoxConfig;
|
||||
private Button AddButton;
|
||||
private Button buttonStop;
|
||||
}
|
||||
}
|
141
AirBomber/FormBomberConfig.cs
Normal file
141
AirBomber/FormBomberConfig.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using AirBomber.DrawningObjects;
|
||||
using AirBomber.Entities;
|
||||
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 AirBomber
|
||||
{
|
||||
public partial class FormBomberConfig : Form
|
||||
{
|
||||
private event Action<DrawningBomber>? EventAddBomber;
|
||||
DrawningBomber? _bomber = null;
|
||||
|
||||
public FormBomberConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
whitePanel.MouseDown += PanelColor_MouseDown;
|
||||
greyPanel.MouseDown += PanelColor_MouseDown;
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||
buttonStop.Click += (sender, e) => Close();
|
||||
}
|
||||
|
||||
private void DrawBomber()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxConfig.Width, pictureBoxConfig.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bomber?.SetPosition(5, 5);
|
||||
_bomber?.DrawBomber(gr);
|
||||
pictureBoxConfig.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawningBomber> ev)
|
||||
{
|
||||
if (EventAddBomber == null)
|
||||
{
|
||||
EventAddBomber = new Action<DrawningBomber>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBomber += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void LableObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "easyLabel":
|
||||
_bomber = new DrawningBomber((int)SpeedNumericUpDown.Value,
|
||||
(int)WeightNumericUpDown.Value, Color.White, pictureBoxConfig.Width,
|
||||
pictureBoxConfig.Height);
|
||||
break;
|
||||
case "hardLabel":
|
||||
_bomber = new DrawningAirBomber((int)SpeedNumericUpDown.Value,
|
||||
(int)WeightNumericUpDown.Value, Color.Red, Color.Black,
|
||||
bakCheckBox.Checked, rocketCheckBox.Checked, pictureBoxConfig.Width,
|
||||
pictureBoxConfig.Height);
|
||||
break;
|
||||
}
|
||||
DrawBomber();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBomber?.Invoke(_bomber);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_bomber is DrawningBomber entityAirBomber)
|
||||
{
|
||||
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_bomber.setColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawBomber();
|
||||
}
|
||||
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_bomber != null && _bomber.EntityBomber is EntityAirBomber entityAirBomber)
|
||||
{
|
||||
labelDopColor.AllowDrop = true;
|
||||
}
|
||||
else
|
||||
labelDopColor.AllowDrop = false;
|
||||
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelAddBoxColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_bomber is DrawningAirBomber entityAirBomber)
|
||||
{
|
||||
labelDopColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
entityAirBomber.setAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawBomber();
|
||||
}
|
||||
}
|
||||
}
|
120
AirBomber/FormBomberConfig.resx
Normal file
120
AirBomber/FormBomberConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
18
AirBomber/IMoveableObject.cs
Normal file
18
AirBomber/IMoveableObject.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.DrawningObjects;
|
||||
|
||||
namespace AirBomber.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosit { get; }
|
||||
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(Diraction direction);
|
||||
void MoveObject(Diraction direction);
|
||||
}
|
||||
}
|
48
AirBomber/MoveToBottomRight .cs
Normal file
48
AirBomber/MoveToBottomRight .cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.MovementStrategy;
|
||||
|
||||
namespace AirBomber.MovementStrategy
|
||||
{
|
||||
public class MoveToBottomRight : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.RightBorder - FieldWidth;
|
||||
var diffY = objParams.DownBorder - FieldHeight;
|
||||
if (diffX >= 0)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
else if (diffY >= 0)
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
else if (Math.Abs(diffX) > Math.Abs(diffY))
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
55
AirBomber/MoveToCenter.cs
Normal file
55
AirBomber/MoveToCenter.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBomber.MovementStrategy;
|
||||
|
||||
namespace AirBomber.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
AirBomber/ObjectParameters.cs
Normal file
29
AirBomber/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber.MovementStrategy
|
||||
{
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
public int LeftBorder => _x;
|
||||
public int TopBorder => _y;
|
||||
public int RightBorder => _x + _width;
|
||||
public int DownBorder => _y + _height;
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
45
AirBomber/Program.cs
Normal file
45
AirBomber/Program.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormBomberCollection>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormBomberCollection>().AddLogging(option =>
|
||||
{
|
||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||
string pathNeed = "";
|
||||
for (int i = 0; i < path.Length - 3; i++)
|
||||
{
|
||||
pathNeed += path[i] + "\\";
|
||||
}
|
||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}appsettings.json", optional: false, reloadOnChange: true).Build(); var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
103
AirBomber/Properties/Resources.Designer.cs
generated
Normal file
103
AirBomber/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AirBomber.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("AirBomber.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 down {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("down", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap left {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("left", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap right_arrow {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("right-arrow", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap up_arrow {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("up-arrow", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
AirBomber/Properties/Resources.resx
Normal file
133
AirBomber/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="right-arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\right-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="up-arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\up-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
AirBomber/Resources/down.png
Normal file
BIN
AirBomber/Resources/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
AirBomber/Resources/left.png
Normal file
BIN
AirBomber/Resources/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
AirBomber/Resources/right-arrow.png
Normal file
BIN
AirBomber/Resources/right-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
AirBomber/Resources/up-arrow.png
Normal file
BIN
AirBomber/Resources/up-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
114
AirBomber/SetGeneric.cs
Normal file
114
AirBomber/SetGeneric.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using AirBomber.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBomber.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T?> _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Count;
|
||||
/// <summary>
|
||||
/// Максимальное количество объектов в списке
|
||||
/// </summary>
|
||||
private readonly int _maxCount;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="plane">Добавляемая установка</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T plane)
|
||||
{
|
||||
return Insert(plane, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="plane">Добавляемая установка</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T plane, int position)
|
||||
{
|
||||
if (position < 0 || position >= _maxCount)
|
||||
throw new BomberNotFoundException(position);
|
||||
|
||||
if (Count >= _maxCount)
|
||||
throw new StorageOverflowException(position);
|
||||
_places.Insert(0, plane);
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
{
|
||||
/// Проверка позиции
|
||||
if (position < 0 || position > _maxCount || position >= Count)
|
||||
throw new BomberNotFoundException(position);
|
||||
/// Удаление объекта из массива, присвоив элементу массива значение null
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position > _maxCount)
|
||||
return null;
|
||||
if (_places.Count <= position)
|
||||
return null;
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < 0 || position > _maxCount)
|
||||
return;
|
||||
if (_places.Count <= position)
|
||||
return;
|
||||
_places[position] = value;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetPlane(int? maxPlane = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxPlane.HasValue && i == maxPlane.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
AirBomber/Status.cs
Normal file
15
AirBomber/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
19
AirBomber/StorageOverflowException.cs
Normal file
19
AirBomber/StorageOverflowException.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber.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 contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
20
AirBomber/appsettings.json
Normal file
20
AirBomber/appsettings.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "GasolineTanker"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user