Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 059c5c908e |
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
internal abstract class AbstractMap
|
||||
{
|
||||
private IDrawingObject _drawingObject = null;
|
||||
protected int[,] _map = null;
|
||||
@@ -202,45 +202,5 @@ namespace AirFighter
|
||||
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
|
||||
public bool Equals(AbstractMap? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var diffMap = other;
|
||||
if (diffMap == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (diffMap._height != _height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (diffMap._width != _width)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (diffMap._size_x != _size_x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (diffMap._size_y != _size_y )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
if (diffMap._map[i, j] != _map[j, i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class AircraftCompareByColor : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? x, IDrawingObject? y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xAircraft = x as DrawingObjectAircraft;
|
||||
var yAircraft = y as DrawingObjectAircraft;
|
||||
if (xAircraft == null && yAircraft == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xAircraft == null && yAircraft != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xAircraft != null && yAircraft == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xAircraft.GetAircraft.Plane.BodyColor.R.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.R) != 0)
|
||||
{
|
||||
return xAircraft.GetAircraft.Plane.BodyColor.R.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.R);
|
||||
}
|
||||
if (xAircraft.GetAircraft.Plane.BodyColor.G.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.G) != 0)
|
||||
{
|
||||
return xAircraft.GetAircraft.Plane.BodyColor.G.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.G);
|
||||
}
|
||||
if (xAircraft.GetAircraft.Plane.BodyColor.B.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.B) != 0)
|
||||
{
|
||||
return xAircraft.GetAircraft.Plane.BodyColor.B.CompareTo(yAircraft.GetAircraft.Plane.BodyColor.B);
|
||||
}
|
||||
|
||||
if (xAircraft.GetAircraft.Plane is EntityMilitaryAircraft xMilitaryAircraft && yAircraft.GetAircraft.Plane is EntityMilitaryAircraft yMilitaryAircraft)
|
||||
{
|
||||
if (xMilitaryAircraft.ExtraColor.R.CompareTo(yMilitaryAircraft.ExtraColor.R) != 0)
|
||||
{
|
||||
return xMilitaryAircraft.ExtraColor.R.CompareTo(yMilitaryAircraft.ExtraColor.R);
|
||||
}
|
||||
if (xMilitaryAircraft.ExtraColor.G.CompareTo(yMilitaryAircraft.ExtraColor.G) != 0)
|
||||
{
|
||||
return xMilitaryAircraft.ExtraColor.G.CompareTo(yMilitaryAircraft.ExtraColor.G);
|
||||
}
|
||||
if (xMilitaryAircraft.ExtraColor.B.CompareTo(yMilitaryAircraft.ExtraColor.B) != 0)
|
||||
{
|
||||
return xMilitaryAircraft.ExtraColor.B.CompareTo(yMilitaryAircraft.ExtraColor.B);
|
||||
}
|
||||
}
|
||||
|
||||
var speedCompare = xAircraft.GetAircraft.Plane.Speed.CompareTo(yAircraft.GetAircraft.Plane.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xAircraft.GetAircraft.Plane.Weight.CompareTo(yAircraft.GetAircraft.Plane.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class AircraftCompareByType : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? x, IDrawingObject? y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xAircraft = x as DrawingObjectAircraft;
|
||||
var yAircraft = y as DrawingObjectAircraft;
|
||||
if (xAircraft == null && yAircraft == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xAircraft == null && yAircraft != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xAircraft != null && yAircraft == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (xAircraft.GetAircraft.GetType().Name != yAircraft.GetAircraft.GetType().Name)
|
||||
{
|
||||
if (xAircraft.GetAircraft.GetType().Name == "DrawingAircraft")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var speedCompare = xAircraft.GetAircraft.Plane.Speed.CompareTo(yAircraft.GetAircraft.Plane.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xAircraft.GetAircraft.Plane.Weight.CompareTo(yAircraft.GetAircraft.Plane.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
public delegate void AircraftDelegate(DrawingAircraft aircraft);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class AircraftNotFoundException : ApplicationException
|
||||
{
|
||||
public AircraftNotFoundException() : base() { }
|
||||
public AircraftNotFoundException(string message) : base(message) { }
|
||||
public AircraftNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
public AircraftNotFoundException(SerializationInfo info, StreamingContext contex) : base(info,contex) { }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -238,11 +238,6 @@ namespace AirFighter
|
||||
|
||||
}
|
||||
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
(Plane as EntityAircraft).setColor(color);
|
||||
}
|
||||
|
||||
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _aircraftWidth - 1, _startPosY + _aircraftHeight - 1);
|
||||
|
||||
@@ -85,10 +85,5 @@ namespace AirFighter
|
||||
}
|
||||
}
|
||||
|
||||
public void SetExtraColor(Color color)
|
||||
{
|
||||
(Plane as EntityMilitaryAircraft).setColor(color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace AirFighter
|
||||
|
||||
public float Step => _aircraft.Plane?.Step ?? 0;
|
||||
|
||||
public DrawingAircraft GetAircraft => _aircraft;
|
||||
|
||||
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _aircraft?.GetCurrentPosition() ?? default;
|
||||
@@ -45,59 +43,6 @@ namespace AirFighter
|
||||
Random rnd = new Random();
|
||||
int x = rnd.Next(0, 10);
|
||||
}
|
||||
|
||||
public string ReceiveInfo() => _aircraft?.ReceiveDataForSaving();
|
||||
|
||||
public static IDrawingObject Create(string data) => new DrawingObjectAircraft(data.CreateDrawingAircraft());
|
||||
|
||||
public bool Equals(IDrawingObject? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var diffAircraft = other as DrawingObjectAircraft;
|
||||
if (diffAircraft == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var aircraft = _aircraft.Plane;
|
||||
var diffAircraftCast = diffAircraft._aircraft.Plane;
|
||||
if (aircraft.Speed != diffAircraftCast.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (aircraft.Weight != diffAircraftCast.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (aircraft.BodyColor != diffAircraftCast.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aircraft is EntityMilitaryAircraft || diffAircraftCast is EntityMilitaryAircraft)
|
||||
{
|
||||
if (aircraft is EntityMilitaryAircraft && diffAircraftCast is EntityMilitaryAircraft)
|
||||
{
|
||||
if ((aircraft as EntityMilitaryAircraft).ExtraColor != (diffAircraftCast as EntityMilitaryAircraft).ExtraColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((aircraft as EntityMilitaryAircraft).Rockets != (diffAircraftCast as EntityMilitaryAircraft).Rockets)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((aircraft as EntityMilitaryAircraft).ExtraWings != (diffAircraftCast as EntityMilitaryAircraft).ExtraWings)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,11 +35,6 @@ namespace AirFighter
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,5 @@ namespace AirFighter
|
||||
Rockets = rockets;
|
||||
ExtraWings = extraWings;
|
||||
}
|
||||
|
||||
public new void setColor(Color color)
|
||||
{
|
||||
ExtraColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal static class ExtensionAircraft
|
||||
{
|
||||
private static readonly char _separatorForObjects = ':';
|
||||
|
||||
public static DrawingAircraft CreateDrawingAircraft(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObjects);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingAircraft(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawingMilitaryAircraft(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string ReceiveDataForSaving(this DrawingAircraft drawingAircraft)
|
||||
{
|
||||
var aircraft = drawingAircraft.Plane;
|
||||
var str = $"{aircraft.Speed}{_separatorForObjects}{aircraft.Weight}{_separatorForObjects}{aircraft.BodyColor.Name}";
|
||||
if (aircraft is not EntityMilitaryAircraft militaryAircraft)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{_separatorForObjects}{militaryAircraft.ExtraColor.Name}{_separatorForObjects}{militaryAircraft.ExtraWings}{_separatorForObjects}{militaryAircraft.Rockets}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
375
AirFighter/FormAircraftConfig.Designer.cs
generated
375
AirFighter/FormAircraftConfig.Designer.cs
generated
@@ -1,375 +0,0 @@
|
||||
namespace AirFighter
|
||||
{
|
||||
partial class FormAircraftConfig
|
||||
{
|
||||
/// <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.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.labelMilitary = new System.Windows.Forms.Label();
|
||||
this.labelSimple = new System.Windows.Forms.Label();
|
||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelOrange = new System.Windows.Forms.Panel();
|
||||
this.panelAqua = 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.panelGold = new System.Windows.Forms.Panel();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.checkBoxExtraWings = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxRockets = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelExtraColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelMilitary);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimple);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxExtraWings);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxRockets);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(447, 245);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Config";
|
||||
//
|
||||
// labelMilitary
|
||||
//
|
||||
this.labelMilitary.AllowDrop = true;
|
||||
this.labelMilitary.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelMilitary.Location = new System.Drawing.Point(319, 177);
|
||||
this.labelMilitary.Name = "labelMilitary";
|
||||
this.labelMilitary.Size = new System.Drawing.Size(106, 33);
|
||||
this.labelMilitary.TabIndex = 8;
|
||||
this.labelMilitary.Text = "Military";
|
||||
this.labelMilitary.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelMilitary.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
|
||||
this.labelMilitary.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
|
||||
this.labelMilitary.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
|
||||
//
|
||||
// labelSimple
|
||||
//
|
||||
this.labelSimple.AllowDrop = true;
|
||||
this.labelSimple.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimple.Location = new System.Drawing.Point(191, 177);
|
||||
this.labelSimple.Name = "labelSimple";
|
||||
this.labelSimple.Size = new System.Drawing.Size(106, 33);
|
||||
this.labelSimple.TabIndex = 7;
|
||||
this.labelSimple.Text = "Simple";
|
||||
this.labelSimple.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimple.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
|
||||
this.labelSimple.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
|
||||
this.labelSimple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
this.groupBoxColors.Controls.Add(this.panelOrange);
|
||||
this.groupBoxColors.Controls.Add(this.panelAqua);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||
this.groupBoxColors.Controls.Add(this.panelGold);
|
||||
this.groupBoxColors.Controls.Add(this.panelPurple);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColors.Location = new System.Drawing.Point(197, 22);
|
||||
this.groupBoxColors.Name = "groupBoxColors";
|
||||
this.groupBoxColors.Size = new System.Drawing.Size(244, 142);
|
||||
this.groupBoxColors.TabIndex = 6;
|
||||
this.groupBoxColors.TabStop = false;
|
||||
this.groupBoxColors.Text = "Colors";
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
this.panelOrange.BackColor = System.Drawing.Color.Orange;
|
||||
this.panelOrange.Location = new System.Drawing.Point(184, 78);
|
||||
this.panelOrange.Name = "panelOrange";
|
||||
this.panelOrange.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelOrange.TabIndex = 7;
|
||||
this.panelOrange.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelAqua
|
||||
//
|
||||
this.panelAqua.BackColor = System.Drawing.Color.Aqua;
|
||||
this.panelAqua.Location = new System.Drawing.Point(184, 22);
|
||||
this.panelAqua.Name = "panelAqua";
|
||||
this.panelAqua.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelAqua.TabIndex = 3;
|
||||
this.panelAqua.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(128, 78);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelBlue.TabIndex = 6;
|
||||
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.YellowGreen;
|
||||
this.panelGreen.Location = new System.Drawing.Point(128, 22);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelGreen.TabIndex = 2;
|
||||
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(72, 78);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelRed.TabIndex = 5;
|
||||
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGold
|
||||
//
|
||||
this.panelGold.BackColor = System.Drawing.Color.Gold;
|
||||
this.panelGold.Location = new System.Drawing.Point(72, 22);
|
||||
this.panelGold.Name = "panelGold";
|
||||
this.panelGold.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelGold.TabIndex = 1;
|
||||
this.panelGold.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
this.panelPurple.Location = new System.Drawing.Point(16, 78);
|
||||
this.panelPurple.Name = "panelPurple";
|
||||
this.panelPurple.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelPurple.TabIndex = 4;
|
||||
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(16, 22);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(50, 50);
|
||||
this.panelBlack.TabIndex = 0;
|
||||
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// checkBoxExtraWings
|
||||
//
|
||||
this.checkBoxExtraWings.AutoSize = true;
|
||||
this.checkBoxExtraWings.Location = new System.Drawing.Point(16, 145);
|
||||
this.checkBoxExtraWings.Name = "checkBoxExtraWings";
|
||||
this.checkBoxExtraWings.Size = new System.Drawing.Size(145, 19);
|
||||
this.checkBoxExtraWings.TabIndex = 5;
|
||||
this.checkBoxExtraWings.Text = "Extra wings availability";
|
||||
this.checkBoxExtraWings.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRockets
|
||||
//
|
||||
this.checkBoxRockets.AutoSize = true;
|
||||
this.checkBoxRockets.Location = new System.Drawing.Point(16, 120);
|
||||
this.checkBoxRockets.Name = "checkBoxRockets";
|
||||
this.checkBoxRockets.Size = new System.Drawing.Size(121, 19);
|
||||
this.checkBoxRockets.TabIndex = 4;
|
||||
this.checkBoxRockets.Text = "Missile availability";
|
||||
this.checkBoxRockets.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(64, 73);
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(73, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(16, 75);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(48, 15);
|
||||
this.labelWeight.TabIndex = 2;
|
||||
this.labelWeight.Text = "Weight:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(64, 36);
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(73, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 1;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(16, 38);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(42, 15);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Speed:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(14, 44);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(188, 153);
|
||||
this.pictureBoxObject.TabIndex = 1;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.labelExtraColor);
|
||||
this.panelObject.Controls.Add(this.labelColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(474, 12);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(217, 210);
|
||||
this.panelObject.TabIndex = 2;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
|
||||
//
|
||||
// labelExtraColor
|
||||
//
|
||||
this.labelExtraColor.AllowDrop = true;
|
||||
this.labelExtraColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelExtraColor.Location = new System.Drawing.Point(114, 10);
|
||||
this.labelExtraColor.Name = "labelExtraColor";
|
||||
this.labelExtraColor.Size = new System.Drawing.Size(88, 31);
|
||||
this.labelExtraColor.TabIndex = 3;
|
||||
this.labelExtraColor.Text = "Extra color";
|
||||
this.labelExtraColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelExtraColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelExtraColor_DragDrop);
|
||||
this.labelExtraColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelExtraColor_DragEnter);
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.AllowDrop = true;
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(14, 10);
|
||||
this.labelColor.Name = "labelColor";
|
||||
this.labelColor.Size = new System.Drawing.Size(89, 31);
|
||||
this.labelColor.TabIndex = 2;
|
||||
this.labelColor.Text = "Main color";
|
||||
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);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(474, 228);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(103, 29);
|
||||
this.buttonAdd.TabIndex = 3;
|
||||
this.buttonAdd.Text = "Add";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(588, 228);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(103, 29);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormAircraftConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(708, 269);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormAircraftConfig";
|
||||
this.Text = "Aircraft creation";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private CheckBox checkBoxExtraWings;
|
||||
private CheckBox checkBoxRockets;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private Label labelWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelSpeed;
|
||||
private Label labelMilitary;
|
||||
private Label labelSimple;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelOrange;
|
||||
private Panel panelAqua;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Panel panelGold;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelExtraColor;
|
||||
private Label labelColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
public partial class FormAircraftConfig : Form
|
||||
{
|
||||
DrawingAircraft _aircraft = null;
|
||||
|
||||
private event AircraftDelegate EventAddAircraft;
|
||||
|
||||
public FormAircraftConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelAqua.MouseDown += PanelColor_MouseDown;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelGold.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelOrange.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||
}
|
||||
|
||||
private void DrawAircraft()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_aircraft?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_aircraft?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(AircraftDelegate ev)
|
||||
{
|
||||
if (EventAddAircraft == null)
|
||||
{
|
||||
EventAddAircraft = new AircraftDelegate(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddAircraft += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimple":
|
||||
{
|
||||
_aircraft = new DrawingAircraft((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
}
|
||||
break;
|
||||
case "labelMilitary":
|
||||
{
|
||||
_aircraft = new DrawingMilitaryAircraft((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White,Color.Black,checkBoxRockets.Checked,checkBoxExtraWings.Checked);
|
||||
}
|
||||
break;
|
||||
}
|
||||
DrawAircraft();
|
||||
}
|
||||
|
||||
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control).DoDragDrop((sender as Control).BackColor,DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
_aircraft.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawAircraft();
|
||||
}
|
||||
|
||||
private void labelExtraColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelExtraColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_aircraft is DrawingMilitaryAircraft)
|
||||
{
|
||||
(_aircraft as DrawingMilitaryAircraft).SetExtraColor((Color)e.Data.GetData(typeof(Color)));
|
||||
|
||||
}
|
||||
DrawAircraft();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddAircraft?.Invoke(_aircraft);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void label_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name,DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
292
AirFighter/FormMapWithSetAircrafts.Designer.cs
generated
292
AirFighter/FormMapWithSetAircrafts.Designer.cs
generated
@@ -29,41 +29,23 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.PanelGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.SortByColorButton = new System.Windows.Forms.Button();
|
||||
this.SortByTypeButton = new System.Windows.Forms.Button();
|
||||
this.MapsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.DeleteMapButton = new System.Windows.Forms.Button();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.AddMapButton = new System.Windows.Forms.Button();
|
||||
this.newMapTextBox = new System.Windows.Forms.TextBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.comboBoxMapSelection = new System.Windows.Forms.ComboBox();
|
||||
this.AddAircraftButton = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPostion = new System.Windows.Forms.MaskedTextBox();
|
||||
this.DeleteAircraftButton = new System.Windows.Forms.Button();
|
||||
this.ShowHangarButton = new System.Windows.Forms.Button();
|
||||
this.ShowMapButton = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.ShowMapButton = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.ShowHangarButton = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.DeleteAircraftButton = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPostion = new System.Windows.Forms.MaskedTextBox();
|
||||
this.AddAircraftButton = new System.Windows.Forms.Button();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.PanelGroupBox.SuspendLayout();
|
||||
this.MapsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PanelGroupBox
|
||||
//
|
||||
this.PanelGroupBox.Controls.Add(this.SortByColorButton);
|
||||
this.PanelGroupBox.Controls.Add(this.SortByTypeButton);
|
||||
this.PanelGroupBox.Controls.Add(this.MapsGroupBox);
|
||||
this.PanelGroupBox.Controls.Add(this.buttonDown);
|
||||
this.PanelGroupBox.Controls.Add(this.buttonRight);
|
||||
this.PanelGroupBox.Controls.Add(this.ShowMapButton);
|
||||
@@ -73,84 +55,23 @@
|
||||
this.PanelGroupBox.Controls.Add(this.DeleteAircraftButton);
|
||||
this.PanelGroupBox.Controls.Add(this.maskedTextBoxPostion);
|
||||
this.PanelGroupBox.Controls.Add(this.AddAircraftButton);
|
||||
this.PanelGroupBox.Controls.Add(this.comboBoxMapSelection);
|
||||
this.PanelGroupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.PanelGroupBox.Location = new System.Drawing.Point(672, 24);
|
||||
this.PanelGroupBox.Location = new System.Drawing.Point(600, 0);
|
||||
this.PanelGroupBox.Name = "PanelGroupBox";
|
||||
this.PanelGroupBox.Size = new System.Drawing.Size(218, 702);
|
||||
this.PanelGroupBox.Size = new System.Drawing.Size(200, 450);
|
||||
this.PanelGroupBox.TabIndex = 0;
|
||||
this.PanelGroupBox.TabStop = false;
|
||||
this.PanelGroupBox.Text = "Function panel";
|
||||
//
|
||||
// SortByColorButton
|
||||
// pictureBox
|
||||
//
|
||||
this.SortByColorButton.Location = new System.Drawing.Point(12, 339);
|
||||
this.SortByColorButton.Name = "SortByColorButton";
|
||||
this.SortByColorButton.Size = new System.Drawing.Size(176, 36);
|
||||
this.SortByColorButton.TabIndex = 17;
|
||||
this.SortByColorButton.Text = "Sort by color";
|
||||
this.SortByColorButton.UseVisualStyleBackColor = true;
|
||||
this.SortByColorButton.Click += new System.EventHandler(this.SortByColorButton_Click);
|
||||
//
|
||||
// SortByTypeButton
|
||||
//
|
||||
this.SortByTypeButton.Location = new System.Drawing.Point(12, 297);
|
||||
this.SortByTypeButton.Name = "SortByTypeButton";
|
||||
this.SortByTypeButton.Size = new System.Drawing.Size(176, 36);
|
||||
this.SortByTypeButton.TabIndex = 16;
|
||||
this.SortByTypeButton.Text = "Sort by type";
|
||||
this.SortByTypeButton.UseVisualStyleBackColor = true;
|
||||
this.SortByTypeButton.Click += new System.EventHandler(this.SortByTypeButton_Click);
|
||||
//
|
||||
// MapsGroupBox
|
||||
//
|
||||
this.MapsGroupBox.Controls.Add(this.DeleteMapButton);
|
||||
this.MapsGroupBox.Controls.Add(this.listBoxMaps);
|
||||
this.MapsGroupBox.Controls.Add(this.AddMapButton);
|
||||
this.MapsGroupBox.Controls.Add(this.newMapTextBox);
|
||||
this.MapsGroupBox.Controls.Add(this.comboBoxMapSelection);
|
||||
this.MapsGroupBox.Location = new System.Drawing.Point(6, 22);
|
||||
this.MapsGroupBox.Name = "MapsGroupBox";
|
||||
this.MapsGroupBox.Size = new System.Drawing.Size(188, 260);
|
||||
this.MapsGroupBox.TabIndex = 15;
|
||||
this.MapsGroupBox.TabStop = false;
|
||||
this.MapsGroupBox.Text = "Maps";
|
||||
//
|
||||
// DeleteMapButton
|
||||
//
|
||||
this.DeleteMapButton.Location = new System.Drawing.Point(6, 222);
|
||||
this.DeleteMapButton.Name = "DeleteMapButton";
|
||||
this.DeleteMapButton.Size = new System.Drawing.Size(176, 32);
|
||||
this.DeleteMapButton.TabIndex = 13;
|
||||
this.DeleteMapButton.Text = "Delete map";
|
||||
this.DeleteMapButton.UseVisualStyleBackColor = true;
|
||||
this.DeleteMapButton.Click += new System.EventHandler(this.DeleteMapButton_Click);
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 15;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(8, 122);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(174, 94);
|
||||
this.listBoxMaps.TabIndex = 12;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// AddMapButton
|
||||
//
|
||||
this.AddMapButton.Location = new System.Drawing.Point(6, 81);
|
||||
this.AddMapButton.Name = "AddMapButton";
|
||||
this.AddMapButton.Size = new System.Drawing.Size(176, 35);
|
||||
this.AddMapButton.TabIndex = 11;
|
||||
this.AddMapButton.Text = "Add map";
|
||||
this.AddMapButton.UseVisualStyleBackColor = true;
|
||||
this.AddMapButton.Click += new System.EventHandler(this.AddMapButton_Click);
|
||||
//
|
||||
// newMapTextBox
|
||||
//
|
||||
this.newMapTextBox.Location = new System.Drawing.Point(6, 22);
|
||||
this.newMapTextBox.Name = "newMapTextBox";
|
||||
this.newMapTextBox.Size = new System.Drawing.Size(176, 23);
|
||||
this.newMapTextBox.TabIndex = 10;
|
||||
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(600, 450);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// comboBoxMapSelection
|
||||
//
|
||||
@@ -159,17 +80,66 @@
|
||||
this.comboBoxMapSelection.Items.AddRange(new object[] {
|
||||
"1. Simple map",
|
||||
"2. NightSky map"});
|
||||
this.comboBoxMapSelection.Location = new System.Drawing.Point(6, 51);
|
||||
this.comboBoxMapSelection.Location = new System.Drawing.Point(6, 22);
|
||||
this.comboBoxMapSelection.Name = "comboBoxMapSelection";
|
||||
this.comboBoxMapSelection.Size = new System.Drawing.Size(176, 23);
|
||||
this.comboBoxMapSelection.Size = new System.Drawing.Size(182, 23);
|
||||
this.comboBoxMapSelection.TabIndex = 9;
|
||||
this.comboBoxMapSelection.SelectedIndexChanged += new System.EventHandler(this.comboBoxMapSelection_SelectedIndexChanged);
|
||||
//
|
||||
// AddAircraftButton
|
||||
//
|
||||
this.AddAircraftButton.Location = new System.Drawing.Point(6, 80);
|
||||
this.AddAircraftButton.Name = "AddAircraftButton";
|
||||
this.AddAircraftButton.Size = new System.Drawing.Size(182, 35);
|
||||
this.AddAircraftButton.TabIndex = 10;
|
||||
this.AddAircraftButton.Text = "Add aircraft";
|
||||
this.AddAircraftButton.UseVisualStyleBackColor = true;
|
||||
this.AddAircraftButton.Click += new System.EventHandler(this.AddAircraftButton_Click);
|
||||
//
|
||||
// maskedTextBoxPostion
|
||||
//
|
||||
this.maskedTextBoxPostion.Location = new System.Drawing.Point(6, 139);
|
||||
this.maskedTextBoxPostion.Mask = "00";
|
||||
this.maskedTextBoxPostion.Name = "maskedTextBoxPostion";
|
||||
this.maskedTextBoxPostion.Size = new System.Drawing.Size(182, 23);
|
||||
this.maskedTextBoxPostion.TabIndex = 11;
|
||||
//
|
||||
// DeleteAircraftButton
|
||||
//
|
||||
this.DeleteAircraftButton.Location = new System.Drawing.Point(6, 177);
|
||||
this.DeleteAircraftButton.Name = "DeleteAircraftButton";
|
||||
this.DeleteAircraftButton.Size = new System.Drawing.Size(182, 36);
|
||||
this.DeleteAircraftButton.TabIndex = 12;
|
||||
this.DeleteAircraftButton.Text = "Delete aircraft";
|
||||
this.DeleteAircraftButton.UseVisualStyleBackColor = true;
|
||||
this.DeleteAircraftButton.Click += new System.EventHandler(this.DeleteAircraftButton_Click);
|
||||
//
|
||||
// ShowHangarButton
|
||||
//
|
||||
this.ShowHangarButton.Location = new System.Drawing.Point(6, 258);
|
||||
this.ShowHangarButton.Name = "ShowHangarButton";
|
||||
this.ShowHangarButton.Size = new System.Drawing.Size(182, 30);
|
||||
this.ShowHangarButton.TabIndex = 13;
|
||||
this.ShowHangarButton.Text = "Show hangar";
|
||||
this.ShowHangarButton.UseVisualStyleBackColor = true;
|
||||
this.ShowHangarButton.Click += new System.EventHandler(this.ShowHangarButton_Click);
|
||||
//
|
||||
// ShowMapButton
|
||||
//
|
||||
this.ShowMapButton.Location = new System.Drawing.Point(6, 308);
|
||||
this.ShowMapButton.Name = "ShowMapButton";
|
||||
this.ShowMapButton.Size = new System.Drawing.Size(182, 36);
|
||||
this.ShowMapButton.TabIndex = 14;
|
||||
this.ShowMapButton.Text = "Show map";
|
||||
this.ShowMapButton.UseVisualStyleBackColor = true;
|
||||
this.ShowMapButton.Click += new System.EventHandler(this.ShowMapButton_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(99, 660);
|
||||
this.buttonDown.Location = new System.Drawing.Point(81, 408);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 11;
|
||||
@@ -181,155 +151,50 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(135, 660);
|
||||
this.buttonRight.Location = new System.Drawing.Point(117, 408);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 10;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ShowMapButton
|
||||
//
|
||||
this.ShowMapButton.Location = new System.Drawing.Point(12, 578);
|
||||
this.ShowMapButton.Name = "ShowMapButton";
|
||||
this.ShowMapButton.Size = new System.Drawing.Size(182, 36);
|
||||
this.ShowMapButton.TabIndex = 14;
|
||||
this.ShowMapButton.Text = "Show map";
|
||||
this.ShowMapButton.UseVisualStyleBackColor = true;
|
||||
this.ShowMapButton.Click += new System.EventHandler(this.ShowMapButton_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(63, 660);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(45, 408);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 9;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ShowHangarButton
|
||||
//
|
||||
this.ShowHangarButton.Location = new System.Drawing.Point(12, 542);
|
||||
this.ShowHangarButton.Name = "ShowHangarButton";
|
||||
this.ShowHangarButton.Size = new System.Drawing.Size(182, 30);
|
||||
this.ShowHangarButton.TabIndex = 13;
|
||||
this.ShowHangarButton.Text = "Show hangar";
|
||||
this.ShowHangarButton.UseVisualStyleBackColor = true;
|
||||
this.ShowHangarButton.Click += new System.EventHandler(this.ShowHangarButton_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(99, 624);
|
||||
this.buttonUp.Location = new System.Drawing.Point(81, 372);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 8;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// DeleteAircraftButton
|
||||
//
|
||||
this.DeleteAircraftButton.Location = new System.Drawing.Point(12, 500);
|
||||
this.DeleteAircraftButton.Name = "DeleteAircraftButton";
|
||||
this.DeleteAircraftButton.Size = new System.Drawing.Size(182, 36);
|
||||
this.DeleteAircraftButton.TabIndex = 12;
|
||||
this.DeleteAircraftButton.Text = "Delete aircraft";
|
||||
this.DeleteAircraftButton.UseVisualStyleBackColor = true;
|
||||
this.DeleteAircraftButton.Click += new System.EventHandler(this.DeleteAircraftButton_Click);
|
||||
//
|
||||
// maskedTextBoxPostion
|
||||
//
|
||||
this.maskedTextBoxPostion.Location = new System.Drawing.Point(12, 453);
|
||||
this.maskedTextBoxPostion.Mask = "00";
|
||||
this.maskedTextBoxPostion.Name = "maskedTextBoxPostion";
|
||||
this.maskedTextBoxPostion.Size = new System.Drawing.Size(182, 23);
|
||||
this.maskedTextBoxPostion.TabIndex = 11;
|
||||
//
|
||||
// AddAircraftButton
|
||||
//
|
||||
this.AddAircraftButton.Location = new System.Drawing.Point(12, 412);
|
||||
this.AddAircraftButton.Name = "AddAircraftButton";
|
||||
this.AddAircraftButton.Size = new System.Drawing.Size(182, 35);
|
||||
this.AddAircraftButton.TabIndex = 10;
|
||||
this.AddAircraftButton.Text = "Add aircraft";
|
||||
this.AddAircraftButton.UseVisualStyleBackColor = true;
|
||||
this.AddAircraftButton.Click += new System.EventHandler(this.AddAircraftButton_Click);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 24);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(672, 702);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(890, 24);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(100, 22);
|
||||
this.SaveToolStripMenuItem.Text = "Save";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(100, 22);
|
||||
this.LoadToolStripMenuItem.Text = "Load";
|
||||
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";
|
||||
//
|
||||
// FormMapWithSetAircrafts
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(890, 726);
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.PanelGroupBox);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormMapWithSetAircrafts";
|
||||
this.Text = "MapWithSelectedAircrafts";
|
||||
this.PanelGroupBox.ResumeLayout(false);
|
||||
this.PanelGroupBox.PerformLayout();
|
||||
this.MapsGroupBox.ResumeLayout(false);
|
||||
this.MapsGroupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -347,18 +212,5 @@
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private GroupBox MapsGroupBox;
|
||||
private Button DeleteMapButton;
|
||||
private ListBox listBoxMaps;
|
||||
private Button AddMapButton;
|
||||
private TextBox newMapTextBox;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem fileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button SortByColorButton;
|
||||
private Button SortByTypeButton;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -13,108 +12,73 @@ namespace AirFighter
|
||||
{
|
||||
public partial class FormMapWithSetAircrafts : Form
|
||||
{
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Simple map", new SimpleMap() },
|
||||
private MapWithSetAircraftsGeneric<DrawingObjectAircraft, AbstractMap> _mapAircraftsCollectionGeneric;
|
||||
|
||||
{"Nightsky map", new NightSkyMap()}
|
||||
};
|
||||
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public FormMapWithSetAircrafts(ILogger<FormMapWithSetAircrafts> logger)
|
||||
public FormMapWithSetAircrafts()
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||
comboBoxMapSelection.Items.Clear();
|
||||
foreach (var elem in _mapsDict)
|
||||
{
|
||||
comboBoxMapSelection.Items.Add(elem.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshMaps()
|
||||
{
|
||||
int index = listBoxMaps.SelectedIndex;
|
||||
|
||||
listBoxMaps.Items.Clear();
|
||||
|
||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||
{
|
||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||
}
|
||||
|
||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||
{
|
||||
listBoxMaps.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||
{
|
||||
listBoxMaps.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowMapButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
if (_mapAircraftsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
|
||||
private void comboBoxMapSelection_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxMapSelection.Text)
|
||||
{
|
||||
case "1. Simple map":
|
||||
{
|
||||
map = new SimpleMap();
|
||||
}
|
||||
break;
|
||||
case "2. NightSky map":
|
||||
{
|
||||
map = new NightSkyMap();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapAircraftsCollectionGeneric = new MapWithSetAircraftsGeneric<DrawingObjectAircraft, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapAircraftsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAircraftButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formAircraftConfig = new FormAircraftConfig();
|
||||
formAircraftConfig.AddEvent(new(AddAircraft));
|
||||
formAircraftConfig.Show();
|
||||
}
|
||||
|
||||
public void AddAircraft(DrawingAircraft aircraft)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
if (_mapAircraftsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
AirFighterForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectAircraft(aircraft) != -1)
|
||||
DrawingObjectAircraft aircraft = new(form.SelectedAircraft);
|
||||
if (_mapAircraftsCollectionGeneric + aircraft != -1)
|
||||
{
|
||||
MessageBox.Show("Object is added");
|
||||
_logger.LogInformation($"{aircraft.Plane.GetType()} was added.");
|
||||
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to add object");
|
||||
_logger.LogInformation($"Unable to add object.");
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
catch (VaultOverflowException ex)
|
||||
{
|
||||
|
||||
_logger.LogWarning($"Vault overflow exception: {ex.Message}");
|
||||
MessageBox.Show($"Vault overflow exception: {ex.Message}", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Unknown error: {ex.Message}");
|
||||
MessageBox.Show($"Unknown error: {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DeleteAircraftButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPostion.Text))
|
||||
{
|
||||
return;
|
||||
@@ -124,45 +88,29 @@ namespace AirFighter
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPostion.Text);
|
||||
try
|
||||
if (_mapAircraftsCollectionGeneric - pos != null)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Object is deleted");
|
||||
_logger.LogInformation($"Aircraft was removed from {pos} position.");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to delete object");
|
||||
_logger.LogInformation($"Unable to remove aircraft from {pos} position.");
|
||||
}
|
||||
MessageBox.Show("Object is deleted");
|
||||
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
||||
}
|
||||
catch(AircraftNotFoundException ex)
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"Deletion error: {ex.Message}");
|
||||
_logger.LogWarning($"Aircraft is not found exception: {ex.Message}");
|
||||
MessageBox.Show("Unable to delete object");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Unknown error: {ex.Message}");
|
||||
_logger.LogWarning($"Unknow error: {ex.Message}.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ShowHangarButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
if (_mapAircraftsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
if (_mapAircraftsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -192,108 +140,7 @@ namespace AirFighter
|
||||
}
|
||||
break;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
|
||||
private void AddMapButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxMapSelection.SelectedIndex == -1 || string.IsNullOrEmpty(newMapTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Not all data is filled", " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning("Failed to add map since {0}", comboBoxMapSelection.SelectedIndex == -1? "example of map wasn't choosen." : "name of map is missing");
|
||||
return;
|
||||
}
|
||||
if (!_mapsDict.ContainsKey(comboBoxMapSelection.Text))
|
||||
{
|
||||
MessageBox.Show("There is no such map","Error",MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"There is no map with {comboBoxMapSelection.Text} name.");
|
||||
return;
|
||||
}
|
||||
_mapsCollection.AddMap(newMapTextBox.Text, _mapsDict[comboBoxMapSelection.Text]);
|
||||
RefreshMaps();
|
||||
_logger.LogInformation("Map was added.");
|
||||
}
|
||||
|
||||
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation($"Map was changed to {listBoxMaps.SelectedItem}.");
|
||||
}
|
||||
|
||||
private void DeleteMapButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show($"Delete map {listBoxMaps.SelectedItem}?", "Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapsCollection.DeleteMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
RefreshMaps();
|
||||
_logger.LogInformation($"Map was removed {listBoxMaps.SelectedItem}.");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Data is saved successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"{saveFileDialog.FileName} is saved.");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Something went wrong: {ex.Message}", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Unable to save: {saveFileDialog.FileName} | {ex.Message}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.LoadData(openFileDialog.FileName);
|
||||
RefreshMaps();
|
||||
MessageBox.Show("Data is loaded successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation($"{openFileDialog.FileName} is loaded.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Something went wrong: {ex.Message}", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Unable to load: {openFileDialog.FileName} | {ex.Message}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SortByTypeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ??
|
||||
string.Empty].Sort(new AircraftCompareByType());
|
||||
pictureBox.Image =
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
private void SortByColorButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ??
|
||||
string.Empty].Sort(new AircraftCompareByColor());
|
||||
pictureBox.Image =
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
pictureBox.Image = _mapAircraftsCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,4 @@
|
||||
<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>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>265, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
internal interface IDrawingObject
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
@@ -19,6 +19,5 @@ namespace AirFighter
|
||||
|
||||
(float Left, float Top, float Right, float Bottom) GetCurrentPosition();
|
||||
|
||||
string ReceiveInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class MapWithSetAircraftsGeneric<T, U>
|
||||
where T : class, IDrawingObject, IEquatable<T>
|
||||
where T : class, IDrawingObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
@@ -34,6 +34,7 @@ namespace AirFighter
|
||||
|
||||
public static int operator +(MapWithSetAircraftsGeneric<T, U> map, T aircraft)
|
||||
{
|
||||
|
||||
return map._setAircrafts.Insert(aircraft);
|
||||
}
|
||||
|
||||
@@ -55,13 +56,15 @@ namespace AirFighter
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
|
||||
foreach (var aircraft in _setAircrafts.GetAircrafts())
|
||||
for (int i = 0; i < _setAircrafts.Count; i++)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, aircraft);
|
||||
var aircraft = _setAircrafts.Get(i);
|
||||
if (aircraft != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, aircraft);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
|
||||
}
|
||||
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
@@ -73,39 +76,16 @@ namespace AirFighter
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
|
||||
public string GetData(char separatorType, char separatorData)
|
||||
{
|
||||
string data = $"{_map.GetType().Name}{separatorType}";
|
||||
|
||||
foreach (var aircraft in _setAircrafts.GetAircrafts())
|
||||
{
|
||||
data += $"{aircraft.ReceiveInfo()}{separatorData}";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void LoadData(string[] records)
|
||||
{
|
||||
foreach (var record in records)
|
||||
{
|
||||
_setAircrafts.Insert(DrawingObjectAircraft.Create(record) as T);
|
||||
}
|
||||
}
|
||||
|
||||
public void Sort(IComparer<T> comparer)
|
||||
{
|
||||
_setAircrafts.SortSet(comparer);
|
||||
}
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setAircrafts.Count - 1;
|
||||
for (int i = 0; i < _setAircrafts.Count; i++)
|
||||
{
|
||||
if (_setAircrafts[i] == null)
|
||||
if (_setAircrafts.Get(i) == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var aircraft = _setAircrafts[j];
|
||||
var aircraft = _setAircrafts.Get(i);
|
||||
if (aircraft != null)
|
||||
{
|
||||
_setAircrafts.Insert(aircraft, i);
|
||||
@@ -127,13 +107,11 @@ namespace AirFighter
|
||||
Pen pen = new(Color.Black, 2);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth + 1; i++)
|
||||
{
|
||||
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, _placeSizeWidth - 80, j * _placeSizeHeight + 135);
|
||||
if(i * _placeSizeWidth + _placeSizeWidth + 20 < _pictureWidth - 10)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 60, i * _placeSizeWidth + _placeSizeWidth / 2 + 20, j * _placeSizeHeight + 45);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, _pictureWidth - 80, j * _placeSizeHeight + 135);
|
||||
g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 60, i * _placeSizeWidth + _placeSizeWidth /2 + 20, j * _placeSizeHeight + 45);
|
||||
g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth / 2 + 20, j * _placeSizeHeight + 45, i * _placeSizeWidth + _placeSizeWidth + 20 , j * _placeSizeHeight + 60);
|
||||
g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, i * _placeSizeWidth + 20, j * _placeSizeHeight + 60);
|
||||
|
||||
@@ -144,13 +122,15 @@ namespace AirFighter
|
||||
|
||||
private void DrawAircrafts(Graphics g)
|
||||
{
|
||||
|
||||
int curX = _pictureWidth / _placeSizeWidth - 1;
|
||||
int curY = _pictureHeight / _placeSizeHeight - 1;
|
||||
|
||||
foreach (var aircraft in _setAircrafts.GetAircrafts())
|
||||
for (int i = 0; i < _setAircrafts.Count; i++)
|
||||
{
|
||||
aircraft.SetObject(curX * _placeSizeWidth + 30, curY * _placeSizeHeight + 40, _pictureWidth, _pictureHeight);
|
||||
aircraft.DrawingObject(g);
|
||||
_setAircrafts.Get(i)?.SetObject(curX * _placeSizeWidth + 30, curY * _placeSizeHeight + 40, _pictureWidth, _pictureHeight);
|
||||
|
||||
_setAircrafts.Get(i)?.DrawingObject(g);
|
||||
|
||||
if (curX <= 0)
|
||||
{
|
||||
@@ -164,5 +144,7 @@ namespace AirFighter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
readonly Dictionary<string, MapWithSetAircraftsGeneric<IDrawingObject, AbstractMap>> _mapsVault;
|
||||
|
||||
public List<string> Keys => _mapsVault.Keys.ToList();
|
||||
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly char separatorDict = '|';
|
||||
private readonly char separatorData = ';';
|
||||
|
||||
private bool flag = false;
|
||||
|
||||
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
_mapsVault = new Dictionary<string, MapWithSetAircraftsGeneric<IDrawingObject, AbstractMap>>();
|
||||
}
|
||||
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
if (!Keys.Contains(name))
|
||||
{
|
||||
_mapsVault.Add(name, new MapWithSetAircraftsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DeleteMap(string name)
|
||||
{
|
||||
if (Keys.Contains(name))
|
||||
{
|
||||
_mapsVault.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public MapWithSetAircraftsGeneric<IDrawingObject, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mapsVault.ContainsKey(ind) ? _mapsVault[ind] : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter sw = new StreamWriter(filename))
|
||||
{
|
||||
sw.WriteLine($"MapsCollection");
|
||||
foreach (var vault in _mapsVault)
|
||||
{
|
||||
sw.WriteLine($"{vault.Key}{separatorDict}{vault.Value.GetData(separatorDict, separatorData)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("File was not found.");
|
||||
}
|
||||
|
||||
string str;
|
||||
int count = 0;
|
||||
_mapsVault.Clear();
|
||||
using (StreamReader sr = new StreamReader(filename))
|
||||
{
|
||||
while ((str = sr.ReadLine()) != null)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
if (!str.Contains("MapsCollection"))
|
||||
{
|
||||
throw new FileFormatException("Wrong data format in file.");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
var elem = str.Split(separatorDict);
|
||||
AbstractMap map = null;
|
||||
switch (elem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "NightSkyMap":
|
||||
map = new NightSkyMap();
|
||||
break;
|
||||
}
|
||||
|
||||
_mapsVault.Add(elem[0], new MapWithSetAircraftsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapsVault[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,3 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using Serilog;
|
||||
using System.ServiceProcess;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal static class Program
|
||||
@@ -19,32 +11,7 @@ namespace AirFighter
|
||||
// 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<FormMapWithSetAircrafts>());
|
||||
}
|
||||
|
||||
Application.Run(new FormMapWithSetAircrafts());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormMapWithSetAircrafts>().AddLogging(option =>
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(path: "appsettings.json", false, true)
|
||||
.Build();
|
||||
|
||||
var serilogLogger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(serilogLogger);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,15 @@ using System.Threading.Tasks;
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class SetAircraftsGeneric<T>
|
||||
where T : class, IEquatable<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
private readonly T[] _places;
|
||||
|
||||
public int Count => _places.Count;
|
||||
|
||||
private readonly int _maxCount;
|
||||
public int Count => _places.Length;
|
||||
|
||||
public SetAircraftsGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T>();
|
||||
_places = new T[count];
|
||||
}
|
||||
|
||||
public int Insert(T aircraft)
|
||||
@@ -29,90 +26,62 @@ namespace AirFighter
|
||||
|
||||
public int Insert(T aircraft, int position)
|
||||
{
|
||||
foreach (var instAircraft in _places)
|
||||
int emptypos = -1;
|
||||
|
||||
if (position >= Count && position < 0)
|
||||
{
|
||||
if (aircraft.Equals(instAircraft))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (position > Count || position < 0 || Count == _maxCount)
|
||||
{
|
||||
throw new VaultOverflowException("Overflow of storage.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_places.Insert(position, aircraft);
|
||||
if (_places[position] == null)
|
||||
{
|
||||
_places[position] = aircraft;
|
||||
return position;
|
||||
}
|
||||
|
||||
for (int i = position; i < Count; i++)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
emptypos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (emptypos != -1)
|
||||
{
|
||||
for (int i = emptypos; i > position; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[position] = aircraft;
|
||||
return position;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < Count && position >= 0)
|
||||
{
|
||||
if (_places.ElementAt(position) != null)
|
||||
{
|
||||
T result = _places.ElementAt(position);
|
||||
T result = _places[position];
|
||||
|
||||
_places.RemoveAt(position);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
_places[position] = null;
|
||||
return result;
|
||||
}
|
||||
throw new AircraftNotFoundException($"There is no aircraft in {position} position.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public T this[int position]
|
||||
public T Get(int position)
|
||||
{
|
||||
get
|
||||
if (position >= Count && position < 0)
|
||||
{
|
||||
if (position < _maxCount && position >= 0)
|
||||
{
|
||||
return _places.ElementAt(position);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < _maxCount && position >= 0)
|
||||
{
|
||||
Insert(value,position);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetAircrafts()
|
||||
{
|
||||
|
||||
foreach (var aircraft in _places)
|
||||
{
|
||||
if (aircraft != null)
|
||||
{
|
||||
yield return aircraft;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SortSet(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirFighter
|
||||
{
|
||||
internal class VaultOverflowException : ApplicationException
|
||||
{
|
||||
public VaultOverflowException() : base() { }
|
||||
public VaultOverflowException(string message) : base(message) { }
|
||||
public VaultOverflowException(string message, Exception exception) : base(message, exception) { }
|
||||
protected VaultOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": ["Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/logs.log",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user