PIbd-12 Shurygin D.I. LabWork08 Simple #9

Closed
ShuryginDima wants to merge 1 commits from LabWork08 into LabWork07
13 changed files with 417 additions and 81 deletions

View File

@ -64,7 +64,7 @@ public abstract class AbstractCompany
{
return -1;
}
return company._collection.Insert(plane);
return company._collection.Insert(plane, new DrawiningPlaneEqutables());
}
/// <summary>
@ -118,6 +118,12 @@ public abstract class AbstractCompany
return bitmap;
}
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawningPlane?> comparer) => _collection?.CollectionSort(comparer);
/// <summary>
/// Вывод заднего фона
/// </summary>

View File

@ -0,0 +1,77 @@
using ProjectSeaplane.CollectionGenericObjects;
namespace ProjectSeaplane.CollectionGenericObjects;
/// <summary>
/// Класс, хранящиий информацию по коллекции
/// </summary>
public class CollectionInfo : IEquatable<CollectionInfo>
{
/// <summary>
/// Название
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Тип
/// </summary>
public CollectionType CollectionType { get; private set; }
/// <summary>
/// Описание
/// </summary>
public string Description { get; private set; }
/// <summary>
/// Разделитель для записи информации по объекту в файл
/// </summary>
private static readonly string _separator = "-";
/// <summary>
/// Конструктор
/// </summary>
/// <param name="name">Название</param>
/// <param name="collectionType">Тип</param>
/// <param name="description">Описание</param>
public CollectionInfo(string name, CollectionType collectionType, string
description)
{
Name = name;
CollectionType = collectionType;
Description = description;
}
/// <summary>
/// Создание объекта из строки
/// </summary>
/// <param name="data">Строка</param>
/// <returns>Объект или null</returns>
public static CollectionInfo? GetCollectionInfo(string data)
{
string[] strs = data.Split(_separator,
StringSplitOptions.RemoveEmptyEntries);
if (strs.Length < 1 || strs.Length > 3)
{
return null;
}
return new CollectionInfo(strs[0],
(CollectionType)Enum.Parse(typeof(CollectionType), strs[1]), strs.Length > 2 ?
strs[2] : string.Empty);
}
public override string ToString()
{
return Name + _separator + CollectionType + _separator + Description;
}
public bool Equals(CollectionInfo? other)
{
return Name == other?.Name;
}
public override bool Equals(object? obj)
{
return Equals(obj as CollectionInfo);
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
}

View File

@ -1,4 +1,6 @@
namespace ProjectSeaplane.CollectionGenericObjects;
using ProjectSeaplane.Drawnings;
namespace ProjectSeaplane.CollectionGenericObjects;
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
@ -21,16 +23,18 @@ public interface ICollectionGenericObjects<T>
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="comparer">Cравнение двух объектов</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <param name="comparer">Cравнение двух объектов</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
@ -56,4 +60,10 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
/// <summary>
/// Сортировка коллекции
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
void CollectionSort(IComparer<T?> comparer);
}

View File

@ -1,4 +1,5 @@
using ProjectSeaplane.Exceptions;
using ProjectSeaplane.Drawnings;
using ProjectSeaplane.Exceptions;
namespace ProjectSeaplane.CollectionGenericObjects;
@ -22,7 +23,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public int MaxCount {
get
{
return _collection.Count;
return _maxCount;
}
set
{
@ -54,24 +55,29 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
throw new PositionOutOfCollectionException(position);
}
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
return Insert(obj, _collection.Count);
return Insert(obj, Count, comparer);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (position > MaxCount) throw new CollectionOverflowException(position);
if (obj == null) throw new ArgumentNullException(nameof(obj));
if (_collection.Contains(obj, comparer))
{
throw new ObjectNotUniqueException();
}
if (Count >= _maxCount)
{
throw new CollectionOverflowException(Count);
}
_collection.Insert(position, obj);
return _collection.Count;
return Count;
}
public T? Remove(int position)
{
try
{
T obj = _collection[position];
T? obj = _collection[position];
_collection.RemoveAt(position);
return obj;
}
@ -83,9 +89,14 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < _collection.Count; ++i)
for (int i = 0; i < Count; ++i)
{
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}

View File

@ -63,21 +63,25 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
}
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
return Insert(obj, 0);
return Insert(obj, 0, comparer);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (position < 0)
// DO
if (position < 0 || position > _collection.Length - 1)
{
return -1;
throw new PositionOutOfCollectionException();
}
if (_collection[position] == null)
if (comparer != null)
{
_collection[position] = obj;
return position;
foreach (T? item in _collection)
{
if ((comparer as IEqualityComparer<DrawningPlane>).Equals(obj as DrawningPlane, item as DrawningPlane))
throw new ObjectNotUniqueException();
}
}
for (int i = position; i < Count; i++)
@ -104,7 +108,10 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
try
{
T? obj = _collection[position];
if (obj == null) throw new ObjectNotFoundException(position);
if (obj == null)
{
throw new ObjectNotFoundException(position);
}
_collection[position] = null;
return obj;
}
@ -121,4 +128,10 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
Array.Reverse(_collection);
}
}

View File

@ -1,6 +1,7 @@
using ProjectSeaplane.Drawnings;
using System.Text;
using ProjectSeaplane.Exceptions;
using System.IO;
namespace ProjectSeaplane.CollectionGenericObjects;
@ -14,12 +15,12 @@ public class StorageCollection<T>
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storage;
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storage;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storage.Keys.ToList();
public List<CollectionInfo> Keys => _storage.Keys.ToList();
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
@ -41,7 +42,7 @@ public class StorageCollection<T>
/// </summary>
public StorageCollection()
{
_storage = new Dictionary<string, ICollectionGenericObjects<T>>();
_storage = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
@ -51,21 +52,22 @@ public class StorageCollection<T>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
{
if (string.IsNullOrEmpty(name) || _storage.ContainsKey(name))
// DO
CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
if (collectionInfo.Name == null || _storage.ContainsKey(collectionInfo))
{
return;
}
if (collectionType == CollectionType.None)
switch (collectionType)
{
return;
}
if (collectionType == CollectionType.Massive)
{
_storage[name] = new MassiveGenericObjects<T>();
}
else if (collectionType == CollectionType.List)
{
_storage[name] = new ListGenericObjects<T>();
case CollectionType.None:
return;
case CollectionType.Massive:
_storage.Add(collectionInfo, new MassiveGenericObjects<T> { });
return;
case CollectionType.List:
_storage.Add(collectionInfo, new ListGenericObjects<T> { });
return;
}
}
@ -75,11 +77,13 @@ public class StorageCollection<T>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
if (name == null || !_storage.ContainsKey(name))
// DO
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
if (collectionInfo.Name == null || !_storage.ContainsKey(collectionInfo))
{
return;
}
_storage.Remove(name);
_storage.Remove(collectionInfo);
}
/// <summary>
@ -89,16 +93,15 @@ public class StorageCollection<T>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
{
// DO
get
{
if (_storage.ContainsKey(name))
{
return _storage[name];
}
else
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
if (collectionInfo == null || !_storage.ContainsKey(collectionInfo))
{
return null;
}
return _storage[collectionInfo];
}
}
@ -121,16 +124,17 @@ public class StorageCollection<T>
using (StreamWriter writer = new StreamWriter(filename))
{
writer.WriteLine(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storage)
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storage)
{
writer.Write($"{value.Key}{_separatorForKeyValue}{value.Value.GetCollectionType}{_separatorForKeyValue}{value.Value.MaxCount}{_separatorForKeyValue}");
writer.Write(_separatorItems);
writer.Write($"{value.Key}{_separatorForKeyValue}{value.Value.MaxCount}{_separatorForKeyValue}");
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (!string.IsNullOrEmpty(data))
{
writer.Write(data + _separatorItems);
writer.Write(data);
writer.Write(_separatorItems);
}
}
}
@ -164,21 +168,18 @@ public class StorageCollection<T>
while (line != null)
{
string[] record = line.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4)
if (record.Length != 3)
{
line = reader.ReadLine();
continue;
}
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
if (collection == null)
{
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
throw new NullCollectionException("Не удалось создать коллекцию");
}
collection.MaxCount = Convert.ToInt32(record[2]);
collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
@ -195,7 +196,7 @@ public class StorageCollection<T>
}
}
_storage.Add(record[0], collection);
_storage.Add(collectionInfo, collection);
line = reader.ReadLine();
}
}

View File

@ -0,0 +1,69 @@
using ProjectSeaplane.Entities;
using System.Diagnostics.CodeAnalysis;
namespace ProjectSeaplane.Drawnings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawiningPlaneEqutables : IEqualityComparer<DrawningPlane?>
{
public bool Equals(DrawningPlane? x, DrawningPlane? y)
{
if (x == null || x.EntityPlane == null)
{
return false;
}
if (y == null || y.EntityPlane == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityPlane.Speed != y.EntityPlane.Speed)
{
return false;
}
if (x.EntityPlane.Weight != y.EntityPlane.Weight)
{
return false;
}
if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor)
{
return false;
}
if (x is DrawningSeaplane && y is DrawningSeaplane)
{
// DO доделать логику сравнения дополнительных параметров
EntitySeaplane _x = (EntitySeaplane)x.EntityPlane;
EntitySeaplane _y = (EntitySeaplane)x.EntityPlane;
if (_x.AdditionalColor != _y.AdditionalColor)
{
return false;
}
if (_x.Floats != _y.Floats)
{
return false;
}
if (_x.Boat != _y.Boat)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningPlane obj)
{
return obj.GetHashCode();
}
}

View File

@ -0,0 +1,39 @@
namespace ProjectSeaplane.Drawnings;
/// <summary>
/// Сравнение по цвету, скорости, весу
/// </summary>
public class DrawningPlaneCompareByColor : IComparer<DrawningPlane?>
{
public int Compare(DrawningPlane? x, DrawningPlane? y)
{
// DO прописать логику сравения по цветам, скорости, весу
if (x == null && y == null)
{
return 0;
}
if (x == null || x.EntityPlane == null)
{
return -1;
}
if (y == null || y.EntityPlane == null)
{
return 1;
}
var bodycolorCompare = y.EntityPlane.BodyColor.Name.CompareTo(x.EntityPlane.BodyColor.Name);
if (bodycolorCompare != 0)
{
return bodycolorCompare;
}
var speedCompare = y.EntityPlane.Speed.CompareTo(x.EntityPlane.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return y.EntityPlane.Weight.CompareTo(x.EntityPlane.Weight);
}
}

View File

@ -0,0 +1,33 @@
namespace ProjectSeaplane.Drawnings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class DrawningPlaneCompareByType : IComparer<DrawningPlane?>
{
public int Compare(DrawningPlane? x, DrawningPlane? y)
{
if (x == null && y == null)
{
return 0;
}
if (x == null || x.EntityPlane == null)
{
return -1;
}
if (y == null || y.EntityPlane == null)
{
return 1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight);
}
}

View File

@ -0,0 +1,15 @@
using System.Runtime.Serialization;
namespace ProjectSeaplane.Exceptions;
/// <summary>
/// Класс, описывающий ошибку наличия такого же объекта в коллекции
/// </summary>
[Serializable]
internal class ObjectNotUniqueException : ApplicationException
{
public ObjectNotUniqueException() : base("Такой объект уже присутствует в колекции") { }
public ObjectNotUniqueException(string message) : base(message) { }
public ObjectNotUniqueException(string message, Exception exception) : base(message, exception) { }
protected ObjectNotUniqueException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@ -52,6 +52,8 @@
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
loadFileDialog = new OpenFileDialog();
buttonSortByType = new Button();
buttonSortByColor = new Button();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
@ -66,15 +68,17 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(793, 24);
groupBoxTools.Location = new Point(818, 24);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(144, 575);
groupBoxTools.Size = new Size(144, 621);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(buttonAddPlane);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
@ -84,7 +88,7 @@
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 324);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(138, 248);
panelCompanyTools.Size = new Size(138, 294);
panelCompanyTools.TabIndex = 10;
//
// buttonAddPlane
@ -99,7 +103,7 @@
//
// buttonRefresh
//
buttonRefresh.Location = new Point(3, 202);
buttonRefresh.Location = new Point(3, 152);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(126, 42);
buttonRefresh.TabIndex = 6;
@ -109,7 +113,7 @@
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(4, 101);
maskedTextBoxPosition.Location = new Point(3, 51);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(126, 23);
@ -118,7 +122,7 @@
//
// buttonGoToCheck
//
buttonGoToCheck.Location = new Point(4, 166);
buttonGoToCheck.Location = new Point(3, 116);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(126, 30);
buttonGoToCheck.TabIndex = 5;
@ -128,7 +132,7 @@
//
// buttonRemovePlane
//
buttonRemovePlane.Location = new Point(4, 130);
buttonRemovePlane.Location = new Point(3, 80);
buttonRemovePlane.Name = "buttonRemovePlane";
buttonRemovePlane.Size = new Size(126, 30);
buttonRemovePlane.TabIndex = 4;
@ -247,7 +251,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(793, 575);
pictureBox.Size = new Size(818, 621);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@ -256,7 +260,7 @@
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(937, 24);
menuStrip.Size = new Size(962, 24);
menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip";
//
@ -267,17 +271,17 @@
файлToolStripMenuItem.Size = new Size(48, 20);
файлToolStripMenuItem.Text = "Файл";
//
// SaveToolStripMenuItem
// saveToolStripMenuItem
//
saveToolStripMenuItem.Name = "SaveToolStripMenuItem";
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(181, 22);
saveToolStripMenuItem.Text = "Сохранение";
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
//
// LoadToolStripMenuItem
// loadToolStripMenuItem
//
loadToolStripMenuItem.Name = "LoadToolStripMenuItem";
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(181, 22);
loadToolStripMenuItem.Text = "Загрузка";
@ -287,15 +291,35 @@
//
saveFileDialog.Filter = "txt file | *.txt";
//
// openFileDialog
// loadFileDialog
//
loadFileDialog.Filter = "txt file | *.txt";
//
// buttonSortByType
//
buttonSortByType.Location = new Point(4, 200);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(126, 42);
buttonSortByType.TabIndex = 7;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += ButtonSortByType_Click;
//
// buttonSortByColor
//
buttonSortByColor.Location = new Point(3, 248);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(126, 42);
buttonSortByColor.TabIndex = 8;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += ButtonSortByColor_Click;
//
// FormPlaneCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(937, 599);
ClientSize = new Size(962, 645);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
@ -340,5 +364,7 @@
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog loadFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
}
}

View File

@ -63,7 +63,7 @@ public partial class FormPlaneCollection : Form
/// <param name="plane"></param>
private void SetPlane(DrawningPlane plane)
{
if (_company == null)
if (_company == null || plane == null)
{
return;
}
@ -223,7 +223,7 @@ public partial class FormPlaneCollection : Form
listBoxCollection.Items.Clear();
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
{
string? colName = _storageCollection.Keys?[i];
string? colName = _storageCollection.Keys?[i].Name;
if (!string.IsNullOrEmpty(colName))
{
listBoxCollection.Items.Add(colName);
@ -302,7 +302,7 @@ public partial class FormPlaneCollection : Form
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Загрузка прошла успешно из файла, {filename}", loadFileDialog.FileName);
}
catch(Exception ex)
catch (Exception ex)
{
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка {Message}", ex.Message);
@ -310,4 +310,40 @@ public partial class FormPlaneCollection : Form
RefreshListBoxItems();
}
}
/// <summary>
/// Сортировка по типу
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByType_Click(object sender, EventArgs e)
{
ComparePlanes(new DrawningPlaneCompareByType());
}
/// <summary>
/// Сортировка по цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
ComparePlanes(new DrawningPlaneCompareByColor());
}
/// <summary>
/// Сортировка по сравнителю
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
private void ComparePlanes(IComparer<DrawningPlane?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox.Image = _company.Show();
}
}

View File

@ -118,12 +118,12 @@
<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>
<value>146, 17</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value>
<value>255, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>261, 17</value>
<metadata name="loadFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>