Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
36aa97471e | |||
b0ae098ee0 | |||
e4a261f7fd | |||
6aa194ce4a | |||
d9b0e7a3ce | |||
4942c6bf61 | |||
e1b456f4a8 | |||
a0aee749e1 | |||
9a8d51e3aa | |||
07fe09f7e1 | |||
6f9ccc81d4 | |||
b190f9518e | |||
97b7cd4d5e | |||
3e35ae07d0 |
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.3.32922.545
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirBomber", "AirBomber\AirBomber.csproj", "{13C86177-66C5-4E7C-8BA5-51812F94BB51}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{13C86177-66C5-4E7C-8BA5-51812F94BB51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{13C86177-66C5-4E7C-8BA5-51812F94BB51}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{13C86177-66C5-4E7C-8BA5-51812F94BB51}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{13C86177-66C5-4E7C-8BA5-51812F94BB51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4224EFAB-87D9-4A57-A6D5-B3E4EEEE5D0C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
152
AirBomber/AirBomber/AbstractMap.cs
Normal file
152
AirBomber/AirBomber/AbstractMap.cs
Normal file
@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
{
|
||||
private IDrawningObject _drawningObject = null;
|
||||
protected int[,] _map = null;
|
||||
protected int _width;
|
||||
protected int _height;
|
||||
protected float _size_x;
|
||||
protected float _size_y;
|
||||
protected readonly Random _random = new();
|
||||
protected readonly int _freeRoad = 0;
|
||||
protected readonly int _barrier = 1;
|
||||
public Bitmap CreateMap(int width, int height, IDrawningObject
|
||||
drawningObject)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_drawningObject = drawningObject;
|
||||
GenerateMap();
|
||||
while (!SetObjectOnMap())
|
||||
{
|
||||
GenerateMap();
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
public bool CheckAround(float Left, float Right, float Top, float Bottom)
|
||||
{
|
||||
int startX = (int)(Left / _size_x);
|
||||
int startY = (int)(Right / _size_y);
|
||||
int endX = (int)(Top / _size_x);
|
||||
if (endX > 100)
|
||||
{
|
||||
endX = 100;
|
||||
}
|
||||
int endY = (int)(Bottom / _size_y);
|
||||
if (endY > 100)
|
||||
{
|
||||
endY = 100;
|
||||
}
|
||||
for (int i = startX; i <= endX; i++)
|
||||
{
|
||||
for (int j = startY; j <= endY; j++)
|
||||
{
|
||||
if (_map[i, j] == _barrier)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
// TODO проверка, что объект может переместится в требуемом направлении
|
||||
_drawningObject.MoveObject(direction);
|
||||
(float Left, float Right, float Top, float Bottom) = _drawningObject.GetCurrentPosition();
|
||||
|
||||
if (CheckAround(Left, Right, Top, Bottom))
|
||||
{
|
||||
_drawningObject.MoveObject(MoveObjectBack(direction));
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
private Direction MoveObjectBack(Direction direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Up:
|
||||
return Direction.Down;
|
||||
case Direction.Down:
|
||||
return Direction.Up;
|
||||
case Direction.Left:
|
||||
return Direction.Right;
|
||||
case Direction.Right:
|
||||
return Direction.Left;
|
||||
}
|
||||
return Direction.None;
|
||||
}
|
||||
private bool SetObjectOnMap()
|
||||
{
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int x = _random.Next(0, 10);
|
||||
int y = _random.Next(0, 10);
|
||||
_drawningObject.SetObject(x, y, _width, _height);
|
||||
// TODO првоерка, что объект не "накладывается" на закрытые участки
|
||||
(float Left, float Right, float Top, float Bottom) = _drawningObject.GetCurrentPosition();
|
||||
if (!CheckAround(Left, Right, Top, Bottom)) return true;
|
||||
float startX = Left;
|
||||
float startY = Right;
|
||||
float lengthX = Top - Left;
|
||||
float lengthY = Bottom - Right;
|
||||
while (CheckAround(startX, startY, startX + lengthX, startY + lengthY))
|
||||
{
|
||||
bool result;
|
||||
do
|
||||
{
|
||||
result = CheckAround(startX, startY, startX + lengthX, startY + lengthY);
|
||||
if (!result)
|
||||
{
|
||||
_drawningObject.SetObject((int)startX, (int)startY, _width, _height);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startX += _size_x;
|
||||
}
|
||||
} while (result);
|
||||
startX = x;
|
||||
startY += _size_y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private Bitmap DrawMapWithObject()
|
||||
{
|
||||
Bitmap bmp = new(_width, _height);
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return bmp;
|
||||
}
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
if (_map[i, j] == _freeRoad)
|
||||
{
|
||||
DrawRoadPart(gr, i, j);
|
||||
}
|
||||
else if (_map[i, j] == _barrier)
|
||||
{
|
||||
DrawBarrierPart(gr, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
_drawningObject.DrawningObject(gr);
|
||||
return bmp;
|
||||
}
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
}
|
||||
}
|
56
AirBomber/AirBomber/AirBomber.csproj
Normal file
56
AirBomber/AirBomber/AirBomber.csproj
Normal file
@ -0,0 +1,56 @@
|
||||
<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>
|
||||
<None Remove="nlog.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Configuration.ConfigurationBuilders.Environment" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="TestBase" Version="4.1.4.4" />
|
||||
</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>
|
17
AirBomber/AirBomber/Direction.cs
Normal file
17
AirBomber/AirBomber/Direction.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
219
AirBomber/AirBomber/DrawningJet.cs
Normal file
219
AirBomber/AirBomber/DrawningJet.cs
Normal file
@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityJet Jet { get; set; }
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки самолета
|
||||
/// </summary>
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки самолета
|
||||
/// </summary>
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureWidth = null;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureHeight = null;
|
||||
/// <summary>
|
||||
/// Ширина отрисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _jetWidth = 147;
|
||||
/// <summary>
|
||||
/// Высота отрисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _jetHeight = 115;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес самолета</param>
|
||||
/// <param name="bodyColor">Цвет самолета</param>
|
||||
public DrawningJet(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Jet = new EntityJet(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
protected DrawningJet(int speed, float weight, Color bodyColor, int jetWidth, int jetHeight) :
|
||||
this(speed, weight, bodyColor)
|
||||
{
|
||||
_jetWidth = jetWidth;
|
||||
_jetHeight = jetHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции самолета
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
|
||||
public virtual void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x < 0 || y < 0 || width < x + _jetWidth || height < y + _jetHeight)
|
||||
{
|
||||
_pictureHeight = null;
|
||||
_pictureWidth = null;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
///
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
// вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + _jetWidth + Jet.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += Jet.Step;
|
||||
}
|
||||
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX - Jet.Step > 0)
|
||||
{
|
||||
_startPosX -= Jet.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - Jet.Step > 0)
|
||||
{
|
||||
_startPosY -= Jet.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY + _jetHeight + Jet.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += Jet.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка самолета
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
Brush br = new SolidBrush(Jet?.BodyColor ?? Color.Black);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 50, 130, 20);
|
||||
|
||||
PointF point1 = new PointF(_startPosX + 20, _startPosY + 50);
|
||||
PointF point2 = new PointF(_startPosX + 0, _startPosY + 60);
|
||||
PointF point3 = new PointF(_startPosX + 20, _startPosY + 70);
|
||||
PointF[] nose = { point1, point2, point3 };
|
||||
g.DrawPolygon(pen, nose);
|
||||
g.FillPolygon(brBlack, nose);
|
||||
|
||||
PointF point4 = new PointF(_startPosX + 90, _startPosY + 50);
|
||||
PointF point5 = new PointF(_startPosX + 90, _startPosY + 0);
|
||||
PointF point6 = new PointF(_startPosX + 100, _startPosY + 0);
|
||||
PointF point7 = new PointF(_startPosX + 110, _startPosY + 50);
|
||||
PointF[] rwing = { point4, point5, point6, point7 };
|
||||
g.DrawPolygon(pen, rwing);
|
||||
|
||||
PointF point8 = new PointF(_startPosX + 90, _startPosY + 70);
|
||||
PointF point9 = new PointF(_startPosX + 90, _startPosY + 120);
|
||||
PointF point10 = new PointF(_startPosX + 100, _startPosY + 120);
|
||||
PointF point11 = new PointF(_startPosX + 110, _startPosY + 70);
|
||||
PointF[] lwing = { point8, point9, point10, point11 };
|
||||
g.DrawPolygon(pen, lwing);
|
||||
|
||||
PointF point12 = new PointF(_startPosX + 130, _startPosY + 50);
|
||||
PointF point13 = new PointF(_startPosX + 130, _startPosY + 40);
|
||||
PointF point14 = new PointF(_startPosX + 150, _startPosY + 25);
|
||||
PointF point15 = new PointF(_startPosX + 150, _startPosY + 50);
|
||||
PointF[] rback = { point12, point13, point14, point15 };
|
||||
g.DrawPolygon(pen, rback);
|
||||
|
||||
|
||||
PointF point16 = new PointF(_startPosX + 130, _startPosY + 70);
|
||||
PointF point17 = new PointF(_startPosX + 130, _startPosY + 80);
|
||||
PointF point18 = new PointF(_startPosX + 150, _startPosY + 95);
|
||||
PointF point19 = new PointF(_startPosX + 150, _startPosY + 70);
|
||||
PointF[] lback = { point16, point17, point18, point19 };
|
||||
g.DrawPolygon(pen, lback);
|
||||
|
||||
g.FillPolygon(br, lwing);
|
||||
g.FillPolygon(br, rwing);
|
||||
g.FillPolygon(br, rback);
|
||||
g.FillPolygon(br, lback);
|
||||
g.FillRectangle(br, _startPosX + 20, _startPosY + 50, 130, 20);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена границ формы отрисовки
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureWidth <= _jetWidth || _pictureHeight <= _jetHeight)
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
return;
|
||||
}
|
||||
if (_startPosX + _jetWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _jetWidth;
|
||||
}
|
||||
if (_startPosY + _jetHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _jetHeight;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции
|
||||
/// </summary>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _jetWidth, _startPosY + _jetHeight);
|
||||
}
|
||||
}
|
||||
}
|
37
AirBomber/AirBomber/DrawningObjectJet.cs
Normal file
37
AirBomber/AirBomber/DrawningObjectJet.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class DrawningObjectJet : IDrawningObject
|
||||
{
|
||||
private DrawningJet _jet = null;
|
||||
public DrawningObjectJet(DrawningJet jet)
|
||||
{
|
||||
_jet = jet;
|
||||
}
|
||||
public float Step => _jet?.Jet?.Step ?? 0;
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _jet?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_jet?.MoveTransport(direction);
|
||||
}
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_jet.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
void IDrawningObject.DrawningObject(Graphics g)
|
||||
{
|
||||
_jet.DrawTransport(g);
|
||||
}
|
||||
public string GetInfo() => _jet?.GetDataForSave();
|
||||
public static IDrawningObject Create(string data) => new DrawningObjectJet(data.CreateDrawningJet());
|
||||
}
|
||||
}
|
81
AirBomber/AirBomber/DrawningSportJet.cs
Normal file
81
AirBomber/AirBomber/DrawningSportJet.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
|
||||
internal class DrawningSportJet : DrawningJet
|
||||
{
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine"></param>
|
||||
public DrawningSportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing) :
|
||||
base(speed, weight, bodyColor, 110, 60)
|
||||
{
|
||||
Jet = new EntitySportJet(speed, weight, bodyColor, dopColor, bodyKit, wing);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (Jet is not EntitySportJet sportJet)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(sportJet.DopColor);
|
||||
int x = Convert.ToInt32(_startPosX);
|
||||
int y = Convert.ToInt32(_startPosY);
|
||||
|
||||
if (sportJet.Wing)
|
||||
{
|
||||
GraphicsPath path1 = new GraphicsPath();
|
||||
Point pt1 = new Point(x + 100, y + 10);
|
||||
Point pt2 = new Point(x + 100, y + 40);
|
||||
Rectangle rect1 = new Rectangle(x + 80, y + 10, 30, 30);
|
||||
|
||||
path1.AddLine(pt1, pt2);
|
||||
path1.AddArc(rect1, 90, 180);
|
||||
g.DrawPath(pen, path1);
|
||||
g.FillPath(dopBrush, path1);
|
||||
|
||||
GraphicsPath path2 = new GraphicsPath();
|
||||
Point pt3 = new Point(x + 100, y + 80);
|
||||
Point pt4 = new Point(x + 100, y + 110);
|
||||
Rectangle rect2 = new Rectangle(x + 80, y + 80, 30, 30);
|
||||
|
||||
path2.AddLine(pt3, pt4);
|
||||
path2.AddArc(rect2, 90, 180);
|
||||
g.DrawPath(pen, path2);
|
||||
g.FillPath(dopBrush, path2);
|
||||
}
|
||||
if (sportJet.SportLine) { }
|
||||
|
||||
_startPosX += 10;
|
||||
_startPosY += 5;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 10;
|
||||
_startPosY -= 5;
|
||||
|
||||
if (sportJet.BodyKit)
|
||||
{
|
||||
Rectangle rect = new Rectangle(x + 146, y + 45, 10, 40);
|
||||
g.DrawRectangle(pen, rect);
|
||||
g.FillRectangle(dopBrush, rect);
|
||||
Point pt5 = new Point(x + 30, y + 65);
|
||||
Point pt6 = new Point(x + 145, y + 65);
|
||||
g.DrawLine(pen, pt5, pt6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
AirBomber/AirBomber/EntityJet.cs
Normal file
47
AirBomber/AirBomber/EntityJet.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public class EntityJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public float Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения самолета
|
||||
/// </summary>
|
||||
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса самолета
|
||||
/// </summary>
|
||||
/// <param name="speed"></param>
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
|
||||
public EntityJet(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
AirBomber/AirBomber/EntitySportJet.cs
Normal file
44
AirBomber/AirBomber/EntitySportJet.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class EntitySportJet : EntityJet
|
||||
{
|
||||
///<summary>
|
||||
///Класс-сущность "Спортивный автомобиль"
|
||||
///</summary>
|
||||
public Color DopColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак наличия обвеса
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия антикрыла
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия гоночной полосы
|
||||
/// </summary>
|
||||
public bool SportLine { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия топливных баков</param>
|
||||
/// <param name="wing">Признак наличия бомб</param>
|
||||
public EntitySportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
}
|
||||
}
|
||||
}
|
56
AirBomber/AirBomber/ExtentionJet.cs
Normal file
56
AirBomber/AirBomber/ExtentionJet.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
/// <summary>
|
||||
/// Расширение для класса DrawningJet
|
||||
/// </summary>
|
||||
internal static class ExtentionJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public static DrawningJet CreateDrawningJet(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawningJet(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
|
||||
}
|
||||
if (strs.Length == 7)
|
||||
{
|
||||
return new DrawningSportJet(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]),
|
||||
Color.FromName(strs[3]), Convert.ToBoolean(strs[4]),
|
||||
Convert.ToBoolean(strs[5]));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningJet"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDataForSave(this DrawningJet drawningJet)
|
||||
{
|
||||
var jet = drawningJet.Jet;
|
||||
var str = $"{jet.Speed}{_separatorForObject}{jet.Weight}{_separatorForObject}{jet.BodyColor.Name}";
|
||||
if (jet is not EntitySportJet sportCar)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{_separatorForObject}{sportCar.DopColor.Name}{_separatorForObject}{sportCar.BodyKit}{_separatorForObject}{sportCar.Wing}";
|
||||
}
|
||||
}
|
||||
}
|
373
AirBomber/AirBomber/FormJetConfig.Designer.cs
generated
Normal file
373
AirBomber/AirBomber/FormJetConfig.Designer.cs
generated
Normal file
@ -0,0 +1,373 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormJetConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelWhite = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelRed = new System.Windows.Forms.Panel();
|
||||
this.checkBoxWing = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.LabelDopColor = new System.Windows.Forms.Label();
|
||||
this.LabelBaseColor = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBox1.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBox1.Controls.Add(this.groupBox2);
|
||||
this.groupBox1.Controls.Add(this.checkBoxWing);
|
||||
this.groupBox1.Controls.Add(this.checkBoxBodyKit);
|
||||
this.groupBox1.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(454, 197);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "groupBox1";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(353, 156);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(88, 27);
|
||||
this.labelModifiedObject.TabIndex = 9;
|
||||
this.labelModifiedObject.Text = "Продвинутый";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(244, 156);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(92, 27);
|
||||
this.labelSimpleObject.TabIndex = 8;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.panelPurple);
|
||||
this.groupBox2.Controls.Add(this.panelBlack);
|
||||
this.groupBox2.Controls.Add(this.panelGray);
|
||||
this.groupBox2.Controls.Add(this.panelWhite);
|
||||
this.groupBox2.Controls.Add(this.panelYellow);
|
||||
this.groupBox2.Controls.Add(this.panelBlue);
|
||||
this.groupBox2.Controls.Add(this.panelGreen);
|
||||
this.groupBox2.Controls.Add(this.panelRed);
|
||||
this.groupBox2.Location = new System.Drawing.Point(244, 22);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(197, 115);
|
||||
this.groupBox2.TabIndex = 7;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
this.panelPurple.Location = new System.Drawing.Point(144, 66);
|
||||
this.panelPurple.Name = "panelPurple";
|
||||
this.panelPurple.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelPurple.TabIndex = 7;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(98, 66);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelBlack.TabIndex = 6;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.Silver;
|
||||
this.panelGray.Location = new System.Drawing.Point(52, 66);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelGray.TabIndex = 5;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(6, 66);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelWhite.TabIndex = 4;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(144, 20);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelYellow.TabIndex = 3;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(98, 20);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelBlue.TabIndex = 2;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(52, 20);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(6, 20);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(40, 40);
|
||||
this.panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxWing
|
||||
//
|
||||
this.checkBoxWing.AutoSize = true;
|
||||
this.checkBoxWing.Location = new System.Drawing.Point(12, 125);
|
||||
this.checkBoxWing.Name = "checkBoxWing";
|
||||
this.checkBoxWing.Size = new System.Drawing.Size(156, 19);
|
||||
this.checkBoxWing.TabIndex = 5;
|
||||
this.checkBoxWing.Text = "Признак наличия бомб";
|
||||
this.checkBoxWing.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBodyKit
|
||||
//
|
||||
this.checkBoxBodyKit.AutoSize = true;
|
||||
this.checkBoxBodyKit.Location = new System.Drawing.Point(12, 97);
|
||||
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
|
||||
this.checkBoxBodyKit.Size = new System.Drawing.Size(222, 19);
|
||||
this.checkBoxBodyKit.TabIndex = 4;
|
||||
this.checkBoxBodyKit.Text = "Признак наличия топливных баков";
|
||||
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(81, 59);
|
||||
this.numericUpDownWeight.Maximum = new decimal(new int[] {
|
||||
2000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Minimum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(74, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(81, 30);
|
||||
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(74, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 2;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(49, 61);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(26, 15);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Вес";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(16, 32);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(59, 15);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Скорость";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.AllowDrop = true;
|
||||
this.panel1.Controls.Add(this.LabelDopColor);
|
||||
this.panel1.Controls.Add(this.LabelBaseColor);
|
||||
this.panel1.Controls.Add(this.pictureBoxObject);
|
||||
this.panel1.Location = new System.Drawing.Point(472, 12);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(296, 242);
|
||||
this.panel1.TabIndex = 2;
|
||||
//
|
||||
// LabelDopColor
|
||||
//
|
||||
this.LabelDopColor.AllowDrop = true;
|
||||
this.LabelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.LabelDopColor.Location = new System.Drawing.Point(168, 15);
|
||||
this.LabelDopColor.Name = "LabelDopColor";
|
||||
this.LabelDopColor.Size = new System.Drawing.Size(100, 23);
|
||||
this.LabelDopColor.TabIndex = 2;
|
||||
this.LabelDopColor.Text = "Доп. цвет";
|
||||
this.LabelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// LabelBaseColor
|
||||
//
|
||||
this.LabelBaseColor.AllowDrop = true;
|
||||
this.LabelBaseColor.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.LabelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.LabelBaseColor.Location = new System.Drawing.Point(24, 15);
|
||||
this.LabelBaseColor.Name = "LabelBaseColor";
|
||||
this.LabelBaseColor.Size = new System.Drawing.Size(100, 23);
|
||||
this.LabelBaseColor.TabIndex = 1;
|
||||
this.LabelBaseColor.Text = "Цвет";
|
||||
this.LabelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(3, 47);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(290, 192);
|
||||
this.pictureBoxObject.TabIndex = 0;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
this.buttonOk.Location = new System.Drawing.Point(256, 231);
|
||||
this.buttonOk.Name = "buttonOk";
|
||||
this.buttonOk.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOk.TabIndex = 3;
|
||||
this.buttonOk.Text = "Добавить";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(365, 231);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormJetConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 269);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "FormJetConfig";
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBox1;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private GroupBox groupBox2;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private CheckBox checkBoxWing;
|
||||
private CheckBox checkBoxBodyKit;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private Panel panel1;
|
||||
private Label LabelDopColor;
|
||||
private Label LabelBaseColor;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
189
AirBomber/AirBomber/FormJetConfig.cs
Normal file
189
AirBomber/AirBomber/FormJetConfig.cs
Normal file
@ -0,0 +1,189 @@
|
||||
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 FormJetConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-самолета
|
||||
/// </summary>
|
||||
/// <param name="jet"></param>
|
||||
public delegate void JetDelegate(DrawningJet jet);
|
||||
|
||||
// Создаем событие и оно должно быть публичным, чтобы его можно было использовать в разных классах
|
||||
// например в главной форме, которая вызывает форму добавления самолета
|
||||
public event JetDelegate EventAddJet;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Переменная - выбранный самолет
|
||||
/// </summary>
|
||||
private DrawningJet _jet = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormJetConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
// Используем лямбда функцию для закрытия окна при нажатии на кнопку Отмена
|
||||
// при этом используем встроенные делегат EventHandler
|
||||
buttonCancel.Click += (object sender, EventArgs e) => this.Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление самолета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Генерируем событие
|
||||
EventAddJet?.Invoke(_jet);
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка самолета
|
||||
/// </summary>
|
||||
private void DrawJet()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_jet?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_jet?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_jet = new DrawningJet((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_jet = new DrawningSportJet((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||
checkBoxBodyKit.Checked, checkBoxWing.Checked);
|
||||
break;
|
||||
}
|
||||
DrawJet();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отправляем цвет с панели
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _jet != null)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _jet?.ToString() == "JetsProject.DrawningSportJet")
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Принимаем основной цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = e.Data.GetData(typeof(Color));
|
||||
if (color != null && _jet != null)
|
||||
{
|
||||
_jet.Jet.BodyColor = (Color)color;
|
||||
DrawJet();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_jet != null && _jet.Jet is EntitySportJet entityJet)
|
||||
{
|
||||
entityJet.DopColor = (Color)e.Data.GetData(typeof(Color));
|
||||
DrawJet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
AirBomber/AirBomber/FormJetConfig.resx
Normal file
60
AirBomber/AirBomber/FormJetConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
401
AirBomber/AirBomber/FormMapWithSetJets.Designer.cs
generated
Normal file
401
AirBomber/AirBomber/FormMapWithSetJets.Designer.cs
generated
Normal file
@ -0,0 +1,401 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormMapWithSetJets
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonDown1 = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.ButtonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight1 = new System.Windows.Forms.Button();
|
||||
this.buttonLeft1 = new System.Windows.Forms.Button();
|
||||
this.buttonUp1 = new System.Windows.Forms.Button();
|
||||
this.ButtonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.ButtonShowStorage = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.TextBox();
|
||||
this.ButtonAddJet = new System.Windows.Forms.Button();
|
||||
this.ButtonRemoveJet = new System.Windows.Forms.Button();
|
||||
this.pictureBoxJet = new System.Windows.Forms.PictureBox();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonDown1
|
||||
//
|
||||
this.buttonDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown1.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown;
|
||||
this.buttonDown1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown1.Location = new System.Drawing.Point(68, 884);
|
||||
this.buttonDown1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDown1.Name = "buttonDown1";
|
||||
this.buttonDown1.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonDown1.TabIndex = 7;
|
||||
this.buttonDown1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.Controls.Add(this.groupBox2);
|
||||
this.groupBox1.Controls.Add(this.buttonRight);
|
||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||
this.groupBox1.Controls.Add(this.buttonUp);
|
||||
this.groupBox1.Controls.Add(this.buttonDown);
|
||||
this.groupBox1.Controls.Add(this.buttonRight1);
|
||||
this.groupBox1.Controls.Add(this.buttonLeft1);
|
||||
this.groupBox1.Controls.Add(this.buttonUp1);
|
||||
this.groupBox1.Controls.Add(this.buttonDown1);
|
||||
this.groupBox1.Controls.Add(this.ButtonShowOnMap);
|
||||
this.groupBox1.Controls.Add(this.ButtonShowStorage);
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox1.Controls.Add(this.ButtonAddJet);
|
||||
this.groupBox1.Controls.Add(this.ButtonRemoveJet);
|
||||
this.groupBox1.Location = new System.Drawing.Point(893, 27);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(191, 546);
|
||||
this.groupBox1.TabIndex = 7;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.buttonAddMap);
|
||||
this.groupBox2.Controls.Add(this.listBoxMaps);
|
||||
this.groupBox2.Controls.Add(this.ButtonDeleteMap);
|
||||
this.groupBox2.Controls.Add(this.textBoxNewMapName);
|
||||
this.groupBox2.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 22);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(173, 235);
|
||||
this.groupBox2.TabIndex = 15;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Карты";
|
||||
//
|
||||
// buttonAddMap
|
||||
//
|
||||
this.buttonAddMap.Location = new System.Drawing.Point(6, 85);
|
||||
this.buttonAddMap.Name = "buttonAddMap";
|
||||
this.buttonAddMap.Size = new System.Drawing.Size(161, 23);
|
||||
this.buttonAddMap.TabIndex = 9;
|
||||
this.buttonAddMap.Text = "Добавить карту";
|
||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 15;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(6, 115);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(161, 79);
|
||||
this.listBoxMaps.TabIndex = 8;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonDeleteMap
|
||||
//
|
||||
this.ButtonDeleteMap.Location = new System.Drawing.Point(6, 200);
|
||||
this.ButtonDeleteMap.Name = "ButtonDeleteMap";
|
||||
this.ButtonDeleteMap.Size = new System.Drawing.Size(161, 23);
|
||||
this.ButtonDeleteMap.TabIndex = 7;
|
||||
this.ButtonDeleteMap.Text = "Удалить карту";
|
||||
this.ButtonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 51);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(161, 23);
|
||||
this.textBoxNewMapName.TabIndex = 6;
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 22);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(161, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 5;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(116, 494);
|
||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonRight.TabIndex = 14;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(34, 494);
|
||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonLeft.TabIndex = 13;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(75, 460);
|
||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonUp.TabIndex = 12;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(75, 494);
|
||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonDown.TabIndex = 11;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight1
|
||||
//
|
||||
this.buttonRight1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight1.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
|
||||
this.buttonRight1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight1.Location = new System.Drawing.Point(109, 884);
|
||||
this.buttonRight1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRight1.Name = "buttonRight1";
|
||||
this.buttonRight1.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonRight1.TabIndex = 10;
|
||||
this.buttonRight1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonLeft1
|
||||
//
|
||||
this.buttonLeft1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft1.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft1.Location = new System.Drawing.Point(27, 884);
|
||||
this.buttonLeft1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonLeft1.Name = "buttonLeft1";
|
||||
this.buttonLeft1.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonLeft1.TabIndex = 9;
|
||||
this.buttonLeft1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonUp1
|
||||
//
|
||||
this.buttonUp1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp1.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp;
|
||||
this.buttonUp1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp1.Location = new System.Drawing.Point(68, 850);
|
||||
this.buttonUp1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUp1.Name = "buttonUp1";
|
||||
this.buttonUp1.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonUp1.TabIndex = 8;
|
||||
this.buttonUp1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ButtonShowOnMap
|
||||
//
|
||||
this.ButtonShowOnMap.Location = new System.Drawing.Point(17, 418);
|
||||
this.ButtonShowOnMap.Name = "ButtonShowOnMap";
|
||||
this.ButtonShowOnMap.Size = new System.Drawing.Size(161, 23);
|
||||
this.ButtonShowOnMap.TabIndex = 6;
|
||||
this.ButtonShowOnMap.Text = "Посмотреть карту";
|
||||
this.ButtonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// ButtonShowStorage
|
||||
//
|
||||
this.ButtonShowStorage.Location = new System.Drawing.Point(17, 380);
|
||||
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
||||
this.ButtonShowStorage.Size = new System.Drawing.Size(161, 23);
|
||||
this.ButtonShowStorage.TabIndex = 3;
|
||||
this.ButtonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.ButtonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 301);
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(161, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 4;
|
||||
//
|
||||
// ButtonAddJet
|
||||
//
|
||||
this.ButtonAddJet.Location = new System.Drawing.Point(17, 263);
|
||||
this.ButtonAddJet.Name = "ButtonAddJet";
|
||||
this.ButtonAddJet.Size = new System.Drawing.Size(161, 23);
|
||||
this.ButtonAddJet.TabIndex = 0;
|
||||
this.ButtonAddJet.Text = "Добавить самолет";
|
||||
this.ButtonAddJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddJet.Click += new System.EventHandler(this.ButtonAddJet_Click);
|
||||
//
|
||||
// ButtonRemoveJet
|
||||
//
|
||||
this.ButtonRemoveJet.Location = new System.Drawing.Point(17, 339);
|
||||
this.ButtonRemoveJet.Name = "ButtonRemoveJet";
|
||||
this.ButtonRemoveJet.Size = new System.Drawing.Size(161, 23);
|
||||
this.ButtonRemoveJet.TabIndex = 1;
|
||||
this.ButtonRemoveJet.Text = "Удалить самолет";
|
||||
this.ButtonRemoveJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonRemoveJet.Click += new System.EventHandler(this.ButtonRemoveJet_Click);
|
||||
//
|
||||
// pictureBoxJet
|
||||
//
|
||||
this.pictureBoxJet.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBoxJet.Location = new System.Drawing.Point(0, 27);
|
||||
this.pictureBoxJet.Name = "pictureBoxJet";
|
||||
this.pictureBoxJet.Size = new System.Drawing.Size(887, 546);
|
||||
this.pictureBoxJet.TabIndex = 6;
|
||||
this.pictureBoxJet.TabStop = false;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.файлToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(1096, 24);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.SaveToolStripMenuItem.Text = "Сохранение";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.LoadToolStripMenuItem.Text = "Загрузка";
|
||||
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormMapWithSetJets
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1096, 573);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.pictureBoxJet);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMapWithSetJets";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDown1;
|
||||
private GroupBox groupBox1;
|
||||
private Button buttonRight1;
|
||||
private Button buttonLeft1;
|
||||
private Button buttonUp1;
|
||||
private Button ButtonShowOnMap;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private Button ButtonShowStorage;
|
||||
private TextBox maskedTextBoxPosition;
|
||||
private Button ButtonAddJet;
|
||||
private Button ButtonRemoveJet;
|
||||
private PictureBox pictureBoxJet;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private GroupBox groupBox2;
|
||||
private Button buttonAddMap;
|
||||
private ListBox listBoxMaps;
|
||||
private Button ButtonDeleteMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
294
AirBomber/AirBomber/FormMapWithSetJets.cs
Normal file
294
AirBomber/AirBomber/FormMapWithSetJets.cs
Normal file
@ -0,0 +1,294 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 static System.Windows.Forms.DataFormats;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public partial class FormMapWithSetJets : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь для выпадающего списка
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Простая карта", new SimpleMap() },
|
||||
{ "Небо", new SkyMap() }
|
||||
};
|
||||
/// <summary>
|
||||
/// Объект от коллекции карт
|
||||
/// </summary>
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetJetsGeneric<DrawningObjectJet, AbstractMap> _mapJetsCollectionGeneric;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetJets(ILogger<FormMapWithSetJets> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_mapsCollection = new MapsCollection(pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapsDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение listBoxMaps
|
||||
/// </summary>
|
||||
private void ReloadMaps()
|
||||
{
|
||||
int index = listBoxMaps.SelectedIndex;
|
||||
listBoxMaps.Items.Clear();
|
||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||
{
|
||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||
}
|
||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||
{
|
||||
listBoxMaps.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||
{
|
||||
listBoxMaps.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogInformation("При добавлении карты {0}", comboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта");
|
||||
return;
|
||||
}
|
||||
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||
{
|
||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogInformation("При добавлении карты {0}", comboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта");
|
||||
return;
|
||||
}
|
||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||
ReloadMaps();
|
||||
_logger.LogInformation("Добавлена карта {0}", textBoxNewMapName.Text);
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation("Осуществлён переход на карту под названием {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
ReloadMaps();
|
||||
_logger.LogInformation("Удалена карта {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddJet_Click(DrawningJet jet)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawningObjectJet boat = new(jet);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation("Объект добавлен");
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogInformation("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
_logger.LogWarning($"Ошибка, переполнение хранилища: {0}", ex.Message);
|
||||
MessageBox.Show($"Ошибка, хранилище переполнено: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
_logger.LogWarning("Ошибка добавления");
|
||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveJet_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
try
|
||||
{
|
||||
var deletedJet = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
|
||||
if (deletedJet != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation("Из текущей карты удален объект {@ship}", deletedJet);
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Не удалось добавить объект по позиции {0} равен null", pos);
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning("Ошибка удаления: {0}", ex.Message);
|
||||
MessageBox.Show($"Ошибка удаления: {ex.Message}");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
dir = Direction.Up;
|
||||
break;
|
||||
case "buttonDown":
|
||||
dir = Direction.Down;
|
||||
break;
|
||||
case "buttonLeft":
|
||||
dir = Direction.Left;
|
||||
break;
|
||||
case "buttonRight":
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBoxJet.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.SaveData(saveFileDialog.FileName);
|
||||
_logger.LogInformation("Загрузка данных из файла '{0}' прошла успешно", openFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogInformation("Не удалось загрузить файл '{0}'. Текст ошибки: {1}", openFileDialog.FileName, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.LoadData(openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка данных прошла успешно", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
ReloadMaps();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
69
AirBomber/AirBomber/FormMapWithSetJets.resx
Normal file
69
AirBomber/AirBomber/FormMapWithSetJets.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>417, 19</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>272, 17</value>
|
||||
</metadata>
|
||||
</root>
|
44
AirBomber/AirBomber/IDrawningObject.cs
Normal file
44
AirBomber/AirBomber/IDrawningObject.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal interface IDrawningObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
/// </summary>
|
||||
public float Step { get; }
|
||||
/// <summary>
|
||||
/// Установка позиции объекта
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина полотна</param>
|
||||
/// <param name="height">Высота полотна</param>
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
void DrawningObject(Graphics g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
/// <summary>
|
||||
/// Получение информации по объекту
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetInfo();
|
||||
}
|
||||
}
|
22
AirBomber/AirBomber/JetNotFoundException.cs
Normal file
22
AirBomber/AirBomber/JetNotFoundException.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class JetNotFoundException : ApplicationException
|
||||
{
|
||||
public JetNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
|
||||
public JetNotFoundException() : base() { }
|
||||
|
||||
public JetNotFoundException(string message) : base(message) { }
|
||||
|
||||
public JetNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
|
||||
protected JetNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
227
AirBomber/AirBomber/MapWithSetJetsGeneric.cs
Normal file
227
AirBomber/AirBomber/MapWithSetJetsGeneric.cs
Normal file
@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class MapWithSetJetsGeneric<T, U>
|
||||
where T : class, IDrawningObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 122;
|
||||
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetJetGeneric<T> _setJets;
|
||||
|
||||
/// <summary>
|
||||
/// Карта
|
||||
/// </summary>
|
||||
private readonly U _map;
|
||||
public U Map => _map;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth">Ширина</param>
|
||||
/// <param name="picHeight">Высота</param>
|
||||
/// <param name="map">Карта</param>
|
||||
public MapWithSetJetsGeneric(int picWidth, int picHeight, U map)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setJets = new SetJetGeneric<T>(width * height);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="jet"></param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(MapWithSetJetsGeneric<T, U> map, T jet)
|
||||
{
|
||||
return map._setJets.Insert(jet);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static T operator -(MapWithSetJetsGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setJets.Remove(position);
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowSet()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawJets(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Просмотр объекта на карте
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
foreach (var car in _setJets.GetJets())
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение объекта по крате
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return _map.MoveObject(direction);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||
/// </summary>
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setJets.Count - 1;
|
||||
for (int i = 0; i < _setJets.Count; i++)
|
||||
{
|
||||
if (_setJets[i] == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var car = _setJets[j];
|
||||
if (car != null)
|
||||
{
|
||||
_setJets.Insert(car, i);
|
||||
_setJets.Remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
for (int x = 0; x < _pictureWidth; x++)
|
||||
{
|
||||
for (int y = 0; y < _pictureWidth; y++)
|
||||
{
|
||||
Brush hangarColor = new SolidBrush(Color.Silver);
|
||||
g.FillRectangle(hangarColor, x * x, y * y, x * (x + 1), y * (y + 1));
|
||||
}
|
||||
}
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{//линия рамзетки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth * 3 / 4, j * _placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawJets(Graphics g)
|
||||
{
|
||||
// максимальное количество колонок и строк
|
||||
int cols = _pictureWidth / _placeSizeWidth;
|
||||
//int rows = _pictureHeight / _placeSizeHeight;
|
||||
int rows = (cols - 1) * _placeSizeWidth;
|
||||
// счетчик колонок и строк
|
||||
int ccol = 0;
|
||||
int crow = 0;
|
||||
|
||||
for (int i = 0; i < _setJets.Count; i++)
|
||||
{
|
||||
// установка позиции
|
||||
//_setJets.Get(i)?.SetObject(ccol * _placeSizeWidth, crow * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||
_setJets[i]?.SetObject(rows - i % cols * _placeSizeWidth, i / cols * _placeSizeHeight + 3, _pictureWidth, _pictureHeight);
|
||||
_setJets[i]?.DrawningObject(g);
|
||||
//(сначала передвигаемся влево)
|
||||
ccol++;
|
||||
if (ccol >= cols)
|
||||
{
|
||||
//(потом двигаемся вниз)
|
||||
crow++;
|
||||
ccol = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных в виде строки
|
||||
/// </summary>
|
||||
/// <param name="separatorType">Разделитель карт</param>
|
||||
/// <param name="separatorData">Разделитель самолетов</param>
|
||||
/// <returns></returns>
|
||||
public string GetData(char separatorType, char separatorData)
|
||||
{
|
||||
string data = $"{_map.GetType().Name}{separatorType}";
|
||||
foreach (var car in _setJets.GetJets())
|
||||
{
|
||||
data += $"{car.GetInfo()}{separatorData}";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка списка из массива строк
|
||||
/// </summary>
|
||||
/// <param name="records"></param>
|
||||
public void LoadData(string[] records)
|
||||
{
|
||||
foreach (var rec in records)
|
||||
{
|
||||
_setJets.Insert(DrawningObjectJet.Create(rec) as T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
164
AirBomber/AirBomber/MapsCollection.cs
Normal file
164
AirBomber/AirBomber/MapsCollection.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции карт
|
||||
/// </summary>
|
||||
internal class MapsCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с картами
|
||||
/// </summary>
|
||||
readonly Dictionary<string, MapWithSetJetsGeneric<IDrawningObject, AbstractMap>> _mapStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий карт
|
||||
/// </summary>
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Разделитель карт
|
||||
/// </summary>
|
||||
private static readonly char separatorDict = '|';
|
||||
/// <summary>
|
||||
/// Разделитель самолетов
|
||||
/// </summary>
|
||||
private static readonly char separatorData = ',';
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string, MapWithSetJetsGeneric<IDrawningObject, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
/// <param name="map">Карта</param>
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
MapWithSetJetsGeneric<IDrawningObject, AbstractMap> mapJetsCollectionGeneric;
|
||||
|
||||
// Если карта или её имя не задано - выходим
|
||||
if (map == null || string.IsNullOrEmpty(name)) return;
|
||||
|
||||
// Если совершается попытка добавить карту с уже существующим именем, то выходим
|
||||
if (_mapStorages.ContainsKey(name)) return;
|
||||
mapJetsCollectionGeneric = new MapWithSetJetsGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map);
|
||||
_mapStorages.Add(name, mapJetsCollectionGeneric);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
public void DelMap(string name)
|
||||
{
|
||||
// Если имя удаляемой карты не задано - выходим
|
||||
if (string.IsNullOrEmpty(name)) return;
|
||||
_mapStorages.Remove(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Доступ к ангару
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public MapWithSetJetsGeneric<IDrawningObject, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
_mapStorages.TryGetValue(ind, out var result);
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод записи информации в файл
|
||||
/// </summary>
|
||||
/// <param name="text">Строка, которую следует записать</param>
|
||||
/// <param name="stream">Поток для записи</param>
|
||||
private static void WriteToFile(string text, FileStream stream)
|
||||
{
|
||||
byte[] info = new UTF8Encoding(true).GetBytes(text);
|
||||
stream.Write(info, 0, info.Length);
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение информации по самолетам в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns></returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter fs = new(filename))
|
||||
{
|
||||
fs.Write($"MapsCollection{Environment.NewLine}");
|
||||
foreach (var storage in _mapStorages)
|
||||
{
|
||||
fs.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка информации по самолетам из файла
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string str = "";
|
||||
if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
throw new FileFormatException("Формат данных в файле неправильный");
|
||||
}
|
||||
//очищаем записи
|
||||
_mapStorages.Clear();
|
||||
while ((str = sr.ReadLine()) != null)
|
||||
{
|
||||
var elem = str.Split(separatorDict);
|
||||
AbstractMap map = null;
|
||||
switch (elem[1])
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Небо":
|
||||
map = new SkyMap();
|
||||
break;
|
||||
}
|
||||
_mapStorages.Add(elem[0], new MapWithSetJetsGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
42
AirBomber/AirBomber/Program.cs
Normal file
42
AirBomber/AirBomber/Program.cs
Normal file
@ -0,0 +1,42 @@
|
||||
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<FormMapWithSetJets>());
|
||||
}
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormMapWithSetJets>()
|
||||
.AddLogging(option =>
|
||||
{
|
||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: "serilog.json").Build();
|
||||
|
||||
var logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
103
AirBomber/AirBomber/Properties/Resources.Designer.cs
generated
Normal file
103
AirBomber/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 arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
AirBomber/AirBomber/Properties/Resources.resx
Normal file
133
AirBomber/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="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
AirBomber/AirBomber/Resources/arrowDown.jpg
Normal file
BIN
AirBomber/AirBomber/Resources/arrowDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
AirBomber/AirBomber/Resources/arrowLeft.jpg
Normal file
BIN
AirBomber/AirBomber/Resources/arrowLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
AirBomber/AirBomber/Resources/arrowRight.jpg
Normal file
BIN
AirBomber/AirBomber/Resources/arrowRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
AirBomber/AirBomber/Resources/arrowUp.jpg
Normal file
BIN
AirBomber/AirBomber/Resources/arrowUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
115
AirBomber/AirBomber/SetJetGeneric.cs
Normal file
115
AirBomber/AirBomber/SetJetGeneric.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class SetJetGeneric<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 SetJetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление самолета в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="jet">Добавляемый самолет</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
//public int Insert(T jet)
|
||||
//{
|
||||
// return Insert(jet, 0);
|
||||
//}
|
||||
public int Insert(T jet, int position = 0)
|
||||
{
|
||||
if (position < 0 || position >= _maxCount || _maxCount <= _places.Count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_places.Contains(jet))
|
||||
{
|
||||
throw new ArgumentException($"Объект {jet} уже есть в наборе");
|
||||
}
|
||||
if (Count == _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
}
|
||||
_places.Insert(position, jet);
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= _maxCount) return null;
|
||||
var result = _places[position];
|
||||
_places.RemoveAt(position);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position">Позиция получаемого самолета</param>
|
||||
/// <returns></returns>
|
||||
public T this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position >= _maxCount) return null;
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
_places[position] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Проход по набору до первого пустого
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetJets()
|
||||
{
|
||||
foreach (var jet in _places)
|
||||
{
|
||||
if (jet != null)
|
||||
{
|
||||
yield return jet;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
52
AirBomber/AirBomber/SimpleMap.cs
Normal file
52
AirBomber/AirBomber/SimpleMap.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class SimpleMap : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
private readonly Brush roadColor = new SolidBrush(Color.Gray);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
int counter = 0;
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 25)
|
||||
{
|
||||
int x = _random.Next(0, 100);
|
||||
int y = _random.Next(0, 100);
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
52
AirBomber/AirBomber/SkyMap.cs
Normal file
52
AirBomber/AirBomber/SkyMap.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class SkyMap : AbstractMap
|
||||
{
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.White);
|
||||
private readonly Brush roadColor = new SolidBrush(Color.DeepSkyBlue);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
int counter = 0;
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 20)
|
||||
{
|
||||
int x = _random.Next(0, 95);
|
||||
int y = _random.Next(0, 95);
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y + 1] = _barrier;
|
||||
_map[x, y + 2] = _barrier;
|
||||
_map[x + 1, y + 1] = _barrier;
|
||||
_map[x + 2, y + 1] = _barrier;
|
||||
_map[x + 1, y] = _barrier;
|
||||
_map[x + 2, y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
AirBomber/AirBomber/StorageOverflowException.cs
Normal file
22
AirBomber/AirBomber/StorageOverflowException.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
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) { }
|
||||
}
|
||||
}
|
206
AirBomber/AirBomber/WarJet.Designer.cs
generated
Normal file
206
AirBomber/AirBomber/WarJet.Designer.cs
generated
Normal file
@ -0,0 +1,206 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class WarJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxJet = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.ButtonSelectJet = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxJet
|
||||
//
|
||||
this.pictureBoxJet.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxJet.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxJet.Name = "pictureBoxJet";
|
||||
this.pictureBoxJet.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxJet.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxJet.TabIndex = 0;
|
||||
this.pictureBoxJet.TabStop = false;
|
||||
this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxJet_Resize);
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip1.TabIndex = 1;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес:";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 402);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(702, 331);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonUp.TabIndex = 3;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(656, 377);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(748, 377);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonRight.TabIndex = 5;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(702, 377);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonDown.TabIndex = 6;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(93, 402);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(107, 23);
|
||||
this.buttonCreateModif.TabIndex = 7;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||
//
|
||||
// ButtonSelectJet
|
||||
//
|
||||
this.ButtonSelectJet.Location = new System.Drawing.Point(554, 394);
|
||||
this.ButtonSelectJet.Name = "ButtonSelectJet";
|
||||
this.ButtonSelectJet.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonSelectJet.TabIndex = 8;
|
||||
this.ButtonSelectJet.Text = "Выбрать";
|
||||
this.ButtonSelectJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonSelectJet.Click += new System.EventHandler(this.ButtonSelectJet_Click);
|
||||
//
|
||||
// WarJet
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ButtonSelectJet);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.pictureBoxJet);
|
||||
this.Name = "WarJet";
|
||||
this.Text = "Военный самолет";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit();
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxJet;
|
||||
private StatusStrip statusStrip1;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreateModif;
|
||||
private Button ButtonSelectJet;
|
||||
}
|
||||
}
|
121
AirBomber/AirBomber/WarJet.cs
Normal file
121
AirBomber/AirBomber/WarJet.cs
Normal file
@ -0,0 +1,121 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
public partial class WarJet : Form
|
||||
{
|
||||
private DrawningJet _jet;
|
||||
public DrawningJet SelectedJet { get; private set; }
|
||||
public WarJet()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Ìåòîä ïðîðèñîâêè ñàìîëåòà
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_jet?.DrawTransport(gr);
|
||||
pictureBoxJet.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ìåòîä óñòàíîâêè äàííûõ
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_jet.Jet.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_jet.Jet.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_jet.Jet.BodyColor.Name}";
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||
//_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//ïîëó÷àåì èìÿ êíîïêè
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_jet?.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_jet?.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_jet?.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_jet?.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PictureBoxJet_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_jet?.ChangeBorders(pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ìîäèôèêàöèÿ"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialogDop = new();
|
||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dopColor = dialogDop.Color;
|
||||
}
|
||||
_jet = new DrawningSportJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||
//var jet = new DrawningSportJet(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
//Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
//Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Âûáðàòü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectJet_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedJet = _jet;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
63
AirBomber/AirBomber/WarJet.resx
Normal file
63
AirBomber/AirBomber/WarJet.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
14
AirBomber/AirBomber/nlog.config
Normal file
14
AirBomber/AirBomber/nlog.config
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="carlog-
|
||||
${shortdate}.log" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
x
Reference in New Issue
Block a user