Сортировка.
This commit is contained in:
parent
e1515f7771
commit
91c2c075f3
@ -17,6 +17,8 @@ namespace Airbus
|
|||||||
_airbus = airbus;
|
_airbus = airbus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawningAirbus GetPlane => _airbus;
|
||||||
|
|
||||||
void IDrawningObject.DrawningObject(Graphics g)
|
void IDrawningObject.DrawningObject(Graphics g)
|
||||||
{
|
{
|
||||||
_airbus.DrawTransport(g);
|
_airbus.DrawTransport(g);
|
||||||
|
50
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
50
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
@ -51,6 +51,8 @@
|
|||||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.saveFileDialog = new System.Windows.Forms.OpenFileDialog();
|
this.saveFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.buttonSortByType = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSortByColor = new System.Windows.Forms.Button();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
this.groupBoxMaps.SuspendLayout();
|
this.groupBoxMaps.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
@ -59,6 +61,8 @@
|
|||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonSortByColor);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonSortByType);
|
||||||
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonRight);
|
this.groupBoxTools.Controls.Add(this.buttonRight);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||||
@ -72,7 +76,7 @@
|
|||||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(843, 28);
|
this.groupBoxTools.Location = new System.Drawing.Point(843, 28);
|
||||||
this.groupBoxTools.Name = "groupBoxTools";
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
this.groupBoxTools.Size = new System.Drawing.Size(250, 769);
|
this.groupBoxTools.Size = new System.Drawing.Size(250, 863);
|
||||||
this.groupBoxTools.TabIndex = 0;
|
this.groupBoxTools.TabIndex = 0;
|
||||||
this.groupBoxTools.TabStop = false;
|
this.groupBoxTools.TabStop = false;
|
||||||
this.groupBoxTools.Text = "Инструменты";
|
this.groupBoxTools.Text = "Инструменты";
|
||||||
@ -145,7 +149,7 @@
|
|||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.Right;
|
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.Right;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(158, 704);
|
this.buttonRight.Location = new System.Drawing.Point(158, 798);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(45, 45);
|
this.buttonRight.Size = new System.Drawing.Size(45, 45);
|
||||||
this.buttonRight.TabIndex = 9;
|
this.buttonRight.TabIndex = 9;
|
||||||
@ -157,7 +161,7 @@
|
|||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.Down;
|
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.Down;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(107, 704);
|
this.buttonDown.Location = new System.Drawing.Point(107, 798);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(45, 45);
|
this.buttonDown.Size = new System.Drawing.Size(45, 45);
|
||||||
this.buttonDown.TabIndex = 8;
|
this.buttonDown.TabIndex = 8;
|
||||||
@ -169,7 +173,7 @@
|
|||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.Left;
|
this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.Left;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(56, 704);
|
this.buttonLeft.Location = new System.Drawing.Point(56, 798);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(45, 45);
|
this.buttonLeft.Size = new System.Drawing.Size(45, 45);
|
||||||
this.buttonLeft.TabIndex = 7;
|
this.buttonLeft.TabIndex = 7;
|
||||||
@ -181,7 +185,7 @@
|
|||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.Up;
|
this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.Up;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(107, 653);
|
this.buttonUp.Location = new System.Drawing.Point(107, 747);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(45, 45);
|
this.buttonUp.Size = new System.Drawing.Size(45, 45);
|
||||||
this.buttonUp.TabIndex = 6;
|
this.buttonUp.TabIndex = 6;
|
||||||
@ -190,7 +194,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(20, 553);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(20, 687);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(218, 29);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(218, 29);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
@ -200,7 +204,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(20, 500);
|
this.buttonShowStorage.Location = new System.Drawing.Point(20, 634);
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(218, 29);
|
this.buttonShowStorage.Size = new System.Drawing.Size(218, 29);
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
@ -210,7 +214,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemovePlane
|
// buttonRemovePlane
|
||||||
//
|
//
|
||||||
this.buttonRemovePlane.Location = new System.Drawing.Point(20, 446);
|
this.buttonRemovePlane.Location = new System.Drawing.Point(20, 580);
|
||||||
this.buttonRemovePlane.Name = "buttonRemovePlane";
|
this.buttonRemovePlane.Name = "buttonRemovePlane";
|
||||||
this.buttonRemovePlane.Size = new System.Drawing.Size(218, 29);
|
this.buttonRemovePlane.Size = new System.Drawing.Size(218, 29);
|
||||||
this.buttonRemovePlane.TabIndex = 3;
|
this.buttonRemovePlane.TabIndex = 3;
|
||||||
@ -220,7 +224,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 413);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 547);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(218, 27);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(218, 27);
|
||||||
@ -228,7 +232,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddPlane
|
// buttonAddPlane
|
||||||
//
|
//
|
||||||
this.buttonAddPlane.Location = new System.Drawing.Point(20, 378);
|
this.buttonAddPlane.Location = new System.Drawing.Point(20, 512);
|
||||||
this.buttonAddPlane.Name = "buttonAddPlane";
|
this.buttonAddPlane.Name = "buttonAddPlane";
|
||||||
this.buttonAddPlane.Size = new System.Drawing.Size(218, 29);
|
this.buttonAddPlane.Size = new System.Drawing.Size(218, 29);
|
||||||
this.buttonAddPlane.TabIndex = 1;
|
this.buttonAddPlane.TabIndex = 1;
|
||||||
@ -241,7 +245,7 @@
|
|||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 28);
|
this.pictureBox.Location = new System.Drawing.Point(0, 28);
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox.Size = new System.Drawing.Size(843, 769);
|
this.pictureBox.Size = new System.Drawing.Size(843, 863);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -287,11 +291,31 @@
|
|||||||
//
|
//
|
||||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||||
//
|
//
|
||||||
|
// buttonSortByType
|
||||||
|
//
|
||||||
|
this.buttonSortByType.Location = new System.Drawing.Point(20, 395);
|
||||||
|
this.buttonSortByType.Name = "buttonSortByType";
|
||||||
|
this.buttonSortByType.Size = new System.Drawing.Size(218, 29);
|
||||||
|
this.buttonSortByType.TabIndex = 11;
|
||||||
|
this.buttonSortByType.Text = "Сортировка по типу";
|
||||||
|
this.buttonSortByType.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click);
|
||||||
|
//
|
||||||
|
// buttonSortByColor
|
||||||
|
//
|
||||||
|
this.buttonSortByColor.Location = new System.Drawing.Point(20, 430);
|
||||||
|
this.buttonSortByColor.Name = "buttonSortByColor";
|
||||||
|
this.buttonSortByColor.Size = new System.Drawing.Size(218, 29);
|
||||||
|
this.buttonSortByColor.TabIndex = 12;
|
||||||
|
this.buttonSortByColor.Text = "Сортировка по цвету";
|
||||||
|
this.buttonSortByColor.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click);
|
||||||
|
//
|
||||||
// FormMapWithSetPlanes
|
// FormMapWithSetPlanes
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1093, 797);
|
this.ClientSize = new System.Drawing.Size(1093, 891);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBoxTools);
|
this.Controls.Add(this.groupBoxTools);
|
||||||
this.Controls.Add(this.menuStrip);
|
this.Controls.Add(this.menuStrip);
|
||||||
@ -335,5 +359,7 @@
|
|||||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
private OpenFileDialog openFileDialog;
|
private OpenFileDialog openFileDialog;
|
||||||
private OpenFileDialog saveFileDialog;
|
private OpenFileDialog saveFileDialog;
|
||||||
|
private Button buttonSortByColor;
|
||||||
|
private Button buttonSortByType;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -292,5 +292,17 @@ namespace Airbus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//сортировка по типу
|
||||||
|
private void buttonSortByType_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//сортировка по цвету
|
||||||
|
private void buttonSortByColor_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//TODO прописать логику
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,12 @@ namespace Airbus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//сортировка
|
||||||
|
public void Sort(IComparer<T> comparer)
|
||||||
|
{
|
||||||
|
_setPlanes.SortSet(comparer);
|
||||||
|
}
|
||||||
|
|
||||||
//"взламываем" набор, чтобы все элементы оказались в начале
|
//"взламываем" набор, чтобы все элементы оказались в начале
|
||||||
private void Shaking()
|
private void Shaking()
|
||||||
{
|
{
|
||||||
|
16
Airbus/Airbus/PlaneCompareByColor.cs
Normal file
16
Airbus/Airbus/PlaneCompareByColor.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
internal class PlaneCompareByColor : IComparer<IDrawningObject>
|
||||||
|
{
|
||||||
|
public int Compare(IDrawningObject? x, IDrawningObject? y)
|
||||||
|
{
|
||||||
|
//TODO проверку
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
Airbus/Airbus/PlaneCompareByType.cs
Normal file
67
Airbus/Airbus/PlaneCompareByType.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
internal class PlaneCompareByType : IComparer<IDrawningObject>
|
||||||
|
{
|
||||||
|
public int Compare(IDrawningObject? x, IDrawningObject? y)
|
||||||
|
{
|
||||||
|
if(x == null && y == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x == null && y != null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x != null && y != null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var xPlane = x as DrawningObjectPlane;
|
||||||
|
var yPlane = y as DrawningObjectPlane;
|
||||||
|
|
||||||
|
if(xPlane == null && yPlane == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xPlane == null && yPlane != null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xPlane != null && yPlane == null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xPlane.GetPlane.GetType().Name != yPlane.GetPlane.GetType().Name)
|
||||||
|
{
|
||||||
|
if(xPlane.GetPlane.GetType().Name == "DrawningAirbus")
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var speedCompare = xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed);
|
||||||
|
|
||||||
|
if(speedCompare != 0)
|
||||||
|
{
|
||||||
|
return speedCompare;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -114,5 +114,16 @@ namespace Airbus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//сортировка набора объектов
|
||||||
|
public void SortSet(IComparer<T> comparer)
|
||||||
|
{
|
||||||
|
if(comparer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_places.Sort(comparer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user