Compare commits
No commits in common. "6a6a24f7dc8cfe1870d392b1d4aea314af6592c6" and "a66e4d604a884bcc4ccba1f29d338f16d6973c13" have entirely different histories.
6a6a24f7dc
...
a66e4d604a
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
internal abstract class AbstractMap
|
||||
{
|
||||
private IDrawingObject _drawingObject = null;
|
||||
protected int[,] _map = null;
|
||||
@ -122,46 +122,5 @@ namespace Artilleries
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
|
||||
public bool Equals(AbstractMap? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_width != other._width)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_height != other._height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_size_x != other._size_x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_size_y != other._size_y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
if (_map[i, j] != other._map[i, j])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class ArtilleryCompareByColor : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? first, IDrawingObject? second)
|
||||
{
|
||||
if (first == null && second == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (first == null && second != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (first != null && second == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var firstArtillery = first as DrawingObjectArtillery;
|
||||
var secondArtillery = second as DrawingObjectArtillery;
|
||||
|
||||
if (firstArtillery == null && secondArtillery == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (firstArtillery == null && secondArtillery != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (firstArtillery != null && secondArtillery == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int firstColor = firstArtillery.Artillery.Artillery.BodyColor.ToArgb();
|
||||
int secondColor = secondArtillery.Artillery.Artillery.BodyColor.ToArgb();
|
||||
|
||||
if (firstColor != secondColor)
|
||||
{
|
||||
return firstColor.CompareTo(secondColor);
|
||||
}
|
||||
|
||||
if (firstArtillery.Artillery.Artillery is EntityAdvancedArtillery firstAdvanced && secondArtillery.Artillery.Artillery is EntityAdvancedArtillery secondAdvanced)
|
||||
{
|
||||
firstColor = firstAdvanced.DopColor.ToArgb();
|
||||
secondColor = secondAdvanced.DopColor.ToArgb();
|
||||
|
||||
if (firstColor != secondColor)
|
||||
{
|
||||
return firstColor.CompareTo(secondColor);
|
||||
}
|
||||
}
|
||||
|
||||
var speedCompare = firstArtillery.Artillery.Artillery.Speed.CompareTo(secondArtillery.Artillery.Artillery.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
|
||||
return firstArtillery.Artillery.Artillery.Weight.CompareTo(secondArtillery.Artillery.Artillery.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class ArtilleryCompareByType : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? first, IDrawingObject? second)
|
||||
{
|
||||
if (first == null && second == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (first == null && second != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (first != null && second == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var firstArtillery = first as DrawingObjectArtillery;
|
||||
var secondArtillery = second as DrawingObjectArtillery;
|
||||
|
||||
if (firstArtillery == null && secondArtillery == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (firstArtillery == null && secondArtillery != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (firstArtillery != null && secondArtillery == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (firstArtillery.Artillery.GetType() != secondArtillery.Artillery.GetType())
|
||||
{
|
||||
if (firstArtillery.Artillery.GetType().Name == "DrawningArtillery")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
var speedCompare = firstArtillery.Artillery.Artillery.Speed.CompareTo(secondArtillery.Artillery.Artillery.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
|
||||
return firstArtillery.Artillery.Artillery.Weight.CompareTo(secondArtillery.Artillery.Artillery.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,8 +10,6 @@ namespace Artilleries
|
||||
{
|
||||
private DrawingArtillery _artillery = null;
|
||||
|
||||
public DrawingArtillery Artillery => _artillery;
|
||||
|
||||
public DrawingObjectArtillery(DrawingArtillery artillery)
|
||||
{
|
||||
_artillery = artillery;
|
||||
@ -42,63 +40,5 @@ namespace Artilleries
|
||||
public string GetInfo() => _artillery?.GetDateForSave();
|
||||
|
||||
public static IDrawingObject Create(string data) => new DrawingObjectArtillery(data.CreateDrawingArtillery());
|
||||
|
||||
public bool Equals(IDrawingObject? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var otherArtillery = other as DrawingObjectArtillery;
|
||||
|
||||
if (otherArtillery == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var artillery = _artillery.Artillery;
|
||||
var otherArtilleryArtillery = otherArtillery._artillery.Artillery;
|
||||
|
||||
if (artillery.GetType() != otherArtilleryArtillery.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (artillery.Speed != otherArtilleryArtillery.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (artillery.Weight != otherArtilleryArtillery.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (artillery.BodyColor != otherArtilleryArtillery.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (artillery is EntityAdvancedArtillery advanced && otherArtilleryArtillery is EntityAdvancedArtillery otherAdvanced)
|
||||
{
|
||||
if (advanced.DopColor != otherAdvanced.DopColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (advanced.Weapon != otherAdvanced.Weapon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (advanced.SalvoBattery != otherAdvanced.SalvoBattery)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,6 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.toolsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.buttonSortByColor = new System.Windows.Forms.Button();
|
||||
this.buttonSortByType = new System.Windows.Forms.Button();
|
||||
this.mapsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
@ -61,8 +59,6 @@
|
||||
//
|
||||
// toolsGroupBox
|
||||
//
|
||||
this.toolsGroupBox.Controls.Add(this.buttonSortByColor);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonSortByType);
|
||||
this.toolsGroupBox.Controls.Add(this.mapsGroupBox);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonShowOnMap);
|
||||
this.toolsGroupBox.Controls.Add(this.buttonShowStorage);
|
||||
@ -76,31 +72,11 @@
|
||||
this.toolsGroupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.toolsGroupBox.Location = new System.Drawing.Point(600, 24);
|
||||
this.toolsGroupBox.Name = "toolsGroupBox";
|
||||
this.toolsGroupBox.Size = new System.Drawing.Size(200, 657);
|
||||
this.toolsGroupBox.Size = new System.Drawing.Size(200, 589);
|
||||
this.toolsGroupBox.TabIndex = 0;
|
||||
this.toolsGroupBox.TabStop = false;
|
||||
this.toolsGroupBox.Text = "Инструменты";
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
this.buttonSortByColor.Location = new System.Drawing.Point(13, 324);
|
||||
this.buttonSortByColor.Name = "buttonSortByColor";
|
||||
this.buttonSortByColor.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonSortByColor.TabIndex = 27;
|
||||
this.buttonSortByColor.Text = "Сортировать по цвету";
|
||||
this.buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click);
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
this.buttonSortByType.Location = new System.Drawing.Point(13, 286);
|
||||
this.buttonSortByType.Name = "buttonSortByType";
|
||||
this.buttonSortByType.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonSortByType.TabIndex = 26;
|
||||
this.buttonSortByType.Text = "Сортировать по типу";
|
||||
this.buttonSortByType.UseVisualStyleBackColor = true;
|
||||
this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click);
|
||||
//
|
||||
// mapsGroupBox
|
||||
//
|
||||
this.mapsGroupBox.Controls.Add(this.buttonDeleteMap);
|
||||
@ -166,7 +142,7 @@
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 526);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 470);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonShowOnMap.TabIndex = 24;
|
||||
@ -176,7 +152,7 @@
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(13, 488);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(13, 423);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonShowStorage.TabIndex = 23;
|
||||
@ -186,7 +162,7 @@
|
||||
//
|
||||
// buttonRemoveArtillery
|
||||
//
|
||||
this.buttonRemoveArtillery.Location = new System.Drawing.Point(13, 441);
|
||||
this.buttonRemoveArtillery.Location = new System.Drawing.Point(13, 376);
|
||||
this.buttonRemoveArtillery.Name = "buttonRemoveArtillery";
|
||||
this.buttonRemoveArtillery.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonRemoveArtillery.TabIndex = 22;
|
||||
@ -196,7 +172,7 @@
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 412);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 347);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||
@ -204,7 +180,7 @@
|
||||
//
|
||||
// buttonAddArtillery
|
||||
//
|
||||
this.buttonAddArtillery.Location = new System.Drawing.Point(13, 374);
|
||||
this.buttonAddArtillery.Location = new System.Drawing.Point(13, 309);
|
||||
this.buttonAddArtillery.Name = "buttonAddArtillery";
|
||||
this.buttonAddArtillery.Size = new System.Drawing.Size(175, 32);
|
||||
this.buttonAddArtillery.TabIndex = 20;
|
||||
@ -217,7 +193,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(124, 606);
|
||||
this.buttonRight.Location = new System.Drawing.Point(124, 538);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 18;
|
||||
@ -229,7 +205,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(88, 606);
|
||||
this.buttonDown.Location = new System.Drawing.Point(88, 538);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 17;
|
||||
@ -241,7 +217,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(88, 573);
|
||||
this.buttonUp.Location = new System.Drawing.Point(88, 505);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 16;
|
||||
@ -253,7 +229,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(54, 606);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(54, 538);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 15;
|
||||
@ -265,7 +241,7 @@
|
||||
this.pictureBoxArtilleries.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxArtilleries.Location = new System.Drawing.Point(0, 24);
|
||||
this.pictureBoxArtilleries.Name = "pictureBoxArtilleries";
|
||||
this.pictureBoxArtilleries.Size = new System.Drawing.Size(600, 657);
|
||||
this.pictureBoxArtilleries.Size = new System.Drawing.Size(600, 589);
|
||||
this.pictureBoxArtilleries.TabIndex = 1;
|
||||
this.pictureBoxArtilleries.TabStop = false;
|
||||
//
|
||||
@ -315,7 +291,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 681);
|
||||
this.ClientSize = new System.Drawing.Size(800, 613);
|
||||
this.Controls.Add(this.pictureBoxArtilleries);
|
||||
this.Controls.Add(this.toolsGroupBox);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
@ -359,7 +335,5 @@
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private OpenFileDialog loadFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button buttonSortByColor;
|
||||
private Button buttonSortByType;
|
||||
}
|
||||
}
|
@ -250,25 +250,5 @@ namespace Artilleries
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSortByType_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new ArtilleryCompareByType());
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
private void buttonSortByColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new ArtilleryCompareByColor());
|
||||
pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
internal interface IDrawingObject
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class MapWithSetArtilleriesGeneric<T, U>
|
||||
where T : class, IDrawingObject, IEquatable<T>
|
||||
where T : class, IDrawingObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
@ -142,10 +142,5 @@ namespace Artilleries
|
||||
_setArtilleries.Insert(DrawingObjectArtillery.Create(record) as T);
|
||||
}
|
||||
}
|
||||
|
||||
public void Sort(IComparer<T> comparer)
|
||||
{
|
||||
_setArtilleries.SortSet(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class SetArtilleriesGeneric<T>
|
||||
where T : class, IEquatable<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
public int Count => _places.Count;
|
||||
@ -36,11 +36,6 @@ namespace Artilleries
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_places.Contains(artillery))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_places.Insert(position, artillery);
|
||||
|
||||
return position;
|
||||
@ -98,15 +93,5 @@ namespace Artilleries
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SortSet(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user