ISEbd-11_Kotova_M_D_Labwork8_Simple #13

Closed
MariaKotova wants to merge 1 commits from Labwork8 into Labwork7
13 changed files with 400 additions and 45 deletions
Showing only changes of commit ffa8212cec - Show all commits

View File

@ -56,7 +56,7 @@ public abstract class AbstractCompany
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawingExcavatorEmpty excavator)
{
return company._collection.Insert(excavator);
return company._collection.Insert(excavator, new DrawningExcavatorEqutables());
}
/// <summary>
@ -115,4 +115,10 @@ public abstract class AbstractCompany
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawingExcavatorEmpty?> comparer) => _collection?.CollectionSort(comparer);
}

View File

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormsAppExcavator.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 WinFormsAppExcavator.CollectionGenericObjects;
using WinFormsAppExcavator.Drawings;
namespace WinFormsAppExcavator.CollectionGenericObjects;
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
@ -22,7 +24,7 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<T?>? compaper = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
@ -30,7 +32,7 @@ public interface ICollectionGenericObjects<T>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
int Insert(T obj, int position, IEqualityComparer<T?>? compaper = null);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
@ -54,5 +56,11 @@ 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,6 @@

using ProjectWarmlyShip.Exceptions;
using WinFormsAppExcavator.Drawings;
using WinFormsAppExcavator.Exceptions;
namespace WinFormsAppExcavator.CollectionGenericObjects;
@ -44,14 +46,28 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? compaper = null)
{
if (compaper != null)
{
if (_collection.Contains(obj, compaper))
{
throw new ObjectIsEqualException();
}
}
if (Count == _maxCount) throw new CollectionOverflowException();
_collection.Add(obj);
return Count;
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? compaper = null)
{
if (compaper != null)
{
if (_collection.Contains(obj, compaper))
{
throw new ObjectIsEqualException();
}
}
if (Count == _maxCount) throw new CollectionOverflowException(Count);
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
_collection.Insert(position, obj);
@ -72,4 +88,9 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}

View File

@ -1,4 +1,6 @@

using ProjectWarmlyShip.Exceptions;
using WinFormsAppExcavator.Drawings;
using WinFormsAppExcavator.Exceptions;
namespace WinFormsAppExcavator.CollectionGenericObjects;
@ -55,8 +57,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? compaper = null)
{
if (compaper != null)
{
foreach (T? item in _collection)
{
if ((compaper as IEqualityComparer<DrawingExcavatorEmpty>).Equals(obj as DrawingExcavatorEmpty, item as DrawingExcavatorEmpty))
throw new ObjectIsEqualException();
}
}
int index = 0;
while (index < _collection.Length)
{
@ -72,8 +82,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? compaper = null)
{
if (compaper != null)
{
foreach (T? item in _collection)
{
if ((compaper as IEqualityComparer<DrawingExcavatorEmpty>).Equals(obj as DrawingExcavatorEmpty, item as DrawingExcavatorEmpty))
throw new ObjectIsEqualException();
}
}
if (position >= _collection.Length || position < 0)
{
throw new PositionOutOfCollectionException(position);
@ -125,4 +143,9 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
}
}

View File

@ -13,17 +13,17 @@ public class StorageCollection<T>
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
public List<CollectionInfo> Keys => _storages.Keys.ToList();
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Добавление коллекции в хранилище
@ -34,13 +34,13 @@ public class StorageCollection<T>
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (_storages.ContainsKey(name)) return;
CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
if (_storages.ContainsKey(collectionInfo)) return;
if (collectionType == CollectionType.None) return;
else if (collectionType == CollectionType.Massive)
_storages[name] = new MassiveGenericObjects<T>();
_storages[collectionInfo] = new MassiveGenericObjects<T>();
else if (collectionType == CollectionType.List)
_storages[name] = new ListGenericObjects<T>();
_storages[collectionInfo] = new ListGenericObjects<T>();
}
/// <summary>
/// Удаление коллекции
@ -48,9 +48,9 @@ public class StorageCollection<T>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
// TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name))
_storages.Remove(name);
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
if (_storages.ContainsKey(collectionInfo))
_storages.Remove(collectionInfo);
}
/// <summary>
@ -62,9 +62,10 @@ public class StorageCollection<T>
{
get
{
// TODO Продумать логику получения объекта
if (_storages.ContainsKey(name))
return _storages[name];
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
if (_storages.ContainsKey(collectionInfo))
return _storages[collectionInfo];
return null;
@ -105,7 +106,7 @@ public class StorageCollection<T>
using (StreamWriter writer = new StreamWriter(filename))
{
writer.Write(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
@ -115,8 +116,6 @@ public class StorageCollection<T>
}
sb.Append(value.Key);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.GetCollectionType);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.MaxCount);
sb.Append(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
@ -161,18 +160,19 @@ public class StorageCollection<T>
while ((strs = fs.ReadLine()) != null)
{
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4)
if (record.Length != 3)
{
continue;
}
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ?? throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType);
if (collection == null)
{
throw new Exception("Не удалось создать коллекцию");
}
collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
if (elem?.CreateDrawningExcavatorEmpty() is T excavator)
@ -190,7 +190,7 @@ public class StorageCollection<T>
}
}
}
_storages.Add(record[0], collection);
_storages.Add(collectionInfo, collection);
}
}
}

View File

@ -0,0 +1,68 @@

using System.Diagnostics.CodeAnalysis;
using WinFormsAppExcavator.Entity;
namespace WinFormsAppExcavator.Drawings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawningExcavatorEqutables : IEqualityComparer<DrawingExcavatorEmpty?>
{
public bool Equals(DrawingExcavatorEmpty? x, DrawingExcavatorEmpty? y)
{
if (x == null || x.EntityExcavatorEmpty == null)
{
return false;
}
if (y == null || y.EntityExcavatorEmpty == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityExcavatorEmpty.Speed != y.EntityExcavatorEmpty.Speed)
{
return false;
}
if (x.EntityExcavatorEmpty.Weight != y.EntityExcavatorEmpty.Weight)
{
return false;
}
if (x.EntityExcavatorEmpty.BodyColor != y.EntityExcavatorEmpty.BodyColor)
{
return false;
}
if (x is EntityExcavator && y is EntityExcavator)
{
// TODO доделать логику сравнения дополнительных параметров
EntityExcavator _x = (EntityExcavator)x.EntityExcavatorEmpty;
EntityExcavator _y = (EntityExcavator)x.EntityExcavatorEmpty;
if (_x.AdditionalColor != _y.AdditionalColor)
{
return false;
}
if (_x.Bucket != _y.Bucket)
{
return false;
}
if (_x.BulldozerDump != _y.BulldozerDump)
{
return false;
}
if (_x.Support != _y.Support)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawingExcavatorEmpty? obj)
{
return obj.GetHashCode();
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormsAppExcavator.Drawings;
/// <summary>
/// сравнение по цвету, скорости и весу
/// </summary>
public class ExcavatorCompareByColor : IComparer<DrawingExcavatorEmpty?>
{
public int Compare(DrawingExcavatorEmpty? x, DrawingExcavatorEmpty? y)
{
if (x == null || x.EntityExcavatorEmpty == null)
{
return 1;
}
if (y == null || y.EntityExcavatorEmpty == null)
{
return -1;
}
var bodycolorCompare = x.EntityExcavatorEmpty.BodyColor.Name.CompareTo(y.EntityExcavatorEmpty.BodyColor.Name);
if (bodycolorCompare != 0)
{
return bodycolorCompare;
}
var speedCompare = x.EntityExcavatorEmpty.Speed.CompareTo(y.EntityExcavatorEmpty.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityExcavatorEmpty.Weight.CompareTo(y.EntityExcavatorEmpty.Weight);
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormsAppExcavator.Drawings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class ExcavatorCompareByType : IComparer<DrawingExcavatorEmpty?>
{
public int Compare(DrawingExcavatorEmpty? x, DrawingExcavatorEmpty? y)
{
if (x == null || x.EntityExcavatorEmpty == null)
{
return 1;
}
if (y == null || y.EntityExcavatorEmpty == null)
{
return -1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityExcavatorEmpty.Speed.CompareTo(y.EntityExcavatorEmpty.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityExcavatorEmpty.Weight.CompareTo(y.EntityExcavatorEmpty.Weight);
}
}

View File

@ -0,0 +1,16 @@
using System.Runtime.Serialization;
namespace ProjectWarmlyShip.Exceptions;
/// <summary>
/// Класс, описывающий ошибку переполнения коллекции
/// </summary>
[Serializable]
public class ObjectIsEqualException : ApplicationException
{
public ObjectIsEqualException(int count) : base("В коллекции содержится равный элемент: " + count) { }
public ObjectIsEqualException() : base() { }
public ObjectIsEqualException(string message) : base(message) { }
public ObjectIsEqualException(string message, Exception exception) : base(message, exception) { }
protected ObjectIsEqualException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@ -52,6 +52,8 @@
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog();
buttonSortByType = new Button();
buttonSortByColor = new Button();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
@ -68,13 +70,15 @@
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(642, 28);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(220, 491);
groupBoxTools.Size = new Size(220, 555);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonAddExcavatorEmpty);
panelCompanyTools.Controls.Add(buttonGoToCheck);
@ -82,9 +86,9 @@
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 314);
panelCompanyTools.Location = new Point(3, 319);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(214, 174);
panelCompanyTools.Size = new Size(214, 233);
panelCompanyTools.TabIndex = 9;
//
// maskedTextBox
@ -110,7 +114,7 @@
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(6, 107);
buttonGoToCheck.Location = new Point(8, 107);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(206, 29);
buttonGoToCheck.TabIndex = 5;
@ -121,7 +125,7 @@
// buttonRemoveExcavator
//
buttonRemoveExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveExcavator.Location = new Point(5, 71);
buttonRemoveExcavator.Location = new Point(8, 71);
buttonRemoveExcavator.Name = "buttonRemoveExcavator";
buttonRemoveExcavator.Size = new Size(206, 30);
buttonRemoveExcavator.TabIndex = 4;
@ -132,7 +136,7 @@
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(3, 142);
buttonRefresh.Location = new Point(8, 142);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(206, 27);
buttonRefresh.TabIndex = 6;
@ -248,7 +252,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 28);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(642, 491);
pictureBox.Size = new Size(642, 555);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@ -293,11 +297,33 @@
//
openFileDialog.Filter = "txt file | *.txt";
//
// buttonSortByType
//
buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSortByType.Location = new Point(5, 175);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(206, 29);
buttonSortByType.TabIndex = 7;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += buttonSortByType_Click;
//
// buttonSortByColor
//
buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSortByColor.Location = new Point(6, 206);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(206, 27);
buttonSortByColor.TabIndex = 8;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += buttonSortByColor_Click;
//
// FormExcavatorCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(862, 519);
ClientSize = new Size(862, 583);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
@ -342,5 +368,7 @@
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button buttonSortByType;
private Button buttonSortByColor;
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using ProjectWarmlyShip.Exceptions;
using System.Windows.Forms;
using WinFormsAppExcavator.CollectionGenericObjects;
using WinFormsAppExcavator.Drawings;
@ -24,7 +25,7 @@ public partial class FormExcavatorCollection : Form
/// <summary>
/// Конструктор
/// </summary>
public FormExcavatorCollection(ILogger<FormExcavatorCollection> logger)
public FormExcavatorCollection(ILogger<FormExcavatorCollection> logger)
{
InitializeComponent();
_storageCollection = new();
@ -75,13 +76,19 @@ public partial class FormExcavatorCollection : Form
catch (ObjectNotFoundException) { }
catch (CollectionOverflowException ex)
{
MessageBox.Show("Не удалось добавить объект");
MessageBox.Show("Не удалось добавить объект1");
_logger.LogError("Ошибка: {Message}", ex.Message);
}
catch (PositionOutOfCollectionException ex) {
catch (PositionOutOfCollectionException ex)
{
MessageBox.Show("Выход за границы коллекции");
_logger.LogError("Ошибка: {Message}", ex.Message);
}
catch (ObjectIsEqualException ex)
{
MessageBox.Show("Не удалось добавить объект");
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
/// <summary>
/// Удаление объекта
@ -210,7 +217,7 @@ public partial class FormExcavatorCollection : 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);
@ -283,7 +290,7 @@ public partial class FormExcavatorCollection : Form
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
try
{
_storageCollection.SaveData(saveFileDialog.FileName);
MessageBox.Show("Сохранение прошло успешно",
@ -291,7 +298,7 @@ public partial class FormExcavatorCollection : Form
_logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
}
catch(Exception ex)
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка: {Message}", ex.Message);
@ -324,6 +331,38 @@ public partial class FormExcavatorCollection : Form
}
}
/// <summary>
/// Сортировка по типу
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonSortByType_Click(object sender, EventArgs e)
{
CompareExcavators(new ExcavatorCompareByType());
}
/// <summary>
/// Cортировка по цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonSortByColor_Click(object sender, EventArgs e)
{
CompareExcavators(new ExcavatorCompareByColor());
}
/// <summary>
/// Сортировка по сравнителю
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
private void CompareExcavators(IComparer<DrawingExcavatorEmpty?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox.Image = _company.Show();
}
}

View File

@ -127,6 +127,6 @@
<value>310, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>61</value>
<value>123</value>
</metadata>
</root>