Compare commits

..

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

32 changed files with 71 additions and 2040 deletions

View File

@ -1,9 +1,9 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505 VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AntiAircraftGun", "AntiAircraftGun.csproj", "{40C43023-14E0-4146-82EE-7A5A7384992F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AntiAirCraftGun", "AntiAirCraftGun\AntiAirCraftGun.csproj", "{FB18B709-9154-45E0-8BD8-28822B29FB4B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{40C43023-14E0-4146-82EE-7A5A7384992F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FB18B709-9154-45E0-8BD8-28822B29FB4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40C43023-14E0-4146-82EE-7A5A7384992F}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB18B709-9154-45E0-8BD8-28822B29FB4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40C43023-14E0-4146-82EE-7A5A7384992F}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB18B709-9154-45E0-8BD8-28822B29FB4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40C43023-14E0-4146-82EE-7A5A7384992F}.Release|Any CPU.Build.0 = Release|Any CPU {FB18B709-9154-45E0-8BD8-28822B29FB4B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {990D8FF3-8567-49C7-90F4-1811AB7EB423} SolutionGuid = {EB48B08E-3934-47B3-94AF-DF58D18CDB32}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -8,19 +8,4 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

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

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Enitites;
using static System.Windows.Forms.AxHost;
namespace AntiAircraftGun.DrawingObjects
{
public class AdvancedDrawingAntiAirCraftGun : BaseDrawingAntiAirCraftGun
{
private Point[] points = new Point[4];
public AdvancedDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, Color dopColor, bool rocket,bool radar, int width, int height) :
base(speed, weight, bodyColor, additionalColor, width, height)
{
AntiAirСraftGun = new EntityAdvancedAntiAirCraftGun(speed, weight, bodyColor, additionalColor, dopColor, rocket,radar);
}
public override void DrawTransport(Graphics g)
{
if (AntiAirСraftGun is not EntityAdvancedAntiAirCraftGun advancedGun)
{
return;
}
Pen pen = new Pen(Color.Black);
Brush bodyBrush = new SolidBrush(AntiAirСraftGun.BodyColor);
Brush additionalBrush = new SolidBrush(AntiAirСraftGun.AdditionalColor);
base.DrawTransport(g);
Brush dopBrush = new SolidBrush(advancedGun.DopColor);
Pen dopPen = new Pen(advancedGun.DopColor);
if (advancedGun.Rocket)
{
points[0] = new Point(_startPosX, _startPosY + 30);
points[1] = new Point(_startPosX + 95, _startPosY + 5);
points[2] = new Point(_startPosX + 92, _startPosY);
points[3] = new Point(_startPosX, _startPosY + 25);
g.FillPolygon(dopBrush, points);
g.DrawPolygon(pen, points);
}
if (advancedGun.Radar)
{
g.DrawLine(dopPen, _startPosX + 105, _startPosY + 20, _startPosX +105, _startPosY + 5);
g.FillPie(dopBrush, _startPosX + 81, _startPosY-15, 30, 30, -45, 180);
g.DrawLine(dopPen, _startPosX + 98, _startPosY , _startPosX + 93, _startPosY + 10);
g.FillEllipse(dopBrush, _startPosX + 88, _startPosY -10, 10, 10);
}
}
}
}

View File

@ -1,149 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Enitites;
using AntiAircraftGun.MovementStrategy;
namespace AntiAircraftGun.DrawingObjects
{
public class BaseDrawingAntiAirCraftGun
{
public EntityAntiAirCraftGun? AntiAirСraftGun { get; protected set; }
private readonly int _pictureWidth;
private readonly int _pictureHeight;
protected int _startPosX;
protected int _startPosY;
protected int _zenitWidth = 110;
protected int _zenitHeight = 60;
public BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor);
}
protected BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int carWidth, int carHeight)
{
_pictureWidth = width;
_pictureHeight = height;
_zenitWidth = carWidth;
_zenitHeight = carHeight;
AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor);
}
public void SetPosition(int x, int y)
{
if (AntiAirСraftGun == null) return;
_startPosX = x;
_startPosY = y;
if (x < 0 || y < 0 || x + _zenitWidth >= _pictureWidth || y + _zenitHeight >= _pictureHeight)
{
_startPosX = 1;
_startPosY = 1;
}
}
/// <summary>
/// Координата X объекта
/// </summary>
public int GetPosX => _startPosX;
/// <summary>
/// Координата Y объекта
/// </summary>
public int GetPosY => _startPosY;
/// <summary>
/// Ширина объекта
/// </summary>
public int GetWidth => _zenitWidth;
/// <summary>
/// Высота объекта
/// </summary>
public int GetHeight => _zenitHeight;
/// <summary>
/// Проверка, что объект может переместится по указанному направлению
/// </summary>
/// <param name="direction">Направление</param>
/// <returns>true - можно переместится по указанному направлению</returns>
public bool CanMove(DirectionType direction)
{
if (AntiAirСraftGun == null)
{
return false;
}
return direction switch
{
//влево
DirectionType.Left => _startPosX - AntiAirСraftGun.Step > 0,
//вверх
DirectionType.Up => _startPosY - AntiAirСraftGun.Step > 0,
// вправо
DirectionType.Right =>_startPosX + AntiAirСraftGun.Step + _zenitWidth < _pictureWidth,
//вниз
DirectionType.Down => _startPosY + AntiAirСraftGun.Step + _zenitHeight< _pictureHeight,
_ => false,
};
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MoveTransport(DirectionType direction)
{
if (!CanMove(direction) || AntiAirСraftGun == null)
{
return;
}
switch (direction)
{
//влево
case DirectionType.Left:
_startPosX -= (int)AntiAirСraftGun.Step;
break;
//вверх
case DirectionType.Up:
_startPosY -= (int)AntiAirСraftGun.Step;
break;
// вправо
case DirectionType.Right:
_startPosX += (int)AntiAirСraftGun.Step;
break;
//вниз
case DirectionType.Down:
_startPosY += (int)AntiAirСraftGun.Step;
break;
}
}
public virtual void DrawTransport(Graphics g)
{
Pen pen = Pens.Black;
Brush bodyBrush = new SolidBrush(AntiAirСraftGun.BodyColor);
Brush additionalBrush = new SolidBrush(AntiAirСraftGun.AdditionalColor);
g.FillEllipse(additionalBrush, _startPosX, _startPosY + 40, 110, 10);
g.DrawEllipse(pen, _startPosX, _startPosY + 40, 110, 10);
g.FillRectangle(bodyBrush, _startPosX, _startPosY + 30, 110, 10);
g.DrawRectangle(pen, _startPosX, _startPosY + 30, 110, 10);
g.FillRectangle(bodyBrush, _startPosX + 80, _startPosY + 10, 30, 20);
g.DrawRectangle(pen, _startPosX + 80, _startPosY + 10, 30, 20);
for (int i = 0; i < 4; i++)
{
Rectangle trackRect = new Rectangle(_startPosX + 20 + i * 19, _startPosY + 40, 10, 10);
g.DrawEllipse(pen, trackRect);
g.FillEllipse(Brushes.Black, trackRect);
}
}
/// <summary>
/// Получение объекта IMoveableObject из объекта DrawningCar
/// </summary>
public IMoveableObject GetMoveableObject => new DrawingObjectAntiAirCraftGun(this);
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Enitites
{
public class EntityAdvancedAntiAirCraftGun : EntityAntiAirCraftGun
{
public Color DopColor { get; private set; }
public bool Rocket { get; private set; }
public bool Radar { get; private set; }
public EntityAdvancedAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor,Color dopColor, bool rocket, bool radar)
: base(speed, weight, bodyColor, additionalColor)
{
DopColor = dopColor;
Rocket = rocket;
Radar = radar;
}
}
}

View File

@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Enitites
{
public class EntityAntiAirCraftGun
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public double Step => (double)Speed * 100 / Weight;
/// <summary>
/// Конструктор с параметрами
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Основной цвет</param>
public EntityAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
}
}
}

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"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="strelkaDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\strelkaDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="strelkaTop" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\strelkaTop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="strelkaLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\strelkaLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="strelkaRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\strelkaRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@ -1,193 +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.pictureBoxAntiAircraftGun = new System.Windows.Forms.PictureBox();
this.CreateAdavancedAntiAirCraftGun = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
this.CreateAntiAirCraftGun = new System.Windows.Forms.Button();
this.Step = new System.Windows.Forms.Button();
this.ButtonSelectZenit = new System.Windows.Forms.Button();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).BeginInit();
this.SuspendLayout();
//
// 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(1491, 628);
this.pictureBoxAntiAircraftGun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAntiAircraftGun.TabIndex = 0;
this.pictureBoxAntiAircraftGun.TabStop = false;
//
// CreateAdavancedAntiAirCraftGun
//
this.CreateAdavancedAntiAirCraftGun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.CreateAdavancedAntiAirCraftGun.Location = new System.Drawing.Point(32, 577);
this.CreateAdavancedAntiAirCraftGun.Name = "CreateAdavancedAntiAirCraftGun";
this.CreateAdavancedAntiAirCraftGun.Size = new System.Drawing.Size(183, 23);
this.CreateAdavancedAntiAirCraftGun.TabIndex = 1;
this.CreateAdavancedAntiAirCraftGun.Text = "Создать с дополнениями";
this.CreateAdavancedAntiAirCraftGun.UseVisualStyleBackColor = true;
this.CreateAdavancedAntiAirCraftGun.Click += new System.EventHandler(this.CreateAdvancedAintiAirCraftGun_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.strelkaLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonLeft.Location = new System.Drawing.Point(1265, 562);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 2;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// 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.strelkaTop;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonUp.Location = new System.Drawing.Point(1301, 526);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.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.strelkaRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonRight.Location = new System.Drawing.Point(1337, 562);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 4;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::AntiAircraftGun.Properties.Resources.strelkaDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonDown.Location = new System.Drawing.Point(1301, 562);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 5;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// 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(1244, 28);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(170, 23);
this.comboBoxStrategy.TabIndex = 6;
//
// CreateAntiAirCraftGun
//
this.CreateAntiAirCraftGun.Location = new System.Drawing.Point(221, 577);
this.CreateAntiAirCraftGun.Name = "CreateAntiAirCraftGun";
this.CreateAntiAirCraftGun.Size = new System.Drawing.Size(185, 23);
this.CreateAntiAirCraftGun.TabIndex = 7;
this.CreateAntiAirCraftGun.Text = "Создать обычный";
this.CreateAntiAirCraftGun.UseVisualStyleBackColor = true;
this.CreateAntiAirCraftGun.Click += new System.EventHandler(this.CreateAntiAirCraftGun_Click);
//
// Step
//
this.Step.Location = new System.Drawing.Point(1323, 61);
this.Step.Name = "Step";
this.Step.Size = new System.Drawing.Size(75, 23);
this.Step.TabIndex = 8;
this.Step.Text = "Шаг";
this.Step.UseVisualStyleBackColor = true;
this.Step.Click += new System.EventHandler(this.ButtonStep_Click);
//
// ButtonSelectZenit
//
this.ButtonSelectZenit.Location = new System.Drawing.Point(412, 577);
this.ButtonSelectZenit.Name = "ButtonSelectZenit";
this.ButtonSelectZenit.Size = new System.Drawing.Size(157, 23);
this.ButtonSelectZenit.TabIndex = 9;
this.ButtonSelectZenit.Text = "Выбрать объект";
this.ButtonSelectZenit.UseVisualStyleBackColor = true;
this.ButtonSelectZenit.Click += new System.EventHandler(this.ButtonSelectZenit_Click);
//
// FormAntiAirCraftGun
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1491, 628);
this.Controls.Add(this.ButtonSelectZenit);
this.Controls.Add(this.Step);
this.Controls.Add(this.CreateAntiAirCraftGun);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.CreateAdavancedAntiAirCraftGun);
this.Controls.Add(this.pictureBoxAntiAircraftGun);
this.Name = "FormAntiAirCraftGun";
this.Text = "FormAntiAirCraftGun";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxAntiAircraftGun;
private Button CreateAdavancedAntiAirCraftGun;
private Button buttonLeft;
private Button buttonUp;
private Button buttonRight;
private Button buttonDown;
private ComboBox comboBoxStrategy;
private Button CreateAntiAirCraftGun;
private Button Step;
private Button ButtonSelectZenit;
private ColorDialog colorDialog1;
}
}

View File

@ -1,149 +0,0 @@
using AntiAircraftGun.DrawingObjects;
using AntiAircraftGun.MovementStrategy;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace AntiAircraftGun
{
public partial class FormAntiAirCraftGun : Form
{
private BaseDrawingAntiAirCraftGun _drawingAntiAirCraftGun;
private AbstractStrategy? _abstractStrategy;
public BaseDrawingAntiAirCraftGun? SelectedZenit { get; private set; }
public FormAntiAirCraftGun()
{
InitializeComponent();
_abstractStrategy = null;
SelectedZenit = null;
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawingAntiAirCraftGun == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawingAntiAirCraftGun.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
private void Draw()
{
if (_drawingAntiAirCraftGun == null)
{
return;
}
Bitmap bmp = new Bitmap(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingAntiAirCraftGun.DrawTransport(gr);
pictureBoxAntiAircraftGun.Image = bmp;
}
private void CreateAdvancedAintiAirCraftGun_Click(object sender, EventArgs e)
{
Random random = new Random();
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); // Îñíîâíîé öâåò
Color additionalColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); // Äîï. öâåò äëÿ EntityAdvancedAntiAircraftGun
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
bodyColor = dialog.Color;
if (dialog.ShowDialog() == DialogResult.OK)
dopColor = dialog.Color;
_drawingAntiAirCraftGun = new AdvancedDrawingAntiAirCraftGun(
random.Next(100, 300), // Ñêîðîñòü
random.Next(1000, 3000), // Âåñ
bodyColor, additionalColor, dopColor,
Convert.ToBoolean(random.Next(2)), // Rocket
Convert.ToBoolean(random.Next(2)),
pictureBoxAntiAircraftGun.Width,
pictureBoxAntiAircraftGun.Height
);
_drawingAntiAirCraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void CreateAntiAirCraftGun_Click(object sender, EventArgs e)
{
Random random = new Random();
Color bodyColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); // Îñíîâíîé öâåò
Color additionalColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); // Äîï. öâåò
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
bodyColor = dialog.Color;
}
_drawingAntiAirCraftGun = new BaseDrawingAntiAirCraftGun(
random.Next(100, 300), // Ñêîðîñòü
random.Next(1000, 3000), // Âåñ
bodyColor, additionalColor,
pictureBoxAntiAircraftGun.Width,
pictureBoxAntiAircraftGun.Height
);
_drawingAntiAirCraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void ButtonStep_Click(object sender, EventArgs e)
{
if (_drawingAntiAirCraftGun == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_abstractStrategy = comboBoxStrategy.SelectedIndex
switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.SetData(new
DrawingObjectAntiAirCraftGun(_drawingAntiAirCraftGun), pictureBoxAntiAircraftGun.Width,
pictureBoxAntiAircraftGun.Height);
comboBoxStrategy.Enabled = false;
}
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.MakeStep();
Draw();
if (_abstractStrategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_abstractStrategy = null;
}
}
private void ButtonSelectZenit_Click(object sender, EventArgs e)
{
SelectedZenit = _drawingAntiAirCraftGun;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -1,63 +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="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,186 +0,0 @@
namespace AntiAircraftGun
{
partial class FormAntiAirCraftGunCollection
{
/// <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.panelTools = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.textBoxStorageName = new System.Windows.Forms.TextBox();
this.listBoxStorages = new System.Windows.Forms.ListBox();
this.buttonAddCollection = new System.Windows.Forms.Button();
this.buttonDelCollection = new System.Windows.Forms.Button();
this.maskedTextBoxNumber = new System.Windows.Forms.TextBox();
this.buttonUpdateColletion = new System.Windows.Forms.Button();
this.buttonDeleteZenit = new System.Windows.Forms.Button();
this.buttonAddZenit = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.panelTools.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxCollection
//
this.pictureBoxCollection.Location = new System.Drawing.Point(12, 12);
this.pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.Size = new System.Drawing.Size(711, 571);
this.pictureBoxCollection.TabIndex = 0;
this.pictureBoxCollection.TabStop = false;
//
// panelTools
//
this.panelTools.Controls.Add(this.panel1);
this.panelTools.Controls.Add(this.maskedTextBoxNumber);
this.panelTools.Controls.Add(this.buttonUpdateColletion);
this.panelTools.Controls.Add(this.buttonDeleteZenit);
this.panelTools.Controls.Add(this.buttonAddZenit);
this.panelTools.Location = new System.Drawing.Point(729, 14);
this.panelTools.Name = "panelTools";
this.panelTools.Size = new System.Drawing.Size(234, 568);
this.panelTools.TabIndex = 1;
this.panelTools.Tag = "";
//
// panel1
//
this.panel1.Controls.Add(this.textBoxStorageName);
this.panel1.Controls.Add(this.listBoxStorages);
this.panel1.Controls.Add(this.buttonAddCollection);
this.panel1.Controls.Add(this.buttonDelCollection);
this.panel1.Location = new System.Drawing.Point(15, 52);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(215, 294);
this.panel1.TabIndex = 8;
this.panel1.Tag = "Наборы";
//
// textBoxStorageName
//
this.textBoxStorageName.Location = new System.Drawing.Point(12, 53);
this.textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.Size = new System.Drawing.Size(193, 23);
this.textBoxStorageName.TabIndex = 7;
//
// listBoxStorages
//
this.listBoxStorages.FormattingEnabled = true;
this.listBoxStorages.ItemHeight = 15;
this.listBoxStorages.Location = new System.Drawing.Point(12, 137);
this.listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.Size = new System.Drawing.Size(191, 94);
this.listBoxStorages.TabIndex = 6;
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged);
//
// buttonAddCollection
//
this.buttonAddCollection.Location = new System.Drawing.Point(10, 92);
this.buttonAddCollection.Name = "buttonAddCollection";
this.buttonAddCollection.Size = new System.Drawing.Size(193, 40);
this.buttonAddCollection.TabIndex = 5;
this.buttonAddCollection.Text = "Добавить набор";
this.buttonAddCollection.UseVisualStyleBackColor = true;
this.buttonAddCollection.Click += new System.EventHandler(this.ButtonAddObject_Click);
//
// buttonDelCollection
//
this.buttonDelCollection.Location = new System.Drawing.Point(12, 249);
this.buttonDelCollection.Name = "buttonDelCollection";
this.buttonDelCollection.Size = new System.Drawing.Size(193, 40);
this.buttonDelCollection.TabIndex = 4;
this.buttonDelCollection.Text = "Удалить набор";
this.buttonDelCollection.UseVisualStyleBackColor = true;
this.buttonDelCollection.Click += new System.EventHandler(this.ButtonDelObject_Click);
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Location = new System.Drawing.Point(23, 435);
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(193, 23);
this.maskedTextBoxNumber.TabIndex = 3;
//
// buttonUpdateColletion
//
this.buttonUpdateColletion.Location = new System.Drawing.Point(23, 525);
this.buttonUpdateColletion.Name = "buttonUpdateColletion";
this.buttonUpdateColletion.Size = new System.Drawing.Size(193, 40);
this.buttonUpdateColletion.TabIndex = 2;
this.buttonUpdateColletion.Text = "Обновить коллекцию";
this.buttonUpdateColletion.UseVisualStyleBackColor = true;
this.buttonUpdateColletion.Click += new System.EventHandler(this.ButtonUpdateCollection_Click);
//
// buttonDeleteZenit
//
this.buttonDeleteZenit.Location = new System.Drawing.Point(23, 464);
this.buttonDeleteZenit.Name = "buttonDeleteZenit";
this.buttonDeleteZenit.Size = new System.Drawing.Size(193, 40);
this.buttonDeleteZenit.TabIndex = 1;
this.buttonDeleteZenit.Text = "Удалить объект";
this.buttonDeleteZenit.UseVisualStyleBackColor = true;
this.buttonDeleteZenit.Click += new System.EventHandler(this.ButtonDeleteZenit_Click);
//
// buttonAddZenit
//
this.buttonAddZenit.Location = new System.Drawing.Point(23, 389);
this.buttonAddZenit.Name = "buttonAddZenit";
this.buttonAddZenit.Size = new System.Drawing.Size(193, 40);
this.buttonAddZenit.TabIndex = 0;
this.buttonAddZenit.Text = "Добавить объект";
this.buttonAddZenit.UseVisualStyleBackColor = true;
this.buttonAddZenit.Click += new System.EventHandler(this.ButtonAddZenit_Click);
//
// FormAntiAirCraftGunCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(971, 595);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.pictureBoxCollection);
this.Name = "FormAntiAirCraftGunCollection";
this.Text = "FormAntiAirCraftGunCollection";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
this.panelTools.ResumeLayout(false);
this.panelTools.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxCollection;
private Panel panelTools;
private TextBox maskedTextBoxNumber;
private Button buttonUpdateColletion;
private Button buttonDeleteZenit;
private Button buttonAddZenit;
private Panel panel1;
private TextBox textBoxStorageName;
private ListBox listBoxStorages;
private Button buttonAddCollection;
private Button buttonDelCollection;
}
}

View File

@ -1,166 +0,0 @@
using AntiAircraftGun.DrawingObjects;
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;
namespace AntiAircraftGun
{
public partial class FormAntiAirCraftGunCollection : Form
{
private readonly AntiAirCraftGunGenericStorage _storage;
public FormAntiAirCraftGunCollection()
{
InitializeComponent();
_storage = new AntiAirCraftGunGenericStorage(pictureBoxCollection.Width,pictureBoxCollection.Height);
}
/// <summary>
/// Заполнение listBoxObjects
/// </summary>
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;
}
}
/// <summary>
/// Добавление набора в коллекцию
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddObject_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
}
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender,
EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowZenits();
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonDelObject_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить объект{ listBoxStorages.SelectedItem}?", "Удаление",
MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
?? string.Empty);
ReloadObjects();
}
}
private void ButtonAddZenit_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
MessageBox.Show("Выберите набор в списке.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
MessageBox.Show("Выбранный набор не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
FormAntiAirCraftGun form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (obj + form.SelectedZenit)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowZenits();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void ButtonDeleteZenit_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (obj - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowZenits();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonUpdateCollection_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.ShowZenits();
}
}
}

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,172 +0,0 @@
using AntiAircraftGun.DrawingObjects;
using AntiAircraftGun.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class AntiAirCraftGunGenericCollection<T,U>
where T : BaseDrawingAntiAirCraftGun
where U : IMoveableObject
{
/// <summary>
/// Ширина окна прорисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна прорисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 90;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetGeneric<T> _collection;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
public AntiAirCraftGunGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static bool operator +(AntiAirCraftGunGenericCollection<T,U> collect, T? obj)
{
if (obj == null)
return false;
return collect?._collection.Insert(obj) ?? false;
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static T? operator -(AntiAirCraftGunGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
collect._collection.Remove(pos);
return obj;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public U? GetU(int pos)
{
return (U?)_collection[pos]?.GetMoveableObject;
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowZenits()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
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);
}
}
/// <summary>
/// Метод прорисовки объектов
/// </summary>
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
int x = 0; // Начальная координата X
int y = 0; // Начальная координата Y
int maxX = _pictureWidth; // Максимальное значение X, при достижении которого будет ошибка
int maxY = _pictureHeight; // Максимальное значение Y, когда нужно изменить X
int distance_between_objects = _placeSizeHeight;
foreach (var zenit in _collection.GetZenits())
{
// TODO: Получение объекта
T? obj = zenit;
if (obj != null)
{
// Проверяем, если X достигло максимума, выводим ошибку
if (x >= maxX)
{
MessageBox.Show("Не хватает места для объекта.");
break;
}
// Устанавливаем позицию
obj.SetPosition(x, y + 10);
// TODO: Прорисовка объекта
obj.DrawTransport(g);
// Увеличиваем координату Y для следующего объекта
y += distance_between_objects;
// Проверяем, если Y достигло максимума, изменяем X и сбрасываем Y
if (y + distance_between_objects >= maxY)
{
y = 0;
x += _placeSizeWidth;
}
}
if (obj == null)
{
// Увеличиваем координату Y для следующего объекта
y += distance_between_objects;
// Проверяем, если Y достигло максимума, изменяем X и сбрасываем Y
if (y+distance_between_objects >= maxY)
{
y = 0;
x += _placeSizeWidth;
}
};
}
}
}
}

View File

@ -1,95 +0,0 @@
using AntiAircraftGun.DrawingObjects;
using AntiAircraftGun.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
/// <summary>
/// Класс для хранения коллекции
/// </summary>
internal class AntiAirCraftGunGenericStorage
{
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, AntiAirCraftGunGenericCollection<BaseDrawingAntiAirCraftGun, DrawingObjectAntiAirCraftGun>> _zenitStorages;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
public List<string> Keys => _zenitStorages.Keys.ToList();
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public AntiAirCraftGunGenericStorage(int pictureWidth, int pictureHeight)
{
_zenitStorages = new Dictionary<string, AntiAirCraftGunGenericCollection<BaseDrawingAntiAirCraftGun, DrawingObjectAntiAirCraftGun>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление набора
/// </summary>
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
// TODO: Прописать логику для добавления набора
if (_zenitStorages.ContainsKey(name))
{
MessageBox.Show("Набор с таким именем уже существует");
return;
}
_zenitStorages.Add(name, new AntiAirCraftGunGenericCollection<BaseDrawingAntiAirCraftGun, DrawingObjectAntiAirCraftGun>(_pictureWidth, _pictureHeight));
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="name">Название набора</param>
public void DelSet(string name)
{
// TODO: Прописать логику для удаления набора
if (_zenitStorages.ContainsKey(name) == null)
{
return;
}
_zenitStorages.Remove(name);
}
/// <summary>
/// Доступ к набору
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public AntiAirCraftGunGenericCollection<BaseDrawingAntiAirCraftGun, DrawingObjectAntiAirCraftGun>?
this[string ind]
{
get
{
// TODO: Продумать логику получения набора
if (_zenitStorages.ContainsKey(ind))
{
return _zenitStorages[ind];
}
else
{
return null;
}
}
}
}
}

View File

@ -1,115 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun.Generics
{
internal class SetGeneric<T>
where T : class
{
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private readonly List<T?> _places;
/// <summary>
/// Количество объектов в списке
/// </summary>
public int Count => _places.Count;
/// <summary>
/// Максимальное количество объектов в списке
/// </summary>
private readonly int _maxCount;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="count"></param>
public SetGeneric(int count)
{
_maxCount = count;
_places = new List<T?>(count);
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <returns></returns>
public bool Insert(T car)
{
if (_places.Count == _maxCount)
return false;
Insert(car, 0);
return true;
}
public bool Insert(T car, int position)
{
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
return false;
_places.Insert(position, car);
return true;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
{
// Проверка позиции
if (position < 0 || position >= Count)
return false;
_places.RemoveAt(position);
return true;
}
/// <summary>
/// Получение объекта из набора по позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public T? this[int position]
{
get
{
if (!(position >= 0 && position < Count))
return null;
return _places[position];
}
set
{
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
return;
_places.Insert(position, value);
return;
}
}
/// <summary>
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetZenits(int? maxCars = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxCars.HasValue && i == maxCars.Value)
{
yield break;
}
}
}
public T? Get(int position)
{
if (position < 0 || position >= Count)
{
// Позиция находится за пределами допустимого диапазона, вернем null
return null;
}
return _places[position];
}
}
}

View File

@ -1,132 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AntiAircraftGun.MovementStrategy
{
public abstract class AbstractStrategy
{
/// <summary>
/// Перемещаемый объект
/// </summary>
private IMoveableObject? _moveableObject;
/// <summary>
/// Статус перемещения
/// </summary>
private Status _state = Status.NotInit;
/// <summary>
/// Ширина поля
/// </summary>
protected int FieldWidth { get; private set; }
/// <summary>
/// Высота поля
/// </summary>
protected int FieldHeight { get; private set; }
/// <summary>
/// Статус перемещения
/// </summary>
public Status GetStatus() { return _state; }
/// <summary>
/// Установка данных
/// </summary>
/// <param name="moveableObject">Перемещаемый объект</param>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
public void SetData(IMoveableObject moveableObject, int width, int
height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
/// <summary>
/// Шаг перемещения
/// </summary>
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
/// <summary>
/// Перемещение влево
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveLeft() => MoveTo(DirectionType.Left);
/// <summary>
/// Перемещение вправо
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться,false - неудача)</returns>
protected bool MoveRight() => MoveTo(DirectionType.Right);
/// <summary>
/// Перемещение вверх
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveUp() => MoveTo(DirectionType.Up);
/// <summary>
/// Перемещение вниз
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveDown() => MoveTo(DirectionType.Down);
/// <summary>
/// Параметры объекта
/// </summary>
protected ObjectParameters? GetObjectParameters =>
_moveableObject?.GetObjectPosition;
/// <summary>
/// Шаг объекта
/// </summary>
/// <returns></returns>
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
/// <summary>
/// Перемещение к цели
/// </summary>
protected abstract void MoveToTarget();
/// <summary>
/// Достигнута ли цель
/// </summary>
/// <returns></returns>
protected abstract bool IsTargetDestinaion();
/// <summary>
/// Попытка перемещения в требуемом направлении
/// </summary>
/// <param name="directionType">Направление</param>
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
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,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.DrawingObjects;
namespace AntiAircraftGun.MovementStrategy
{
public class DrawingObjectAntiAirCraftGun : IMoveableObject
{
private readonly BaseDrawingAntiAirCraftGun? _drawningAntiAirCraftGun = null;
public DrawingObjectAntiAirCraftGun(BaseDrawingAntiAirCraftGun drawningCar)
{
_drawningAntiAirCraftGun = drawningCar;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawningAntiAirCraftGun == null || _drawningAntiAirCraftGun.AntiAirСraftGun ==
null)
{
return null;
}
return new ObjectParameters(_drawningAntiAirCraftGun.GetPosX,
_drawningAntiAirCraftGun.GetPosY, _drawningAntiAirCraftGun.GetWidth, _drawningAntiAirCraftGun.GetHeight);
}
}
public int GetStep => (int)(_drawningAntiAirCraftGun?.AntiAirСraftGun?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) =>
_drawningAntiAirCraftGun?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) =>
_drawningAntiAirCraftGun?.MoveTransport(direction);
}
}

View File

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

View File

@ -1,59 +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.RightBorder - FieldWidth;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.DownBorder - FieldHeight;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -1,56 +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,54 +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;
/// <summary>
/// Левая граница
/// </summary>
public int LeftBorder => _x;
/// <summary>
/// Верхняя граница
/// </summary>
public int TopBorder => _y;
/// <summary>
/// Правая граница
/// </summary>
public int RightBorder => _x + _width;
/// <summary>
/// Нижняя граница
/// </summary>
public int DownBorder => _y + _height;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleHorizontal => _x + _width / 2;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleVertical => _y + _height / 2;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -1,15 +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,17 +1,17 @@
namespace AntiAircraftGun namespace AntiAirCraftGun
{ {
internal static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormAntiAirCraftGunCollection()); 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 strelkaDown {
get {
object obj = ResourceManager.GetObject("strelkaDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap strelkaLeft {
get {
object obj = ResourceManager.GetObject("strelkaLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap strelkaRight {
get {
object obj = ResourceManager.GetObject("strelkaRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap strelkaTop {
get {
object obj = ResourceManager.GetObject("strelkaTop", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB