Compare commits

..

No commits in common. "Lab8_AntiAircraftGun" and "main" have entirely different histories.

42 changed files with 50 additions and 3085 deletions

View File

@ -8,57 +8,4 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
<PackageReference Include="NLog" Version="5.2.7" />
<PackageReference Include="NLog.Config" Version="4.7.15" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.7" />
<PackageReference Include="NLog.Schema" Version="5.2.7" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.7" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Settings.AppSettings" Version="2.2.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun
{
public enum DirectionType
{
//Вверх
Up = 1,
//Вниз
Down = 2,
//Влево
Left = 3,
//Вправо
Right = 4,
}
}

View File

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Entities;
namespace AntiAircraftGun.DrawningObjects
{
public class DrawingAntiAircraftGun : DrawningAircraftGun
{
// Конструктор
public DrawingAntiAircraftGun(int speed, double weight, Color bodyColor, Color additionalColor, bool luke, bool zenitkaGun, bool radar, int width, int height) :
base(speed, weight, bodyColor, width, height, 185, 128)
{
if (EntityAircraftGun != null)
{
EntityAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor, additionalColor, luke, zenitkaGun, radar);
}
}
public override void DrawZenitka(Graphics g)
{
if (EntityAircraftGun is not EntityAntiAircraftGun aircraftGun)
{
return;
}
Pen pen = new(Color.Black);
pen.Width = 2;
Brush additionalBrush = new SolidBrush(aircraftGun.AdditionalColor);
// Два орудия у зенитки
if (aircraftGun.ZenitkaGun)
{
Pen penTolst = new(Color.Black);
penTolst.Width = 5;
g.DrawLine(penTolst, startPosX + 105, startPosY + 63, startPosX + 175, startPosY + 13);
g.DrawLine(penTolst, startPosX + 105, startPosY + 73, startPosX + 185, startPosY + 18);
}
base.DrawZenitka(g);
// Лючек зенитки
if (aircraftGun.Luke)
{
g.FillRectangle(additionalBrush, startPosX + 80, startPosY + 43, 25, 10);
}
// Радар зенитки
if (aircraftGun.Radar)
{
g.DrawLine(pen, startPosX + 35, startPosY + 78, startPosX + 35, startPosY + 26);
g.DrawLine(pen, startPosX + 60, startPosY + 53, startPosX + 38, startPosY + 23);
g.DrawLine(pen, startPosX + 18, startPosY + 31, startPosX + 52, startPosY + 18);
g.DrawLine(pen, startPosX + 18, startPosY + 31, startPosX, startPosY + 18);
g.DrawLine(pen, startPosX + 52, startPosY + 18, startPosX + 55, startPosY - 2);
}
}
}
}

View File

@ -1,152 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Entities;
using AntiAircraftGun.MovementStrategy;
namespace AntiAircraftGun.DrawningObjects
{
// Класс, отвечающий за прорисовку и перемещение объекта-сущности
public class DrawningAircraftGun
{
// Класс-сущность
public EntityAircraftGun? EntityAircraftGun { get; protected set; }
// Ширина окна
public int pictureWidth;
// Высота окна
public int pictureHeight;
// Левая координата прорисовки зенитки
protected int startPosX;
// Верхняя координата прорисовки зенитки
protected int startPosY;
// Ширина прорисоки зенитки
protected readonly int _zenitkaWidth = 185;
// Высота прорисовки зенитки
protected readonly int _zenitkaHeight = 128;
// Координата Х объекта
public int GetPosX => startPosX;
// Координата Y объекта
public int GetPosY => startPosY;
// Ширина объекта
public int GetWidth => _zenitkaWidth;
// Высота объекта
public int GetHeight => _zenitkaHeight;
// Конструктор
public DrawningAircraftGun(int speed, double weight, Color bodyColor, int width, int height)
{
if (width < _zenitkaWidth) { return; }
if (height < _zenitkaHeight) { return; }
pictureWidth = width;
pictureHeight = height;
EntityAircraftGun = new EntityAircraftGun(speed, weight, bodyColor);
}
// Конструктор
protected DrawningAircraftGun(int speed, double weight, Color bodyColor, int width, int height, int zenitkaWidth, int zenitkaHeight)
{
pictureWidth = width;
pictureHeight = height;
_zenitkaWidth = zenitkaWidth;
_zenitkaHeight = zenitkaHeight;
EntityAircraftGun = new EntityAircraftGun(speed, weight, bodyColor);
}
// Установка позиции
public void SetPosition(int x, int y)
{
if (x < 0) { x = 0; }
else if (x > pictureWidth) { x = pictureWidth; }
if (y < 0) { y = 0; }
else if (y > pictureHeight) { y = pictureHeight; }
startPosX = x;
startPosY = y;
}
// Проверка, что объект может переместиться по указанному направлению
public bool CanMove(DirectionType direction)
{
if (EntityAircraftGun == null)
{
return false;
}
return direction switch
{
// влево
DirectionType.Left => startPosX - EntityAircraftGun.Step > 0,
// вверх
DirectionType.Up => startPosY - EntityAircraftGun.Step > 0,
// вправо
DirectionType.Right => startPosX + EntityAircraftGun.Step + _zenitkaWidth < pictureWidth,
// вниз
DirectionType.Down => startPosY + EntityAircraftGun.Step + _zenitkaHeight < pictureHeight,
};
}
// Изменение направления перемещения
public void MoveTransport(DirectionType direction)
{
if (!CanMove(direction) || EntityAircraftGun == null)
{
return;
}
switch (direction)
{
// влево
case DirectionType.Left:
startPosX -= (int)EntityAircraftGun.Step;
break;
// вверх
case DirectionType.Up:
startPosY -= (int)EntityAircraftGun.Step;
break;
// вправо
case DirectionType.Right:
startPosX += (int)EntityAircraftGun.Step;
break;
// вниз
case DirectionType.Down:
startPosY += (int)EntityAircraftGun.Step;
break;
}
}
// Прорисовка объекта
public virtual void DrawZenitka(Graphics g)
{
if (EntityAircraftGun == null)
{
return;
}
Pen pen = new(Color.Black);
pen.Width = 2;
Brush additionalBrush = new SolidBrush(EntityAircraftGun.BodyColor);
// Гусеница
g.DrawEllipse(pen, startPosX, startPosY + 103, 150, 25);
g.DrawEllipse(pen, startPosX + 5, startPosY + 110, 10, 10);
g.DrawEllipse(pen, startPosX + 18, startPosY + 108, 15, 15);
g.DrawEllipse(pen, startPosX + 36, startPosY + 107, 17, 17);
g.DrawEllipse(pen, startPosX + 56, startPosY + 107, 17, 17);
g.DrawEllipse(pen, startPosX + 76, startPosY + 107, 17, 17);
g.DrawEllipse(pen, startPosX + 96, startPosY + 107, 17, 17);
g.DrawEllipse(pen, startPosX + 116, startPosY + 108, 15, 15);
g.DrawEllipse(pen, startPosX + 136, startPosY + 110, 10, 10);
// Корпус зенитки
Brush brGreen = new SolidBrush(Color.Green);
g.FillRectangle(brGreen, startPosX + 20, startPosY + 78, 110, 25);
// Башня зенитки
g.FillRectangle(additionalBrush, startPosX + 45, startPosY + 53, 60, 25);
}
// Получение объекта IMoveableObject из объекта DrawingAntiAircraftGun
public IMoveableObject GetMoveableObject => new DrawningObjectAircraftGun(this);
}
}

View File

@ -1,43 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Entities;
namespace AntiAircraftGun.DrawningObjects
{
public static class ExtentionDrawningAircraftGun
{
// Создание объекта из строки
public static DrawningAircraftGun? CreateDrawningAircraftGun(this string info, char separatorForObject, int width, int height)
{
string[] strs = info.Split(separatorForObject);
if (strs.Length == 3)
{
return new DrawningAircraftGun(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
}
if (strs.Length == 7)
{
return new DrawingAntiAircraftGun(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), width, height);
}
return null;
}
// Получение данных для сохранения в файл
public static string GetDataForSave(this DrawningAircraftGun drawningAircraftGun, char separatorForObject)
{
var aircraftgun = drawningAircraftGun.EntityAircraftGun;
if (aircraftgun == null)
{
return string.Empty;
}
var str = $"{aircraftgun.Speed}{separatorForObject}{aircraftgun.Weight}{separatorForObject}{aircraftgun.BodyColor.Name}";
if (aircraftgun is not EntityAntiAircraftGun antiAircraftGun)
{
return str;
}
return $"{str}{separatorForObject}{antiAircraftGun.AdditionalColor.Name}{separatorForObject}{antiAircraftGun.Radar}{separatorForObject}{antiAircraftGun.Luke}{separatorForObject}{antiAircraftGun.ZenitkaGun}";
}
}
}

View File

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Entities
{
// Класс-сущность "Зенитка"
public class EntityAircraftGun
{
public void Bodycolor(Color color)
{
BodyColor = color;
}
// Скорость
public int Speed { get; private set; }
// Вес
public double Weight { get; private set; }
// Основной цвет
public Color BodyColor { get; private set; }
// Шаг перемещения зенитки
public double Step => (double)Speed * 100 / Weight;
// Конструктор с параметрами
public EntityAircraftGun(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
}
}

View File

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Entities
{
// Класс-сущность "Стреляющая зенитка"
public class EntityAntiAircraftGun : EntityAircraftGun
{
public void Additionalcolor(Color color)
{
AdditionalColor = color;
}
// Доп. цвет
public Color AdditionalColor { get; private set; }
// Признак наличия люка
public bool Luke { get; private set; }
// Признак наличия зенитного орудия
public bool ZenitkaGun { get; private set; }
// признак наличия радара
public bool Radar { get; private set; }
// Инициализация полей объекта-класса продвинутой зенитки
public EntityAntiAircraftGun(int speed, double weight, Color bodyColor, Color additionalColor, bool luke, bool zenitkaGun, bool radar) :
base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Luke = luke;
ZenitkaGun = zenitkaGun;
Radar = radar;
}
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace AntiAircraftGun.Exceptions
{
[Serializable]
internal class AircraftGunNotFoundException : ApplicationException
{
public AircraftGunNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
public AircraftGunNotFoundException() : base() { }
public AircraftGunNotFoundException(string message) : base(message) { }
public AircraftGunNotFoundException(string message, Exception exception) : base(message, exception) { }
protected AircraftGunNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace AntiAircraftGun.Exceptions
{
[Serializable]
internal class StorageOverflowException : ApplicationException
{
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
public StorageOverflowException() : base() { }
public StorageOverflowException(string message) : base(message) { }
public StorageOverflowException(string message, Exception exception) : base(message, exception) { }
protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}

View File

@ -0,0 +1,39 @@
namespace AntiAircraftGun
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -0,0 +1,10 @@
namespace AntiAircraftGun
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -117,17 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowDown.png;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.png;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.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -1,274 +0,0 @@
namespace AntiAircraftGun
{
partial class FormAircraftGunCollection
{
/// <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.pictureBoxCollection = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ButtonSortByType = new System.Windows.Forms.Button();
this.ButtonSortByColor = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.listBoxStorages = new System.Windows.Forms.ListBox();
this.textBoxStorageName = new System.Windows.Forms.TextBox();
this.ButtonAddObject = new System.Windows.Forms.Button();
this.ButtonDelObject = new System.Windows.Forms.Button();
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
this.ButtonAddAircraftGun = new System.Windows.Forms.Button();
this.ButtonRemoveAircraftGun = new System.Windows.Forms.Button();
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
this.menuStrip = 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();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxCollection
//
this.pictureBoxCollection.Location = new System.Drawing.Point(12, 27);
this.pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.Size = new System.Drawing.Size(797, 517);
this.pictureBoxCollection.TabIndex = 0;
this.pictureBoxCollection.TabStop = false;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.ButtonSortByType);
this.groupBox1.Controls.Add(this.ButtonSortByColor);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.maskedTextBoxNumber);
this.groupBox1.Controls.Add(this.ButtonAddAircraftGun);
this.groupBox1.Controls.Add(this.ButtonRemoveAircraftGun);
this.groupBox1.Controls.Add(this.ButtonRefreshCollection);
this.groupBox1.Location = new System.Drawing.Point(815, 27);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(236, 470);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Инструменты";
//
// ButtonSortByType
//
this.ButtonSortByType.Location = new System.Drawing.Point(49, 236);
this.ButtonSortByType.Name = "ButtonSortByType";
this.ButtonSortByType.Size = new System.Drawing.Size(156, 27);
this.ButtonSortByType.TabIndex = 8;
this.ButtonSortByType.Text = "Сортировка по типу";
this.ButtonSortByType.UseVisualStyleBackColor = true;
this.ButtonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click);
//
// ButtonSortByColor
//
this.ButtonSortByColor.Location = new System.Drawing.Point(49, 269);
this.ButtonSortByColor.Name = "ButtonSortByColor";
this.ButtonSortByColor.Size = new System.Drawing.Size(156, 27);
this.ButtonSortByColor.TabIndex = 7;
this.ButtonSortByColor.Text = "Сортировка по цвету";
this.ButtonSortByColor.UseVisualStyleBackColor = true;
this.ButtonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.listBoxStorages);
this.groupBox2.Controls.Add(this.textBoxStorageName);
this.groupBox2.Controls.Add(this.ButtonAddObject);
this.groupBox2.Controls.Add(this.ButtonDelObject);
this.groupBox2.Location = new System.Drawing.Point(21, 22);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(209, 205);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Наборы";
//
// listBoxStorages
//
this.listBoxStorages.FormattingEnabled = true;
this.listBoxStorages.ItemHeight = 15;
this.listBoxStorages.Location = new System.Drawing.Point(30, 86);
this.listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.Size = new System.Drawing.Size(156, 79);
this.listBoxStorages.TabIndex = 4;
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxStorages_SelectedIndexChanged);
//
// textBoxStorageName
//
this.textBoxStorageName.Location = new System.Drawing.Point(30, 26);
this.textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.Size = new System.Drawing.Size(156, 23);
this.textBoxStorageName.TabIndex = 3;
//
// ButtonAddObject
//
this.ButtonAddObject.Location = new System.Drawing.Point(30, 55);
this.ButtonAddObject.Name = "ButtonAddObject";
this.ButtonAddObject.Size = new System.Drawing.Size(156, 25);
this.ButtonAddObject.TabIndex = 2;
this.ButtonAddObject.Text = "Добавить набор";
this.ButtonAddObject.UseVisualStyleBackColor = true;
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
//
// ButtonDelObject
//
this.ButtonDelObject.Location = new System.Drawing.Point(30, 171);
this.ButtonDelObject.Name = "ButtonDelObject";
this.ButtonDelObject.Size = new System.Drawing.Size(156, 25);
this.ButtonDelObject.TabIndex = 2;
this.ButtonDelObject.Text = "Удалить набор";
this.ButtonDelObject.UseVisualStyleBackColor = true;
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Location = new System.Drawing.Point(49, 335);
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(156, 23);
this.maskedTextBoxNumber.TabIndex = 5;
//
// ButtonAddAircraftGun
//
this.ButtonAddAircraftGun.Location = new System.Drawing.Point(49, 302);
this.ButtonAddAircraftGun.Name = "ButtonAddAircraftGun";
this.ButtonAddAircraftGun.Size = new System.Drawing.Size(156, 27);
this.ButtonAddAircraftGun.TabIndex = 2;
this.ButtonAddAircraftGun.Text = "Добавить зенитку";
this.ButtonAddAircraftGun.UseVisualStyleBackColor = true;
this.ButtonAddAircraftGun.Click += new System.EventHandler(this.ButtonAddAircraftGun_Click);
//
// ButtonRemoveAircraftGun
//
this.ButtonRemoveAircraftGun.Location = new System.Drawing.Point(49, 364);
this.ButtonRemoveAircraftGun.Name = "ButtonRemoveAircraftGun";
this.ButtonRemoveAircraftGun.Size = new System.Drawing.Size(156, 26);
this.ButtonRemoveAircraftGun.TabIndex = 2;
this.ButtonRemoveAircraftGun.Text = "Удалить зенитку";
this.ButtonRemoveAircraftGun.UseVisualStyleBackColor = true;
this.ButtonRemoveAircraftGun.Click += new System.EventHandler(this.ButtonRemoveAircraftGun_Click);
//
// ButtonRefreshCollection
//
this.ButtonRefreshCollection.Location = new System.Drawing.Point(49, 396);
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
this.ButtonRefreshCollection.Size = new System.Drawing.Size(156, 27);
this.ButtonRefreshCollection.TabIndex = 2;
this.ButtonRefreshCollection.Text = "Обновить коллекцию";
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.файлToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1063, 24);
this.menuStrip.TabIndex = 2;
this.menuStrip.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(141, 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(141, 22);
this.LoadToolStripMenuItem.Text = "Загрузка";
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
//
// openFileDialog
//
this.openFileDialog.FileName = "openFileDialog1";
this.openFileDialog.Filter = "txt file | *.txt";
//
// saveFileDialog
//
this.saveFileDialog.Filter = "txt file | *.txt";
//
// FormAircraftGunCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1063, 556);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pictureBoxCollection);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormAircraftGunCollection";
this.Text = "Набор зениток";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxCollection;
private GroupBox groupBox1;
private Button ButtonRefreshCollection;
private Button ButtonRemoveAircraftGun;
private Button ButtonAddAircraftGun;
private Button ButtonDelObject;
private Button ButtonAddObject;
private TextBox textBoxStorageName;
private ListBox listBoxStorages;
private MaskedTextBox maskedTextBoxNumber;
private GroupBox groupBox2;
private MenuStrip menuStrip;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem SaveToolStripMenuItem;
private ToolStripMenuItem LoadToolStripMenuItem;
private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog;
private Button ButtonSortByType;
private Button ButtonSortByColor;
}
}

View File

@ -1,255 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.Exceptions;
using AntiAircraftGun.Generics;
using AntiAircraftGun.MovementStrategy;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Extensions.Logging;
using System.Xml.Linq;
namespace AntiAircraftGun
{
public partial class FormAircraftGunCollection : Form
{
private readonly AntiAircraftGunsGenericStorage _storage;
private readonly ILogger _logger;
public FormAircraftGunCollection(ILogger<FormAircraftGunCollection> logger)
{
InitializeComponent();
_storage = new AntiAircraftGunsGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
_logger = logger;
}
// Заполнение listBoxObjects
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorages.Items.Add(_storage.Keys[i]);
}
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
{
listBoxStorages.SelectedIndex = 0;
}
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
{
listBoxStorages.SelectedIndex = index;
}
}
// Обновление рисунка по набору
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollection.Image = obj.ShowAntiAircraftGuns();
}
// Удаление объекта из набора
private void ButtonRemoveAircraftGun_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? String.Empty];
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
if (obj == null)
{
return;
}
if (MessageBox.Show("удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
try
{
if (obj - pos != null)
{
MessageBox.Show("Объект удалён");
pictureBoxCollection.Image = obj.ShowAntiAircraftGuns();
_logger.LogInformation($"Из набора {name} удален объект");
}
else
{
MessageBox.Show("Не удалось удалить объект");
_logger.LogWarning("Не удалось удалить объект");
}
}
catch(AircraftGunNotFoundException ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning($"{ex.Message}. Не удалось удалить объект");
}
}
private void AddAircraftGun(DrawningAircraftGun aircraftGun)
{
aircraftGun.pictureWidth = pictureBoxCollection.Width;
aircraftGun.pictureHeight = pictureBoxCollection.Height;
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
if (obj == null)
{
return;
}
try
{
if (obj + aircraftGun)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowAntiAircraftGuns();
_logger.LogInformation($"В набор {name} добавлен объект");
}
else
{
MessageBox.Show("Не удалось добавить объект");
_logger.LogWarning("Не удалось добавить объект");
}
}
catch(StorageOverflowException ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning($"{ex.Message}. Не удалось добавить объект");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning($"{ex.Message}. Не удалось добавить объект");
}
}
// Добавление объекта в набор
private void ButtonAddAircraftGun_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
FormAircraftGunConfig form = new FormAircraftGunConfig();
form.Show();
form.AddEvent(AddAircraftGun);
}
// Удаление набора
private void ButtonDelObject_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
_logger.LogWarning($"Удаление невыбранного набора");
return;
}
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
if (MessageBox.Show($"удалить объект {name}?", "удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
ReloadObjects();
_logger.LogInformation($"Удален набор: {name}");
}
}
// Добавление набора в коллекцию
private void ButtonAddObject_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не все данные заполены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning("Ошибка. Не все данные заполнены");
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
}
// Выбор набора
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAntiAircraftGuns();
}
// Обработка нажатия "Сохранение"
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_storage.SaveData(saveFileDialog.FileName);
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Сохранение");
}
catch (Exception ex) {
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning("Ошибка сохранения");
}
}
}
// Обработка нажатия "Загрузка"
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if(openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_storage.LoadData(openFileDialog.FileName);
ReloadObjects();
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Загрузка");
}
catch (Exception ex) {
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning("Ошибка загрузки");
}
}
}
private void ButtonSortByType_Click(object sender, EventArgs e) => CompareAntiAircraftGun(new AircraftGunCompareByType());
private void ButtonSortByColor_Click(object sender, EventArgs e) => CompareAntiAircraftGun(new AircraftGunCompareByColor());
private void CompareAntiAircraftGun(IComparer<DrawningAircraftGun?> comparer)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
obj.Sort(comparer);
pictureBoxCollection.Image = obj.ShowAntiAircraftGuns();
}
}
}

View File

@ -1,72 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 18</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>272, 18</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@ -1,400 +0,0 @@
namespace AntiAircraftGun
{
partial class FormAircraftGunConfig
{
/// <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.checkBoxGuns = new System.Windows.Forms.CheckBox();
this.checkBoxLuke = new System.Windows.Forms.CheckBox();
this.checkBoxRadar = new System.Windows.Forms.CheckBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.labelWeight = new System.Windows.Forms.Label();
this.labelSpeed = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.panel9 = new System.Windows.Forms.Panel();
this.LabelAdditionalColor = new System.Windows.Forms.Label();
this.LabelColor = new System.Windows.Forms.Label();
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();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.panel9.SuspendLayout();
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.checkBoxGuns);
this.groupBox1.Controls.Add(this.checkBoxLuke);
this.groupBox1.Controls.Add(this.checkBoxRadar);
this.groupBox1.Controls.Add(this.numericUpDownWeight);
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
this.groupBox1.Controls.Add(this.labelWeight);
this.groupBox1.Controls.Add(this.labelSpeed);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(538, 264);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Параметры";
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(380, 202);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(114, 42);
this.labelModifiedObject.TabIndex = 9;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.labelModifiedObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(238, 202);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(114, 42);
this.labelSimpleObject.TabIndex = 8;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.labelSimpleObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// 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(217, 28);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(302, 149);
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(235, 89);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(50, 50);
this.panelPurple.TabIndex = 7;
//
// panelBlack
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(163, 89);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(50, 50);
this.panelBlack.TabIndex = 6;
//
// panelGray
//
this.panelGray.BackColor = System.Drawing.Color.Gray;
this.panelGray.Location = new System.Drawing.Point(91, 89);
this.panelGray.Name = "panelGray";
this.panelGray.Size = new System.Drawing.Size(50, 50);
this.panelGray.TabIndex = 5;
//
// panelWhite
//
this.panelWhite.BackColor = System.Drawing.Color.White;
this.panelWhite.Location = new System.Drawing.Point(21, 89);
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(50, 50);
this.panelWhite.TabIndex = 4;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(235, 22);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(50, 50);
this.panelYellow.TabIndex = 3;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(163, 22);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(50, 50);
this.panelBlue.TabIndex = 2;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.Green;
this.panelGreen.Location = new System.Drawing.Point(91, 22);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(50, 50);
this.panelGreen.TabIndex = 1;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(21, 22);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(50, 50);
this.panelRed.TabIndex = 0;
//
// checkBoxGuns
//
this.checkBoxGuns.AutoSize = true;
this.checkBoxGuns.Location = new System.Drawing.Point(16, 202);
this.checkBoxGuns.Name = "checkBoxGuns";
this.checkBoxGuns.Size = new System.Drawing.Size(166, 19);
this.checkBoxGuns.TabIndex = 6;
this.checkBoxGuns.Text = "Признак наличия орудий";
this.checkBoxGuns.UseVisualStyleBackColor = true;
//
// checkBoxLuke
//
this.checkBoxLuke.AutoSize = true;
this.checkBoxLuke.Location = new System.Drawing.Point(16, 160);
this.checkBoxLuke.Name = "checkBoxLuke";
this.checkBoxLuke.Size = new System.Drawing.Size(162, 19);
this.checkBoxLuke.TabIndex = 5;
this.checkBoxLuke.Text = "Признак наличия лючка";
this.checkBoxLuke.UseVisualStyleBackColor = true;
//
// checkBoxRadar
//
this.checkBoxRadar.AutoSize = true;
this.checkBoxRadar.Location = new System.Drawing.Point(16, 119);
this.checkBoxRadar.Name = "checkBoxRadar";
this.checkBoxRadar.Size = new System.Drawing.Size(164, 19);
this.checkBoxRadar.TabIndex = 4;
this.checkBoxRadar.Text = "Признак наличия радара";
this.checkBoxRadar.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(84, 75);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(75, 23);
this.numericUpDownWeight.TabIndex = 3;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(84, 28);
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(75, 23);
this.numericUpDownSpeed.TabIndex = 2;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(16, 77);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(29, 15);
this.labelWeight.TabIndex = 1;
this.labelWeight.Text = "Вес:";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(16, 30);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
this.labelSpeed.TabIndex = 0;
this.labelSpeed.Text = "Скорость:";
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(19, 58);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(278, 154);
this.pictureBoxObject.TabIndex = 1;
this.pictureBoxObject.TabStop = false;
//
// panel9
//
this.panel9.AllowDrop = true;
this.panel9.Controls.Add(this.LabelAdditionalColor);
this.panel9.Controls.Add(this.LabelColor);
this.panel9.Controls.Add(this.pictureBoxObject);
this.panel9.Location = new System.Drawing.Point(566, 21);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(311, 222);
this.panel9.TabIndex = 2;
this.panel9.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel9.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// LabelAdditionalColor
//
this.LabelAdditionalColor.AllowDrop = true;
this.LabelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelAdditionalColor.Location = new System.Drawing.Point(172, 19);
this.LabelAdditionalColor.Name = "LabelAdditionalColor";
this.LabelAdditionalColor.Size = new System.Drawing.Size(125, 36);
this.LabelAdditionalColor.TabIndex = 3;
this.LabelAdditionalColor.Text = "Доп. цвет";
this.LabelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.LabelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
this.LabelAdditionalColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// LabelColor
//
this.LabelColor.AllowDrop = true;
this.LabelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelColor.Location = new System.Drawing.Point(19, 19);
this.LabelColor.Name = "LabelColor";
this.LabelColor.Size = new System.Drawing.Size(125, 36);
this.LabelColor.TabIndex = 2;
this.LabelColor.Text = "Цвет";
this.LabelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.LabelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
this.LabelColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// ButtonOk
//
this.ButtonOk.Location = new System.Drawing.Point(585, 248);
this.ButtonOk.Name = "ButtonOk";
this.ButtonOk.Size = new System.Drawing.Size(125, 32);
this.ButtonOk.TabIndex = 3;
this.ButtonOk.Text = "Добавить";
this.ButtonOk.UseVisualStyleBackColor = true;
this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(738, 248);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(125, 32);
this.ButtonCancel.TabIndex = 3;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
//
// FormAircraftGunConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(901, 288);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.panel9);
this.Controls.Add(this.ButtonOk);
this.Controls.Add(this.groupBox1);
this.Name = "FormAircraftGunConfig";
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();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.panel9.ResumeLayout(false);
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 checkBoxGuns;
private CheckBox checkBoxLuke;
private CheckBox checkBoxRadar;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelWeight;
private Label labelSpeed;
private PictureBox pictureBoxObject;
private Panel panel9;
private Label LabelAdditionalColor;
private Label LabelColor;
private Button ButtonOk;
private Button ButtonCancel;
}
}

View File

@ -1,135 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.Entities;
namespace AntiAircraftGun
{
public partial class FormAircraftGunConfig : Form
{
// Переменная выбранная зенитка
DrawningAircraftGun? _aircraftGun = null;
// Событие
private event Action<DrawningAircraftGun>? EventAddAircraftGun;
public FormAircraftGunConfig()
{
InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelGray.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelRed.MouseDown += PanelColor_MouseDown;
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
ButtonCancel.Click += (sender, e) => Close();
}
private void DrawAircraftGun()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_aircraftGun?.SetPosition(5, 5);
_aircraftGun?.DrawZenitka(gr);
pictureBoxObject.Image = bmp;
}
public void AddEvent(Action<DrawningAircraftGun> ev)
{
if (EventAddAircraftGun == null)
{
EventAddAircraftGun = ev;
}
else
{
EventAddAircraftGun += ev;
}
}
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_aircraftGun = new DrawningAircraftGun((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
case "labelModifiedObject":
_aircraftGun = new DrawingAntiAircraftGun((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxLuke.Checked, checkBoxGuns.Checked, checkBoxRadar.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawAircraftGun();
}
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddAircraftGun?.Invoke(_aircraftGun);
Close();
}
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
if (_aircraftGun == null)
{
return;
}
switch (((Label)sender).Name)
{
case "LabelColor":
_aircraftGun.EntityAircraftGun.Bodycolor((Color)e.Data.GetData(typeof(Color)));
break;
case "LabelAdditionalColor":
if (_aircraftGun == null)
{
return;
}
(_aircraftGun.EntityAircraftGun as EntityAntiAircraftGun).Additionalcolor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawAircraftGun();
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,206 +0,0 @@
namespace AntiAircraftGun
{
partial class FormAntiAircraftGun
{
/// <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.pictureBox = new System.Windows.Forms.PictureBox();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateAntiAircraftGun = new System.Windows.Forms.Button();
this.pictureBoxAntiAircraftGun = new System.Windows.Forms.PictureBox();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
this.ButtonCreateAntiAircraftGun_Click = new System.Windows.Forms.Button();
this.ButtonStep_Click = new System.Windows.Forms.Button();
this.ButtonSelectAircraftGun_Click = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(884, 461);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::AntiAircraftGun.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonUp.Location = new System.Drawing.Point(791, 373);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(35, 35);
this.buttonUp.TabIndex = 11;
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::AntiAircraftGun.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonLeft.Location = new System.Drawing.Point(750, 414);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
this.buttonLeft.TabIndex = 10;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.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::AntiAircraftGun.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonDown.Location = new System.Drawing.Point(791, 414);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(35, 35);
this.buttonDown.TabIndex = 9;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.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::AntiAircraftGun.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonRight.Location = new System.Drawing.Point(832, 414);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(35, 35);
this.buttonRight.TabIndex = 8;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonCreateAntiAircraftGun
//
this.buttonCreateAntiAircraftGun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateAntiAircraftGun.Location = new System.Drawing.Point(148, 406);
this.buttonCreateAntiAircraftGun.Name = "buttonCreateAntiAircraftGun";
this.buttonCreateAntiAircraftGun.Size = new System.Drawing.Size(186, 43);
this.buttonCreateAntiAircraftGun.TabIndex = 7;
this.buttonCreateAntiAircraftGun.Text = "Создать стреляющую зенитку";
this.buttonCreateAntiAircraftGun.UseVisualStyleBackColor = true;
this.buttonCreateAntiAircraftGun.Click += new System.EventHandler(this.buttonCreate_Click);
//
// pictureBoxAntiAircraftGun
//
this.pictureBoxAntiAircraftGun.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAntiAircraftGun.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAntiAircraftGun.Name = "pictureBoxAntiAircraftGun";
this.pictureBoxAntiAircraftGun.Size = new System.Drawing.Size(884, 461);
this.pictureBoxAntiAircraftGun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAntiAircraftGun.TabIndex = 6;
this.pictureBoxAntiAircraftGun.TabStop = false;
//
// comboBoxStrategy
//
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxStrategy.FormattingEnabled = true;
this.comboBoxStrategy.Items.AddRange(new object[] {
"Движение к центру",
"Движение в правый нижний угол"});
this.comboBoxStrategy.Location = new System.Drawing.Point(633, 12);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(239, 23);
this.comboBoxStrategy.TabIndex = 12;
//
// ButtonCreateAntiAircraftGun_Click
//
this.ButtonCreateAntiAircraftGun_Click.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ButtonCreateAntiAircraftGun_Click.Location = new System.Drawing.Point(12, 406);
this.ButtonCreateAntiAircraftGun_Click.Name = "ButtonCreateAntiAircraftGun_Click";
this.ButtonCreateAntiAircraftGun_Click.Size = new System.Drawing.Size(111, 43);
this.ButtonCreateAntiAircraftGun_Click.TabIndex = 13;
this.ButtonCreateAntiAircraftGun_Click.Text = "Создать зенитку";
this.ButtonCreateAntiAircraftGun_Click.UseVisualStyleBackColor = true;
this.ButtonCreateAntiAircraftGun_Click.Click += new System.EventHandler(this.ButtonCreateAntiAircraftGun_Click_Click);
//
// ButtonStep_Click
//
this.ButtonStep_Click.Location = new System.Drawing.Point(812, 50);
this.ButtonStep_Click.Name = "ButtonStep_Click";
this.ButtonStep_Click.Size = new System.Drawing.Size(55, 42);
this.ButtonStep_Click.TabIndex = 14;
this.ButtonStep_Click.Text = "Шаг";
this.ButtonStep_Click.UseVisualStyleBackColor = true;
this.ButtonStep_Click.Click += new System.EventHandler(this.ButtonStep_Click_Click);
//
// ButtonSelectAircraftGun_Click
//
this.ButtonSelectAircraftGun_Click.Location = new System.Drawing.Point(349, 406);
this.ButtonSelectAircraftGun_Click.Name = "ButtonSelectAircraftGun_Click";
this.ButtonSelectAircraftGun_Click.Size = new System.Drawing.Size(120, 43);
this.ButtonSelectAircraftGun_Click.TabIndex = 15;
this.ButtonSelectAircraftGun_Click.Text = "Выбрать зенитку";
this.ButtonSelectAircraftGun_Click.UseVisualStyleBackColor = true;
this.ButtonSelectAircraftGun_Click.Click += new System.EventHandler(this.ButtonSelectAircraftGun_Click_Click);
//
// FormAntiAircraftGun
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(884, 461);
this.Controls.Add(this.ButtonSelectAircraftGun_Click);
this.Controls.Add(this.ButtonStep_Click);
this.Controls.Add(this.ButtonCreateAntiAircraftGun_Click);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonCreateAntiAircraftGun);
this.Controls.Add(this.pictureBoxAntiAircraftGun);
this.Controls.Add(this.pictureBox);
this.Name = "FormAntiAircraftGun";
this.Text = "Зенитное орудие";
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBox;
private Button buttonUp;
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
private Button buttonCreateAntiAircraftGun;
private PictureBox pictureBoxAntiAircraftGun;
private ComboBox comboBoxStrategy;
private Button ButtonCreateAntiAircraftGun_Click;
private Button ButtonStep_Click;
private Button ButtonSelectAircraftGun_Click;
}
}

View File

@ -1,139 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.MovementStrategy;
namespace AntiAircraftGun
{
public partial class FormAntiAircraftGun : Form
{
private DrawningAircraftGun? _drawningAircraftGun;
private AbstractStrategy? abstractStrategy;
// Âûáðàííàÿ çåíèòêà
public DrawningAircraftGun? SelectedAircraftGun { get; private set; }
public FormAntiAircraftGun()
{
InitializeComponent();
abstractStrategy = null;
SelectedAircraftGun = null;
}
private void Draw()
{
if (_drawningAircraftGun == null)
{
return;
}
Bitmap bmp = new(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningAircraftGun.DrawZenitka(gr);
pictureBoxAntiAircraftGun.Image = bmp;
}
// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü ñòðåëÿþùóþ çåíèòêó"
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
if (dialog.ShowDialog() == DialogResult.OK)
{
dopColor = dialog.Color;
}
_drawningAircraftGun = new DrawingAntiAircraftGun(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAntiAircraftGun.Width,
pictureBoxAntiAircraftGun.Height);
_drawningAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü çåíèòêó"
private void ButtonCreateAntiAircraftGun_Click_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_drawningAircraftGun = new DrawningAircraftGun(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
_drawningAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawningAircraftGun == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawningAircraftGun.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawningAircraftGun.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawningAircraftGun.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawningAircraftGun.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
// Îáðàáîòêà íàæàòèÿ êíîïêè "Øàã"
private void ButtonStep_Click_Click(object sender, EventArgs e)
{
if (_drawningAircraftGun == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
abstractStrategy = comboBoxStrategy.SelectedIndex
switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (abstractStrategy == null)
{
return;
}
abstractStrategy.SetData(new DrawningObjectAircraftGun(_drawningAircraftGun), pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
}
if (abstractStrategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
abstractStrategy.MakeStep();
Draw();
if (abstractStrategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
abstractStrategy = null;
}
}
// Âûáîð çåíèòêè
private void ButtonSelectAircraftGun_Click_Click(object sender, EventArgs e)
{
SelectedAircraftGun = _drawningAircraftGun;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,43 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class AircraftGunCompareByColor : IComparer<DrawningAircraftGun?>
{
public int Compare(DrawningAircraftGun? x, DrawningAircraftGun? y)
{
if (x == null || x.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y == null || y.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(y));
}
if (x.EntityAircraftGun.BodyColor != y.EntityAircraftGun.BodyColor)
{
return x.EntityAircraftGun.BodyColor.Name.CompareTo(y.EntityAircraftGun.BodyColor.Name);
}
if (x.EntityAircraftGun is EntityAntiAircraftGun AntiAircraftGunX && y.EntityAircraftGun is EntityAntiAircraftGun AntiAircraftGunY)
{
var colorCompare = AntiAircraftGunX.AdditionalColor.Name.CompareTo(AntiAircraftGunY.AdditionalColor.Name);
if (colorCompare != 0)
{
return colorCompare;
}
}
var speedCompare = x.EntityAircraftGun.Speed.CompareTo(y.EntityAircraftGun.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityAircraftGun.Weight.CompareTo(y.EntityAircraftGun.Weight);
}
}
}

View File

@ -1,34 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class AircraftGunCompareByType : IComparer<DrawningAircraftGun?>
{
public int Compare(DrawningAircraftGun? x, DrawningAircraftGun? y)
{
if (x == null || x.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y == null || y.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(y));
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityAircraftGun.Speed.CompareTo(y.EntityAircraftGun.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityAircraftGun.Weight.CompareTo(y.EntityAircraftGun.Weight);
}
}
}

View File

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class AntiAircraftGunCollectionInfo : IEquatable<AntiAircraftGunCollectionInfo>
{
public string Name { get; private set; }
public string Description { get; private set; }
public AntiAircraftGunCollectionInfo(string name, string description)
{
Name = name;
Description = description;
}
public bool Equals(AntiAircraftGunCollectionInfo? other)
{
if (other == null || Name == null || other.Name == null)
{
return false;
}
if (Name == other.Name)
{
return true;
}
throw new NotImplementedException();
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
public override string ToString()
{
return Name;
}
}
}

View File

@ -1,106 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.MovementStrategy;
namespace AntiAircraftGun.Generics
{
internal class AntiAircraftGunsGenericCollection<T, U>
where T : DrawningAircraftGun
where U : IMoveableObject
{
private readonly int _pictureWidth;
private readonly int _pictureHeight;
// Размер занимаемого объектом места(ширина)
private readonly int _placeSizeWidth = 185;
// Размер занимаемого объектом места(высота)
private readonly int _placeSizeHeight = 128;
// Набор объектов
private readonly SetGeneric<T> _collection;
// Конструктор
public AntiAircraftGunsGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
// Перегрузка оператора сложения
public static bool operator +(AntiAircraftGunsGenericCollection<T, U> collect, T? obj)
{
if (obj == null)
{
return false;
}
return collect._collection.Insert(obj, new DrawningAircraftGunEqutables());
}
// Перегрузка оператора вычитания
public static T? operator -(AntiAircraftGunsGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection[pos];
collect._collection.Remove(pos);
return obj;
}
// Получение объекта IMoveableObject
public U? GetU(int pos)
{
return (U?)_collection[pos]?.GetMoveableObject;
}
// Вывод всего набора объектов
public Bitmap ShowAntiAircraftGuns()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
// Метод отрисовки фона
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; j++)
{
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
// Метод прорисовки объектов
private void DrawObjects(Graphics g)
{
int height = _pictureHeight / _placeSizeHeight;
int width = _pictureWidth / _placeSizeWidth;
int i = 0;
foreach (var antiaircraftgun in _collection.GetAntiAircraftGuns())
{
if (antiaircraftgun != null)
{
antiaircraftgun.SetPosition((i % width) * _placeSizeWidth, (i / height) * _placeSizeHeight);
antiaircraftgun.DrawZenitka(g);
}
i++;
}
}
// Получение объектов коллекции
public IEnumerable<T?> GetAntiAircraftGuns => _collection.GetAntiAircraftGuns();
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
}
}

View File

@ -1,146 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.MovementStrategy;
using AntiAircraftGun.DrawningObjects;
namespace AntiAircraftGun.Generics
{
internal class AntiAircraftGunsGenericStorage
{
// Словарь
readonly Dictionary<AntiAircraftGunCollectionInfo, AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun>> _aircraftgunStorages;
// Возвращение списка названий наборов
public List<AntiAircraftGunCollectionInfo> Keys => _aircraftgunStorages.Keys.ToList();
// Ширина окна отрисовки
private readonly int _pictureWidth;
// Высота окна отрисовки
private readonly int _pictureHeight;
// Разделитель для записи ключа и значения элемента словаря
private static readonly char _separatorForKeyValue = '|';
// Разделитель для записей коллекции данных в файл
private readonly char _separatorRecords = ';';
// Разделитель для записи информации по объекту в файл
private static readonly char _separatorForObject = ':';
// Конструктор
public AntiAircraftGunsGenericStorage(int pictureWidth, int pictureHeight)
{
_aircraftgunStorages = new Dictionary<AntiAircraftGunCollectionInfo, AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
// Добавление набора
public void AddSet(string name)
{
if(_aircraftgunStorages.ContainsKey(new AntiAircraftGunCollectionInfo(name, "")))
{
return;
}
_aircraftgunStorages[new AntiAircraftGunCollectionInfo(name, "")] = new AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun>(_pictureWidth, _pictureHeight);
}
// Удаление набора
public void DelSet(string name)
{
if (!_aircraftgunStorages.ContainsKey(new AntiAircraftGunCollectionInfo(name, "")))
{
return;
}
_aircraftgunStorages.Remove(new AntiAircraftGunCollectionInfo(name, ""));
}
// Доступ к набору
public AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun>?this[string ind]
{
get
{
var info = new AntiAircraftGunCollectionInfo(ind, "");
if(_aircraftgunStorages.ContainsKey(info))
{
return _aircraftgunStorages[info];
}
return null;
}
}
// Сохранение информации по зениткам в хранилище в файл
public bool SaveData(string filename)
{
if (File.Exists(filename))
{
File.Delete(filename);
}
StringBuilder data = new();
foreach (KeyValuePair<AntiAircraftGunCollectionInfo, AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun>> record in _aircraftgunStorages)
{
StringBuilder records = new();
foreach (DrawningAircraftGun? elem in record.Value.GetAntiAircraftGuns)
{
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
}
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
}
if (data.Length == 0)
{
throw new Exception("Невалидная операция, нет данных для сохранения");
}
using StreamWriter fs = new StreamWriter(filename);
string info = $"AircraftStorage{Environment.NewLine}{data}";
fs.Write(info, 0, info.Length);
return true;
}
// Загрузка информации по зениткам в хранилище из файла
public bool LoadData(string filename)
{
if (!File.Exists(filename))
{
throw new FileNotFoundException("Файл не найден");
}
using (StreamReader fs = new StreamReader(filename))
{
string str = fs.ReadLine();
if (str == null || str.Length == 0)
{
throw new NullReferenceException("Нет данных для загрузки");
}
if (!str.StartsWith("AircraftStorage"))
{
throw new FormatException("Неверный формат данных");
}
_aircraftgunStorages.Clear();
while ((str = fs.ReadLine()) != null)
{
string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 2)
{
continue;
}
AntiAircraftGunsGenericCollection<DrawningAircraftGun, DrawningObjectAircraftGun> collection = new(_pictureWidth, _pictureHeight);
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
DrawningAircraftGun? aircraftgun = elem?.CreateDrawningAircraftGun(_separatorForObject, _pictureWidth, _pictureHeight);
if (aircraftgun != null)
{
if (!(collection + aircraftgun))
{
throw new ApplicationException("Ошибка добавления в коллекцию");
}
}
}
_aircraftgunStorages.Add(new AntiAircraftGunCollectionInfo(record[0], ""), collection);
}
return true;
}
}
}
}

View File

@ -1,67 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class DrawningAircraftGunEqutables : IEqualityComparer<DrawningAircraftGun?>
{
public bool Equals(DrawningAircraftGun? x, DrawningAircraftGun? y)
{
if (x == null || x.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y == null || y.EntityAircraftGun == null)
{
throw new ArgumentNullException(nameof(y));
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityAircraftGun.Speed != y.EntityAircraftGun.Speed)
{
return false;
}
if (x.EntityAircraftGun.Weight != y.EntityAircraftGun.Weight)
{
return false;
}
if (x.EntityAircraftGun.BodyColor != y.EntityAircraftGun.BodyColor)
{
return false;
}
if (x is DrawingAntiAircraftGun && y is DrawingAntiAircraftGun)
{
if ((x.EntityAircraftGun as EntityAntiAircraftGun).Radar != (y.EntityAircraftGun as EntityAntiAircraftGun).Radar)
{
return false;
}
if ((x.EntityAircraftGun as EntityAntiAircraftGun).ZenitkaGun != (y.EntityAircraftGun as EntityAntiAircraftGun).ZenitkaGun)
{
return false;
}
if ((x.EntityAircraftGun as EntityAntiAircraftGun).Luke != (y.EntityAircraftGun as EntityAntiAircraftGun).Luke)
{
return false;
}
if ((x.EntityAircraftGun as EntityAntiAircraftGun).AdditionalColor != (y.EntityAircraftGun as EntityAntiAircraftGun).AdditionalColor)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningAircraftGun obj)
{
return obj.GetHashCode();
}
}
}

View File

@ -1,114 +0,0 @@
using AntiAircraftGun.DrawningObjects;
using AntiAircraftGun.Generics;
using AntiAircraftGun.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Exceptions;
namespace AntiAircraftGun.Generics
{
internal class SetGeneric<T>
where T : class
{
// Список
private readonly List<T?> _places;
// Кол-во объектов в списке
public int Count => _places.Count;
// Максимальное кол-во объектов в списке
private readonly int _maxCount;
// Конструктор
public SetGeneric(int Count)
{
_maxCount = Count;
_places = new List<T?>(Count);
}
// Добавление объекта в набор
public bool Insert(T antiaircraftgun, IEqualityComparer<T?>? equal = null)
{
return Insert(antiaircraftgun, 0, equal);
}
// Добавление объекта на конкретную позицию
public bool Insert(T antiaircraftgun, int position, IEqualityComparer<T?>? equal = null)
{
if (position < 0 || position >= _maxCount)
{
throw new AircraftGunNotFoundException(position);
}
if (Count >= _maxCount)
{
throw new StorageOverflowException(_maxCount);
}
if(equal != null)
{
foreach(var i in _places)
{
if (equal.Equals(i, antiaircraftgun))
{
throw new ApplicationException("Объект уже существует");
}
}
}
_places.Insert(position, antiaircraftgun);
return true;
}
// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if (position < 0 || position >= _maxCount)
{
return false;
}
if (_places[position] == null)
{
throw new AircraftGunNotFoundException(position);
}
_places[position] = null;
return true;
}
// Получение объекта из набора по позиции
public T? this[int position]
{
get
{
if (position < 0 || position >= Count)
{
return null;
}
return _places[position];
}
set
{
if (position < 0 || position >= Count)
{
return;
}
_places[position] = value;
}
}
// Проход по списку
public IEnumerable<T?> GetAntiAircraftGuns(int? maxAntiAircraftGuns = null)
{
for (int i = 0; i < _places.Count; i++)
{
yield return _places[i];
if (maxAntiAircraftGuns.HasValue && i == maxAntiAircraftGuns.Value)
{
yield break;
}
}
}
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
}
}

View File

@ -1,106 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.DrawningObjects;
namespace AntiAircraftGun.MovementStrategy
{
public abstract class AbstractStrategy
{
// Перемещаемый объект
private IMoveableObject? _moveableObject;
// Статус перемещения
private Status _state = Status.NotInit;
// Ширина поля
protected int FieldWidth { get; private set; }
// Высота поля
protected int FieldHeight { get; private set; }
// Статус перемещения
public Status GetStatus() { return _state; }
// Установка данных
public void SetData(IMoveableObject moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
// Шаг перемещения
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
// Перемещение влево
// результат перемещения(true - удалось, false - не удалось)
protected bool MoveLeft() => MoveTo(DirectionType.Left);
// Перемещение вправо
// результат перемещения(true - удалось, false - не удалось)
protected bool MoveRight() => MoveTo(DirectionType.Right);
// Перемещение вверх
// результат перемещения(true - удалось, false - не удалось)
protected bool MoveUp() => MoveTo(DirectionType.Up);
// Перемещение вниз
// результат перемещения(true - удалось, false - не удалось)
protected bool MoveDown() => MoveTo(DirectionType.Down);
// Параметры объекта
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
// Шаг объекта
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
// перемещение к цели
protected abstract void MoveToTarget();
protected abstract bool IsTargetDestinaion();
// Попытка перемещения в требуемом направлении
// Результат попытки(true - удалось, false - не удалось)
private bool MoveTo(DirectionType directionType)
{
if (_state != Status.InProgress)
{
return false;
}
if (_moveableObject?.CheckCanMove(directionType) ?? false)
{
_moveableObject.MoveObject(directionType);
return true;
}
return false;
}
}
}

View File

@ -1,39 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.DrawningObjects;
namespace AntiAircraftGun.MovementStrategy
{
// Реализация интерфейса IDrawningObject для работы с объектом DrawningCar (паттерн Adapter)
public class DrawningObjectAircraftGun : IMoveableObject
{
private readonly DrawningAircraftGun? _drawningAircraftGun = null;
public DrawningObjectAircraftGun(DrawningAircraftGun drawningAircraftGun)
{
_drawningAircraftGun = drawningAircraftGun;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawningAircraftGun == null || _drawningAircraftGun.EntityAircraftGun == null)
{
return null;
}
return new ObjectParameters(_drawningAircraftGun.GetPosX, _drawningAircraftGun.GetPosY, _drawningAircraftGun.GetWidth, _drawningAircraftGun.GetHeight);
}
}
public int GetStep => (int)(_drawningAircraftGun?.EntityAircraftGun?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => _drawningAircraftGun?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => _drawningAircraftGun?.MoveTransport(direction);
}
}

View File

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.DrawningObjects;
namespace AntiAircraftGun.MovementStrategy
{
// Интерфейс для работы с перемещаемым объектом
public interface IMoveableObject
{
// Поулчение координаты X объекта
ObjectParameters? GetObjectPosition { get; }
// Шаг объекта
int GetStep { get; }
// Првоерка, можно ли переместиться по нужному направлению
bool CheckCanMove(DirectionType direction);
// Изменение направления перемещения объекта
void MoveObject(DirectionType direction);
}
}

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.MovementStrategy
{
// Стратегия перемещения объекта в правый нижний угол экрана
public class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -1,55 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.MovementStrategy
{
// Стратегия перемещения объекта в центр экрана
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && objParams.ObjectMiddleVertical <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -1,39 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.MovementStrategy
{
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
// Левая граница
public int LeftBorder => _x;
// Верхняя граница
public int TopBorder => _y;
// Правая граница
public int RightBorder => _x + _width;
// Нижняя граница
public int DownBorder => _y + _height;
// Середина объекта
public int ObjectMiddleHorizontal => _x + _width / 2;
// Середина объекта
public int ObjectMiddleVertical => _y + _height / 2;
//Конструктор
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.MovementStrategy
{
//Статус выполнения операции перемещения
public enum Status
{
NotInit,
InProgress,
Finish
}
}

View File

@ -1,11 +1,3 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using System;
using System.IO;
using System.Windows.Forms;
namespace AntiAircraftGun
{
internal static class Program
@ -19,28 +11,7 @@ namespace AntiAircraftGun
// 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<FormAircraftGunCollection>());
}
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormAircraftGunCollection>().AddLogging(option =>
{
string[] path = Directory.GetCurrentDirectory().Split("\\");
string appPath = "";
for(int i = 0; i < path.Length - 3; i++)
{
appPath += path[i] + "\\";
}
var configuration = new ConfigurationBuilder().AddJsonFile($"{appPath}appsettings.json").Build();
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddSerilog(logger);
});
Application.Run(new Form1());
}
}
}

View File

@ -1,103 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AntiAircraftGun.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("AntiAircraftGun.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));
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

View File

@ -1,20 +0,0 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "logs/aircraftgunlog-.log",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Loco"
}
}
}