This commit is contained in:
shadowik 2022-12-11 23:00:22 +04:00
parent 3de58e4df9
commit e527ff439b
8 changed files with 227 additions and 81 deletions

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoubleDeckerBus
{
internal class BusCompareByColor : IComparer<IDrawingObject>
{
public int Compare(IDrawingObject? x, IDrawingObject? y)
{
// TODO реализовать
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoubleDeckerBus
{
internal class BusCompareByType : 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 xBus = x as DrawingObjectBus;
var yBus = y as DrawingObjectBus;
if (xBus == null && yBus == null)
{
return 0;
}
if (xBus == null && yBus != null)
{
return 1;
}
if (xBus != null && yBus == null)
{
return -1;
}
if (xBus.GetBus.GetType().Name != yBus.GetBus.GetType().Name)
{
if (xBus.GetBus.GetType().Name == "DrawingBus")
{
return -1;
}
return 1;
}
var speedCompare = xBus.GetBus.Bus.Speed.CompareTo(yBus.GetBus.Bus.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return xBus.GetBus.Bus.Weight.CompareTo(yBus.GetBus.Bus.Weight);
}
}
}

View File

@ -59,7 +59,38 @@ namespace DoubleDeckerBus
public DrawingBus getBus() public DrawingBus getBus()
{ {
return _bus; throw new NotImplementedException();
} }
public bool Equals(IDrawingObject? other)
{
if (other == null)
{
return false;
}
var otherBus = other as DrawingObjectBus;
if (otherBus == null)
{
return false;
}
var bus = _bus.Bus;
var otherCarCar = otherBus._bus.Bus;
if (bus.Speed != otherCarCar.Speed)
{
return false;
}
if (bus.Weight != otherCarCar.Weight)
{
return false;
}
if (bus.BodyColor != otherCarCar.BodyColor)
{
return false;
}
// TODO доделать проверки в случае продвинутого объекта
return true;
}
public DrawingBus GetBus => _bus;
} }
} }

View File

@ -39,8 +39,6 @@
this.buttonDown = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button();
this.buttonDeleteBus = new System.Windows.Forms.Button(); this.buttonDeleteBus = new System.Windows.Forms.Button();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonAddBus = new System.Windows.Forms.Button(); this.buttonAddBus = new System.Windows.Forms.Button();
@ -51,6 +49,10 @@
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.SaveFileDialog(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.button1 = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button();
this.ButtonSortByColor = new System.Windows.Forms.Button();
this.ButtonSortByType = new System.Windows.Forms.Button();
this.groupBoxSettings.SuspendLayout(); this.groupBoxSettings.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
@ -59,6 +61,8 @@
// //
// groupBoxSettings // groupBoxSettings
// //
this.groupBoxSettings.Controls.Add(this.ButtonSortByColor);
this.groupBoxSettings.Controls.Add(this.ButtonSortByType);
this.groupBoxSettings.Controls.Add(this.groupBox1); this.groupBoxSettings.Controls.Add(this.groupBox1);
this.groupBoxSettings.Controls.Add(this.buttonRight); this.groupBoxSettings.Controls.Add(this.buttonRight);
this.groupBoxSettings.Controls.Add(this.buttonDown); this.groupBoxSettings.Controls.Add(this.buttonDown);
@ -70,11 +74,9 @@
this.groupBoxSettings.Controls.Add(this.maskedTextBoxPosition); this.groupBoxSettings.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxSettings.Controls.Add(this.buttonAddBus); this.groupBoxSettings.Controls.Add(this.buttonAddBus);
this.groupBoxSettings.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxSettings.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxSettings.Location = new System.Drawing.Point(737, 28); this.groupBoxSettings.Location = new System.Drawing.Point(645, 24);
this.groupBoxSettings.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxSettings.Name = "groupBoxSettings"; this.groupBoxSettings.Name = "groupBoxSettings";
this.groupBoxSettings.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxSettings.Size = new System.Drawing.Size(200, 710);
this.groupBoxSettings.Size = new System.Drawing.Size(229, 829);
this.groupBoxSettings.TabIndex = 0; this.groupBoxSettings.TabIndex = 0;
this.groupBoxSettings.TabStop = false; this.groupBoxSettings.TabStop = false;
this.groupBoxSettings.Text = "Инструменты"; this.groupBoxSettings.Text = "Инструменты";
@ -86,11 +88,9 @@
this.groupBox1.Controls.Add(this.ButtonAddMap); this.groupBox1.Controls.Add(this.ButtonAddMap);
this.groupBox1.Controls.Add(this.textBoxNewMapName); this.groupBox1.Controls.Add(this.textBoxNewMapName);
this.groupBox1.Controls.Add(this.comboBoxSelectorMap); this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
this.groupBox1.Location = new System.Drawing.Point(0, 29); this.groupBox1.Location = new System.Drawing.Point(0, 22);
this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBox1.Size = new System.Drawing.Size(200, 339);
this.groupBox1.Size = new System.Drawing.Size(229, 452);
this.groupBox1.TabIndex = 11; this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Карты"; this.groupBox1.Text = "Карты";
@ -98,20 +98,18 @@
// listBoxMaps // listBoxMaps
// //
this.listBoxMaps.FormattingEnabled = true; this.listBoxMaps.FormattingEnabled = true;
this.listBoxMaps.ItemHeight = 20; this.listBoxMaps.ItemHeight = 15;
this.listBoxMaps.Location = new System.Drawing.Point(7, 200); this.listBoxMaps.Location = new System.Drawing.Point(6, 150);
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBoxMaps.Name = "listBoxMaps"; this.listBoxMaps.Name = "listBoxMaps";
this.listBoxMaps.Size = new System.Drawing.Size(214, 164); this.listBoxMaps.Size = new System.Drawing.Size(188, 124);
this.listBoxMaps.TabIndex = 4; this.listBoxMaps.TabIndex = 4;
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged); this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
// //
// ButtonDeleteMap // ButtonDeleteMap
// //
this.ButtonDeleteMap.Location = new System.Drawing.Point(7, 373); this.ButtonDeleteMap.Location = new System.Drawing.Point(6, 280);
this.ButtonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonDeleteMap.Name = "ButtonDeleteMap"; this.ButtonDeleteMap.Name = "ButtonDeleteMap";
this.ButtonDeleteMap.Size = new System.Drawing.Size(222, 71); this.ButtonDeleteMap.Size = new System.Drawing.Size(194, 53);
this.ButtonDeleteMap.TabIndex = 3; this.ButtonDeleteMap.TabIndex = 3;
this.ButtonDeleteMap.Text = "Удалить карту"; this.ButtonDeleteMap.Text = "Удалить карту";
this.ButtonDeleteMap.UseVisualStyleBackColor = true; this.ButtonDeleteMap.UseVisualStyleBackColor = true;
@ -119,10 +117,9 @@
// //
// ButtonAddMap // ButtonAddMap
// //
this.ButtonAddMap.Location = new System.Drawing.Point(7, 112); this.ButtonAddMap.Location = new System.Drawing.Point(6, 84);
this.ButtonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonAddMap.Name = "ButtonAddMap"; this.ButtonAddMap.Name = "ButtonAddMap";
this.ButtonAddMap.Size = new System.Drawing.Size(222, 71); this.ButtonAddMap.Size = new System.Drawing.Size(194, 53);
this.ButtonAddMap.TabIndex = 2; this.ButtonAddMap.TabIndex = 2;
this.ButtonAddMap.Text = "Добавить карту"; this.ButtonAddMap.Text = "Добавить карту";
this.ButtonAddMap.UseVisualStyleBackColor = true; this.ButtonAddMap.UseVisualStyleBackColor = true;
@ -130,19 +127,17 @@
// //
// textBoxNewMapName // textBoxNewMapName
// //
this.textBoxNewMapName.Location = new System.Drawing.Point(7, 29); this.textBoxNewMapName.Location = new System.Drawing.Point(6, 22);
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxNewMapName.Name = "textBoxNewMapName"; this.textBoxNewMapName.Name = "textBoxNewMapName";
this.textBoxNewMapName.Size = new System.Drawing.Size(214, 27); this.textBoxNewMapName.Size = new System.Drawing.Size(188, 23);
this.textBoxNewMapName.TabIndex = 1; this.textBoxNewMapName.TabIndex = 1;
// //
// comboBoxSelectorMap // comboBoxSelectorMap
// //
this.comboBoxSelectorMap.FormattingEnabled = true; this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 73); this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 55);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(214, 28); this.comboBoxSelectorMap.Size = new System.Drawing.Size(188, 23);
this.comboBoxSelectorMap.TabIndex = 0; this.comboBoxSelectorMap.TabIndex = 0;
// //
// buttonRight // buttonRight
@ -150,9 +145,10 @@
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::DoubleDeckerBus.Properties.Resources.RightArrow; this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.RightArrow;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(125, 760); this.buttonRight.Location = new System.Drawing.Point(109, 658);
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRight.Name = "buttonRight"; this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 29); this.buttonRight.Size = new System.Drawing.Size(26, 22);
this.buttonRight.TabIndex = 10; this.buttonRight.TabIndex = 10;
this.buttonRight.Text = " "; this.buttonRight.Text = " ";
this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.UseVisualStyleBackColor = true;
@ -163,9 +159,10 @@
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::DoubleDeckerBus.Properties.Resources.DownArrow; this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.DownArrow;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(98, 785); this.buttonDown.Location = new System.Drawing.Point(86, 677);
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDown.Name = "buttonDown"; this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 29); this.buttonDown.Size = new System.Drawing.Size(26, 22);
this.buttonDown.TabIndex = 9; this.buttonDown.TabIndex = 9;
this.buttonDown.Text = " "; this.buttonDown.Text = " ";
this.buttonDown.UseVisualStyleBackColor = true; this.buttonDown.UseVisualStyleBackColor = true;
@ -176,9 +173,10 @@
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::DoubleDeckerBus.Properties.Resources.LeftArrow; this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.LeftArrow;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(72, 760); this.buttonLeft.Location = new System.Drawing.Point(63, 658);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 29); this.buttonLeft.Size = new System.Drawing.Size(26, 22);
this.buttonLeft.TabIndex = 8; this.buttonLeft.TabIndex = 8;
this.buttonLeft.Text = " "; this.buttonLeft.Text = " ";
this.buttonLeft.UseVisualStyleBackColor = true; this.buttonLeft.UseVisualStyleBackColor = true;
@ -189,42 +187,20 @@
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::DoubleDeckerBus.Properties.Resources.UpArrow; this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.UpArrow;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(97, 735); this.buttonUp.Location = new System.Drawing.Point(85, 639);
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUp.Name = "buttonUp"; this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 29); this.buttonUp.Size = new System.Drawing.Size(26, 22);
this.buttonUp.TabIndex = 7; this.buttonUp.TabIndex = 7;
this.buttonUp.Text = " "; this.buttonUp.Text = " ";
this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
// //
// button1
//
this.button1.Location = new System.Drawing.Point(7, 695);
this.button1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(208, 47);
this.button1.TabIndex = 5;
this.button1.Text = "Посмотреть карту";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(7, 640);
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(208, 47);
this.buttonShowStorage.TabIndex = 4;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
//
// buttonDeleteBus // buttonDeleteBus
// //
this.buttonDeleteBus.Location = new System.Drawing.Point(7, 584); this.buttonDeleteBus.Location = new System.Drawing.Point(6, 522);
this.buttonDeleteBus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonDeleteBus.Name = "buttonDeleteBus"; this.buttonDeleteBus.Name = "buttonDeleteBus";
this.buttonDeleteBus.Size = new System.Drawing.Size(215, 48); this.buttonDeleteBus.Size = new System.Drawing.Size(188, 36);
this.buttonDeleteBus.TabIndex = 3; this.buttonDeleteBus.TabIndex = 3;
this.buttonDeleteBus.Text = "Удалить автобус"; this.buttonDeleteBus.Text = "Удалить автобус";
this.buttonDeleteBus.UseVisualStyleBackColor = true; this.buttonDeleteBus.UseVisualStyleBackColor = true;
@ -232,19 +208,17 @@
// //
// maskedTextBoxPosition // maskedTextBoxPosition
// //
this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 545); this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 493);
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(214, 27); this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
this.maskedTextBoxPosition.TabIndex = 2; this.maskedTextBoxPosition.TabIndex = 2;
// //
// buttonAddBus // buttonAddBus
// //
this.buttonAddBus.Location = new System.Drawing.Point(7, 489); this.buttonAddBus.Location = new System.Drawing.Point(6, 451);
this.buttonAddBus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddBus.Name = "buttonAddBus"; this.buttonAddBus.Name = "buttonAddBus";
this.buttonAddBus.Size = new System.Drawing.Size(215, 48); this.buttonAddBus.Size = new System.Drawing.Size(188, 36);
this.buttonAddBus.TabIndex = 1; this.buttonAddBus.TabIndex = 1;
this.buttonAddBus.Text = "Добавить автобус"; this.buttonAddBus.Text = "Добавить автобус";
this.buttonAddBus.UseVisualStyleBackColor = true; this.buttonAddBus.UseVisualStyleBackColor = true;
@ -253,10 +227,9 @@
// pictureBox // pictureBox
// //
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, 24);
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pictureBox.Name = "pictureBox"; this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(737, 829); this.pictureBox.Size = new System.Drawing.Size(645, 710);
this.pictureBox.TabIndex = 1; this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false; this.pictureBox.TabStop = false;
// //
@ -267,7 +240,8 @@
this.FileToolStripMenuItem}); this.FileToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(966, 28); this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(845, 24);
this.menuStrip1.TabIndex = 2; this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -277,20 +251,20 @@
this.SaveToolStripMenuItem, this.SaveToolStripMenuItem,
this.LoadToolStripMenuItem}); this.LoadToolStripMenuItem});
this.FileToolStripMenuItem.Name = "FileToolStripMenuItem"; this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";
this.FileToolStripMenuItem.Size = new System.Drawing.Size(59, 24); this.FileToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.FileToolStripMenuItem.Text = "Файл"; this.FileToolStripMenuItem.Text = "Файл";
// //
// SaveToolStripMenuItem // SaveToolStripMenuItem
// //
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26); this.SaveToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.SaveToolStripMenuItem.Text = "Сохранение"; this.SaveToolStripMenuItem.Text = "Сохранение";
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
// //
// LoadToolStripMenuItem // LoadToolStripMenuItem
// //
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26); this.LoadToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.LoadToolStripMenuItem.Text = "Загрузка"; this.LoadToolStripMenuItem.Text = "Загрузка";
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
// //
@ -303,16 +277,55 @@
// //
this.saveFileDialog.Filter = "txt file | *.txt"; this.saveFileDialog.Filter = "txt file | *.txt";
// //
// button1
//
this.button1.Location = new System.Drawing.Point(6, 605);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(182, 35);
this.button1.TabIndex = 5;
this.button1.Text = "Посмотреть карту";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(6, 564);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(182, 35);
this.buttonShowStorage.TabIndex = 4;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
//
// ButtonSortByColor
//
this.ButtonSortByColor.Location = new System.Drawing.Point(12, 402);
this.ButtonSortByColor.Name = "ButtonSortByColor";
this.ButtonSortByColor.Size = new System.Drawing.Size(182, 35);
this.ButtonSortByColor.TabIndex = 13;
this.ButtonSortByColor.Text = "Сортировать по цвету";
this.ButtonSortByColor.UseVisualStyleBackColor = true;
this.ButtonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click);
//
// ButtonSortByType
//
this.ButtonSortByType.Location = new System.Drawing.Point(12, 361);
this.ButtonSortByType.Name = "ButtonSortByType";
this.ButtonSortByType.Size = new System.Drawing.Size(182, 35);
this.ButtonSortByType.TabIndex = 12;
this.ButtonSortByType.Text = "Сортировать по типу";
this.ButtonSortByType.UseVisualStyleBackColor = true;
this.ButtonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click);
//
// FormMapWithSetBuses // FormMapWithSetBuses
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(966, 857); this.ClientSize = new System.Drawing.Size(845, 734);
this.Controls.Add(this.pictureBox); this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxSettings); this.Controls.Add(this.groupBoxSettings);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormMapWithSetBuses"; this.Name = "FormMapWithSetBuses";
this.Text = "Карты с набором объектов"; this.Text = "Карты с набором объектов";
this.groupBoxSettings.ResumeLayout(false); this.groupBoxSettings.ResumeLayout(false);
@ -334,8 +347,6 @@
private Button buttonAddBus; private Button buttonAddBus;
private Button buttonDeleteBus; private Button buttonDeleteBus;
private MaskedTextBox maskedTextBoxPosition; private MaskedTextBox maskedTextBoxPosition;
private Button buttonShowStorage;
private Button button1;
private Button buttonRight; private Button buttonRight;
private Button buttonDown; private Button buttonDown;
private Button buttonLeft; private Button buttonLeft;
@ -352,5 +363,9 @@
private ToolStripMenuItem LoadToolStripMenuItem; private ToolStripMenuItem LoadToolStripMenuItem;
private OpenFileDialog openFileDialog; private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog; private SaveFileDialog saveFileDialog;
private Button ButtonSortByColor;
private Button ButtonSortByType;
private Button button1;
private Button buttonShowStorage;
} }
} }

View File

@ -248,6 +248,20 @@ namespace DoubleDeckerBus
} }
} }
} }
private void ButtonSortByType_Click(object sender, EventArgs e)
{
if (listBoxMaps.SelectedIndex == -1) {
return;
}
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].Sort(new BusCompareByType());
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
// TODO прописать логику
}
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace DoubleDeckerBus namespace DoubleDeckerBus
{ {
internal interface IDrawingObject internal interface IDrawingObject : IEquatable<IDrawingObject>
{ {
public DrawingBus getBus(); public DrawingBus getBus();
public float Step { get; } public float Step { get; }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace DoubleDeckerBus namespace DoubleDeckerBus
{ {
internal class MapWithSetBusesGeneric<T, U> internal class MapWithSetBusesGeneric<T, U>
where T : class, IDrawingObject where T : class, IDrawingObject, IEquatable<T>
where U : AbstractMap where U : AbstractMap
{ {
@ -158,5 +158,9 @@ namespace DoubleDeckerBus
_setBuses.Insert(DrawingObjectBus.Create(rec) as T); _setBuses.Insert(DrawingObjectBus.Create(rec) as T);
} }
} }
public void Sort(IComparer<T> comparer) {
_setBuses.SortSet(comparer);
}
} }
} }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace DoubleDeckerBus namespace DoubleDeckerBus
{ {
internal class SetBusesGeneric<T> internal class SetBusesGeneric<T>
where T : IDrawingObject where T : class, IEquatable<T>
{ {
private readonly List<T> _places; private readonly List<T> _places;
@ -29,6 +29,8 @@ namespace DoubleDeckerBus
public int Insert(T bus, int position) public int Insert(T bus, int position)
{ {
// TODO Проверка на уникальность
if (position < 0 || position >= _maxCount) if (position < 0 || position >= _maxCount)
{ {
throw new BusNotFoundException("Место указано неверно"); throw new BusNotFoundException("Место указано неверно");
@ -75,5 +77,12 @@ namespace DoubleDeckerBus
} }
} }
} }
public void SortSet(IComparer<T> comparer) {
if (comparer == null) {
return;
}
_places.Sort(comparer);
}
} }
} }