Presnyakova V.V Lab_8 #17
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Catamaran
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
{
|
||||
private IDrawingObject _drawingObject = null;
|
||||
protected int[,] _map = null;
|
||||
@ -160,5 +160,31 @@ namespace Catamaran
|
||||
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;
|
||||
}
|
||||
var thisMap = this;
|
||||
var otherMap = other;
|
||||
|
||||
if (thisMap._width != otherMap._width) return false;
|
||||
if (thisMap._height != otherMap._height) return false;
|
||||
if (thisMap._size_x != otherMap._size_x) return false;
|
||||
if (thisMap._size_y != otherMap._size_y) return false;
|
||||
if (thisMap._map.GetLength(0) != otherMap._map.GetLength(0) || thisMap._map.GetLength(1) != otherMap._map.GetLength(1)) return false;
|
||||
for (int i = 0; i < thisMap._map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < thisMap._map.GetLength(1); j++)
|
||||
{
|
||||
if (thisMap._map[i, j] != otherMap._map[i, j]) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.1" newVersion="4.0.5.1" />
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.1" newVersion="4.0.5.1"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
54
Catamaran/BoatCompareByColor.cs
Normal file
54
Catamaran/BoatCompareByColor.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Catamaran
|
||||
{
|
||||
internal class BoatCompareByColor : 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 xBoat = x as DrawingObjectBoat;
|
||||
var yBoat = y as DrawingObjectBoat;
|
||||
if (xBoat == null && yBoat == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xBoat == null && yBoat != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xBoat != null && yBoat == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int colorCompare = string.Compare(xBoat.GetBoat.Catamaran.BodyColor.Name, yBoat.GetBoat.Catamaran.BodyColor.Name);
|
||||
if (colorCompare != 0)
|
||||
{
|
||||
return colorCompare;
|
||||
}
|
||||
var speedCompare = xBoat.GetBoat.Catamaran.Speed.CompareTo(yBoat.GetBoat.Catamaran.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xBoat.GetBoat.Catamaran.Weight.CompareTo(yBoat.GetBoat.Catamaran.Weight);
|
||||
}
|
||||
}
|
||||
}
|
57
Catamaran/BoatCompareByType.cs
Normal file
57
Catamaran/BoatCompareByType.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Catamaran
|
||||
{
|
||||
internal class BoatCompareByType : 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 xBoat = x as DrawingObjectBoat;
|
||||
var yBoat = y as DrawingObjectBoat;
|
||||
if (xBoat == null && yBoat == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xBoat == null && yBoat != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xBoat != null && yBoat == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (xBoat.GetBoat.GetType().Name != yBoat.GetBoat.GetType().Name)
|
||||
{
|
||||
if (xBoat.GetBoat.GetType().Name == "DrawingBoat")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var speedCompare =
|
||||
xBoat.GetBoat.Catamaran.Speed.CompareTo(yBoat.GetBoat.Catamaran.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xBoat.GetBoat.Catamaran.Weight.CompareTo(yBoat.GetBoat.Catamaran.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Catamaran</RootNamespace>
|
||||
<AssemblyName>Catamaran</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
@ -206,6 +206,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AbstractMap.cs" />
|
||||
<Compile Include="BoatCompareByColor.cs" />
|
||||
<Compile Include="BoatCompareByType.cs" />
|
||||
<Compile Include="BoatNotFoundException.cs" />
|
||||
<Compile Include="DrawingCatamaran.cs" />
|
||||
<Compile Include="DrawingObjectBoat.cs" />
|
||||
|
@ -14,12 +14,53 @@ namespace Catamaran
|
||||
{
|
||||
_catamaran = catamaran;
|
||||
}
|
||||
public DrawingBoat GetBoat => _catamaran;
|
||||
public float Step => _catamaran?.Catamaran?.Step ?? 0;
|
||||
public (float Left, float Right, float Top, float Bottom)
|
||||
GetCurrentPosition()
|
||||
GetCurrentPosition()
|
||||
{
|
||||
return _catamaran?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public bool Equals(IDrawingObject other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherBoat = other as DrawingObjectBoat;
|
||||
if (otherBoat == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var boat = _catamaran.Catamaran;
|
||||
var otherBoatBoat = otherBoat._catamaran.Catamaran;
|
||||
if (boat.Speed != otherBoatBoat.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat.Weight != otherBoatBoat.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat.BodyColor != otherBoatBoat.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//доделать проверки в случае продвинутого объекта
|
||||
|
||||
var catamaran = boat as EntityCatamaran;
|
||||
var otherCatamaran = otherBoatBoat as EntityCatamaran;
|
||||
|
||||
if (catamaran == null && otherCatamaran == null) return true;
|
||||
if (catamaran == null || otherCatamaran == null) return false;
|
||||
if (catamaran.DopColor != otherCatamaran.DopColor) return false;
|
||||
if (catamaran.Sail != otherCatamaran.Sail) return false;
|
||||
if (catamaran.Floats != otherCatamaran.Floats) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_catamaran?.MoveTransport(direction);
|
||||
|
74
Catamaran/FormMapWithSetBoats.Designer.cs
generated
74
Catamaran/FormMapWithSetBoats.Designer.cs
generated
@ -29,6 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonSortByColor = new System.Windows.Forms.Button();
|
||||
this.ButtonSortByType = new System.Windows.Forms.Button();
|
||||
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||
@ -59,6 +61,8 @@
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
this.groupBoxTools.Controls.Add(this.ButtonSortByColor);
|
||||
this.groupBoxTools.Controls.Add(this.ButtonSortByType);
|
||||
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||
@ -70,13 +74,33 @@
|
||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(653, 36);
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(653, 33);
|
||||
this.groupBoxTools.Name = "groupBoxTools";
|
||||
this.groupBoxTools.Size = new System.Drawing.Size(303, 611);
|
||||
this.groupBoxTools.Size = new System.Drawing.Size(303, 614);
|
||||
this.groupBoxTools.TabIndex = 0;
|
||||
this.groupBoxTools.TabStop = false;
|
||||
this.groupBoxTools.Text = "Tools";
|
||||
//
|
||||
// ButtonSortByColor
|
||||
//
|
||||
this.ButtonSortByColor.Location = new System.Drawing.Point(24, 335);
|
||||
this.ButtonSortByColor.Name = "ButtonSortByColor";
|
||||
this.ButtonSortByColor.Size = new System.Drawing.Size(191, 26);
|
||||
this.ButtonSortByColor.TabIndex = 7;
|
||||
this.ButtonSortByColor.Text = "SortByColor";
|
||||
this.ButtonSortByColor.UseVisualStyleBackColor = true;
|
||||
this.ButtonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click);
|
||||
//
|
||||
// ButtonSortByType
|
||||
//
|
||||
this.ButtonSortByType.Location = new System.Drawing.Point(24, 298);
|
||||
this.ButtonSortByType.Name = "ButtonSortByType";
|
||||
this.ButtonSortByType.Size = new System.Drawing.Size(191, 31);
|
||||
this.ButtonSortByType.TabIndex = 6;
|
||||
this.ButtonSortByType.Text = "SortByType";
|
||||
this.ButtonSortByType.UseVisualStyleBackColor = true;
|
||||
this.ButtonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click);
|
||||
//
|
||||
// groupBoxMaps
|
||||
//
|
||||
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||
@ -86,7 +110,7 @@
|
||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMaps.Location = new System.Drawing.Point(10, 25);
|
||||
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(213, 314);
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(213, 267);
|
||||
this.groupBoxMaps.TabIndex = 2;
|
||||
this.groupBoxMaps.TabStop = false;
|
||||
this.groupBoxMaps.Text = "Maps";
|
||||
@ -141,9 +165,9 @@
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(24, 490);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(24, 509);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(191, 31);
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(191, 34);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "ShowOnMap";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
@ -151,9 +175,9 @@
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(24, 451);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(24, 470);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(191, 33);
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(191, 36);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "ShowStorage";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
@ -161,9 +185,9 @@
|
||||
//
|
||||
// buttonRemoveBoat
|
||||
//
|
||||
this.buttonRemoveBoat.Location = new System.Drawing.Point(24, 415);
|
||||
this.buttonRemoveBoat.Location = new System.Drawing.Point(24, 434);
|
||||
this.buttonRemoveBoat.Name = "buttonRemoveBoat";
|
||||
this.buttonRemoveBoat.Size = new System.Drawing.Size(191, 30);
|
||||
this.buttonRemoveBoat.Size = new System.Drawing.Size(191, 33);
|
||||
this.buttonRemoveBoat.TabIndex = 3;
|
||||
this.buttonRemoveBoat.Text = "RemoveBoat";
|
||||
this.buttonRemoveBoat.UseVisualStyleBackColor = true;
|
||||
@ -171,7 +195,7 @@
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(24, 383);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(24, 405);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(191, 26);
|
||||
@ -179,9 +203,9 @@
|
||||
//
|
||||
// buttonAddBoat
|
||||
//
|
||||
this.buttonAddBoat.Location = new System.Drawing.Point(24, 345);
|
||||
this.buttonAddBoat.Location = new System.Drawing.Point(24, 364);
|
||||
this.buttonAddBoat.Name = "buttonAddBoat";
|
||||
this.buttonAddBoat.Size = new System.Drawing.Size(191, 32);
|
||||
this.buttonAddBoat.Size = new System.Drawing.Size(191, 35);
|
||||
this.buttonAddBoat.TabIndex = 1;
|
||||
this.buttonAddBoat.Text = "AddBoat";
|
||||
this.buttonAddBoat.UseVisualStyleBackColor = true;
|
||||
@ -192,9 +216,9 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Catamaran.Properties.Resources.Left;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(10, 526);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(10, 548);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 33);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
@ -204,9 +228,9 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Catamaran.Properties.Resources.Right;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(70, 526);
|
||||
this.buttonRight.Location = new System.Drawing.Point(70, 548);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 33);
|
||||
this.buttonRight.TabIndex = 5;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
@ -216,9 +240,9 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::Catamaran.Properties.Resources.Up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(40, 504);
|
||||
this.buttonUp.Location = new System.Drawing.Point(40, 526);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 33);
|
||||
this.buttonUp.TabIndex = 2;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
@ -228,9 +252,9 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Catamaran.Properties.Resources.Down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(40, 534);
|
||||
this.buttonDown.Location = new System.Drawing.Point(40, 556);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 33);
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
@ -238,9 +262,9 @@
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 36);
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 33);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(653, 611);
|
||||
this.pictureBox.Size = new System.Drawing.Size(653, 614);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
@ -252,7 +276,7 @@
|
||||
this.fileToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(956, 36);
|
||||
this.menuStrip.Size = new System.Drawing.Size(956, 33);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
this.menuStrip.Text = "menuStrip";
|
||||
//
|
||||
@ -262,7 +286,7 @@
|
||||
this.saveToolStripMenuItem,
|
||||
this.loadToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 32);
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 29);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
@ -331,5 +355,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog;
|
||||
private System.Windows.Forms.Button ButtonSortByColor;
|
||||
private System.Windows.Forms.Button ButtonSortByType;
|
||||
}
|
||||
}
|
@ -323,5 +323,32 @@ namespace Catamaran
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сортировка по типу
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSortByType_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new BoatCompareByType());
|
||||
pictureBox.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 BoatCompareByColor());
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,4 +126,7 @@
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>357, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>26</value>
|
||||
</metadata>
|
||||
</root>
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Catamaran
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
|
@ -13,7 +13,7 @@ namespace Catamaran
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class MapWithSetBoatsGeneric<T, U>
|
||||
where T : class, IDrawingObject
|
||||
where T : class, IDrawingObject, IEquatable<T>
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
@ -208,6 +208,13 @@ namespace Catamaran
|
||||
_setBoats.Insert(DrawingObjectBoat.Create(rec) as T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сортировка
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public void Sort(IComparer<T> comparer)
|
||||
{
|
||||
_setBoats.SortSet(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
Catamaran/Properties/Settings.Designer.cs
generated
2
Catamaran/Properties/Settings.Designer.cs
generated
@ -12,7 +12,7 @@ namespace Catamaran.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
@ -11,7 +11,7 @@ namespace Catamaran
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetBoatsGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
@ -40,6 +40,7 @@ namespace Catamaran
|
||||
public int Insert(T boat)
|
||||
{
|
||||
|
||||
if (_places.Contains(boat)) return -1;
|
||||
for (int i = 0; i < _maxCount; i++)
|
||||
{
|
||||
if (i == Count)
|
||||
@ -49,7 +50,7 @@ namespace Catamaran
|
||||
}
|
||||
}
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
@ -62,8 +63,8 @@ namespace Catamaran
|
||||
// TODO проверка позиции
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
return -1 ;
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
// TODO проверка, что элемент массива по этой позиции пустой,если нет, то
|
||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
||||
@ -150,6 +151,17 @@ namespace Catamaran
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сортировка набора объектов
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public void SortSet(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user