Compare commits
No commits in common. "f705ead5c2cda695d37292ef2fbeeac4dc724484" and "eac299fe2c3186ad1acdfa9e4ee67ec4c3aa031d" have entirely different histories.
f705ead5c2
...
eac299fe2c
@ -56,7 +56,7 @@ public abstract class AbstractCompany
|
||||
/// <returns></returns>
|
||||
public static int operator +(AbstractCompany company, DrawningStormtrooperBase stormtrooper)
|
||||
{
|
||||
return company._collection.Insert(stormtrooper, new DrawinigStormtrooperBaseEqutables());
|
||||
return company._collection.Insert(stormtrooper);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора удаления для класса
|
||||
@ -108,9 +108,4 @@ public abstract class AbstractCompany
|
||||
/// Расстановка объектов
|
||||
/// </summary>
|
||||
protected abstract void SetObjectsPosition();
|
||||
/// <summary>
|
||||
/// Сортировка
|
||||
/// </summary>
|
||||
/// <param name="comparer">Сравнитель объектов</param>
|
||||
public void Sort(IComparer<DrawningStormtrooperBase?> comparer) => _collection?.CollectionSort(comparer);
|
||||
}
|
||||
|
@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.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></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();
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -25,17 +24,15 @@ public interface ICollectionGenericObjects<T>
|
||||
/// Добавление объекта в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="obj">Добавление объекта</param>
|
||||
/// <param name="comparer">Cравнение двух объектов</param>
|
||||
/// <returns> true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
|
||||
int Insert(T obj);
|
||||
/// <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, IEqualityComparer<T?>? comparer = null);
|
||||
int Insert(T obj, int position);
|
||||
/// <summary>
|
||||
/// Удаление объекта из коллекции с конкретной позиции
|
||||
/// </summary>
|
||||
@ -58,10 +55,5 @@ public interface ICollectionGenericObjects<T>
|
||||
/// </summary>
|
||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||
IEnumerable<T?> GetItems();
|
||||
/// <summary>
|
||||
/// Сортировка коллекции
|
||||
/// </summary>
|
||||
/// <param name="comparer">Сравнитель объектов</param>
|
||||
void CollectionSort(IComparer<T?> comparer);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using ProjectStormtrooper.Exceptions;
|
||||
using ProjectStormtrooper.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -54,35 +53,21 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
||||
public int Insert(T obj)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO вставка в конец набора
|
||||
if (comparer != null)
|
||||
{
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
throw new ObjectIsEqualException();
|
||||
}
|
||||
}
|
||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
||||
_collection.Add(obj);
|
||||
return Count;
|
||||
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO проверка позиции
|
||||
// TODO вставка по позиции
|
||||
if (comparer != null)
|
||||
{
|
||||
if (_collection.Contains(obj, comparer))
|
||||
{
|
||||
throw new ObjectIsEqualException();
|
||||
}
|
||||
}
|
||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
||||
_collection.Insert(position, obj);
|
||||
@ -106,8 +91,4 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
||||
{
|
||||
_collection.Sort(comparer);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using ProjectStormtrooper.Exceptions;
|
||||
using ProjectStormtrooper.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -59,16 +58,8 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
||||
public int Insert(T obj)
|
||||
{
|
||||
if (comparer != null)
|
||||
{
|
||||
foreach(T? item in _collection)
|
||||
{
|
||||
if ((comparer as IEqualityComparer<DrawningStormtrooperBase>).Equals(obj as DrawningStormtrooperBase, item as DrawningStormtrooperBase))
|
||||
throw new ObjectIsEqualException();
|
||||
}
|
||||
}
|
||||
// TODO вставка в свободное место набора
|
||||
int index = 0;
|
||||
while ( index < _collection.Length)
|
||||
@ -83,21 +74,13 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
throw new CollectionOverflowException(Count);
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
// ищется свободное место после этой позиции и идет вставка туда
|
||||
// если нет после, ищем до
|
||||
// TODO вставка
|
||||
if (comparer != null)
|
||||
{
|
||||
foreach (T? item in _collection)
|
||||
{
|
||||
if ((comparer as IEqualityComparer<DrawningStormtrooperBase>).Equals(obj as DrawningStormtrooperBase, item as DrawningStormtrooperBase))
|
||||
throw new ObjectIsEqualException();
|
||||
}
|
||||
}
|
||||
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
||||
if (_collection[position] == null)
|
||||
{
|
||||
@ -145,8 +128,4 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
||||
{
|
||||
Array.Sort(_collection, comparer);
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,17 @@ public class StorageCollection<T>
|
||||
/// <summary>
|
||||
/// Словарь(хранилище) с коллекциями
|
||||
/// </summary>
|
||||
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий коллекций
|
||||
/// </summary>
|
||||
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
||||
public List<string> Keys => _storages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public StorageCollection()
|
||||
{
|
||||
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
|
||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление коллекции в хранилище
|
||||
@ -38,13 +38,17 @@ public class StorageCollection<T>
|
||||
{
|
||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||
// TODO Прописать логику для добавления
|
||||
CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
|
||||
if (_storages.ContainsKey(collectionInfo)) return;
|
||||
if (collectionType == CollectionType.None) return;
|
||||
else if (collectionType == CollectionType.Massive)
|
||||
_storages[collectionInfo] = new MassiveGenericObjects<T>();
|
||||
else if (collectionType == CollectionType.List)
|
||||
_storages[collectionInfo] = new ListGenericObjects<T>();
|
||||
if (!(collectionType == CollectionType.None) && !_storages.ContainsKey(name))
|
||||
{
|
||||
if (collectionType == CollectionType.List)
|
||||
{
|
||||
_storages.Add(name, new ListGenericObjects<T>());
|
||||
}
|
||||
else if (collectionType == CollectionType.Massive)
|
||||
{
|
||||
_storages.Add(name, new MassiveGenericObjects<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
@ -53,10 +57,9 @@ public class StorageCollection<T>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления коллекции
|
||||
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
||||
if (_storages.ContainsKey(collectionInfo))
|
||||
if (_storages.ContainsKey(name))
|
||||
{
|
||||
_storages.Remove(collectionInfo);
|
||||
_storages.Remove(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -70,9 +73,8 @@ public class StorageCollection<T>
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
||||
if (_storages.ContainsKey(collectionInfo))
|
||||
return _storages[collectionInfo];
|
||||
if (_storages.ContainsKey(name))
|
||||
return _storages[name];
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -108,7 +110,7 @@ public class StorageCollection<T>
|
||||
using (StreamWriter writer = new StreamWriter(filename))
|
||||
{
|
||||
writer.Write(_collectionKey);
|
||||
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
|
||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||
{
|
||||
writer.Write(Environment.NewLine);
|
||||
if (value.Value.Count == 0)
|
||||
@ -162,20 +164,18 @@ public class StorageCollection<T>
|
||||
while ((strs = fs.ReadLine()) != null)
|
||||
{
|
||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 3)
|
||||
if (record.Length != 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
|
||||
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
|
||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
|
||||
throw new Exception("Не удалось создать коллекцию");
|
||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
||||
if (collection == null)
|
||||
{
|
||||
throw new Exception("Не удалось создать коллекцию");
|
||||
}
|
||||
collection.MaxCount = Convert.ToInt32(record[1]);
|
||||
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
if (elem?.CreateDrawningStormtrooper() is T stormtrooper)
|
||||
@ -195,7 +195,7 @@ public class StorageCollection<T>
|
||||
|
||||
}
|
||||
}
|
||||
_storages.Add(collectionInfo, collection);
|
||||
_storages.Add(record[0], collection);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
using ProjectStormtrooper.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings;
|
||||
|
||||
public class DrawinigStormtrooperBaseEqutables: IEqualityComparer<DrawningStormtrooperBase>
|
||||
{
|
||||
public bool Equals(DrawningStormtrooperBase? x, DrawningStormtrooperBase? y)
|
||||
{
|
||||
if (x == null || x.EntityStormtrooperBase == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(y==null || y.EntityStormtrooperBase == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityStormtrooperBase.Speed!= y.EntityStormtrooperBase.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityStormtrooperBase.Weight != y.EntityStormtrooperBase.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityStormtrooperBase.BodyColor != y.EntityStormtrooperBase.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x is DrawingStormtrooper && y is DrawingStormtrooper)
|
||||
{
|
||||
EntityStormtrooper _x = (EntityStormtrooper)x.EntityStormtrooperBase;
|
||||
EntityStormtrooper _y = (EntityStormtrooper)x.EntityStormtrooperBase;
|
||||
if (_x.AdditionalColor != _y.AdditionalColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_x.Bombs != _y.Bombs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_x.Rockets != _y.Rockets)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public int GetHashCode([DisallowNull] DrawningStormtrooperBase obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings;
|
||||
/// <summary>
|
||||
/// Сравнению по цвету, скорости, весу
|
||||
/// </summary>
|
||||
public class DrawningStormtrooperBaseByColor:IComparer<DrawningStormtrooperBase?>
|
||||
{
|
||||
public int Compare(DrawningStormtrooperBase? x, DrawningStormtrooperBase? y)
|
||||
{
|
||||
if (x == null || x.EntityStormtrooperBase == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (y == null || y.EntityStormtrooperBase == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var bodycolorCompare = x.EntityStormtrooperBase.BodyColor.Name.CompareTo(y.EntityStormtrooperBase.BodyColor.Name);
|
||||
if (bodycolorCompare != 0)
|
||||
{
|
||||
return bodycolorCompare;
|
||||
}
|
||||
var speedCompare = x.EntityStormtrooperBase.Speed.CompareTo(y.EntityStormtrooperBase.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityStormtrooperBase.Weight.CompareTo(y.EntityStormtrooperBase.Weight);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings;
|
||||
/// <summary>
|
||||
/// Сравнению по типу, скорости, весу
|
||||
/// </summary>
|
||||
public class DrawningStormtrooperBaseByType: IComparer<DrawningStormtrooperBase?>
|
||||
{
|
||||
public int Compare(DrawningStormtrooperBase? x, DrawningStormtrooperBase? y)
|
||||
{
|
||||
if (x == null || x.EntityStormtrooperBase == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (y == null || y.EntityStormtrooperBase == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
}
|
||||
var speedCompare = x.EntityStormtrooperBase.Speed.CompareTo(y.EntityStormtrooperBase.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityStormtrooperBase.Weight.CompareTo(y.EntityStormtrooperBase.Weight);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings
|
||||
{
|
||||
public static class ExtentionDrawningStormtrooperBase
|
||||
public static class ExtentionDrawningStormtrooper
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.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) { }
|
||||
}
|
@ -29,8 +29,6 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonSortByColor = new Button();
|
||||
buttonSortByType = new Button();
|
||||
panelCompanyTools = new Panel();
|
||||
buttonAddStormtrooperBase = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
@ -70,38 +68,14 @@
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(911, 24);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(173, 687);
|
||||
groupBoxTools.Size = new Size(173, 646);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonSortByColor.Location = new Point(5, 238);
|
||||
buttonSortByColor.Name = "buttonSortByColor";
|
||||
buttonSortByColor.Size = new Size(153, 32);
|
||||
buttonSortByColor.TabIndex = 10;
|
||||
buttonSortByColor.Text = "Сортировка по цвету";
|
||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
buttonSortByColor.Click += ButtonSortByColor_Click;
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonSortByType.Location = new Point(3, 196);
|
||||
buttonSortByType.Name = "buttonSortByType";
|
||||
buttonSortByType.Size = new Size(155, 36);
|
||||
buttonSortByType.TabIndex = 9;
|
||||
buttonSortByType.Text = "Сортировка по типу";
|
||||
buttonSortByType.UseVisualStyleBackColor = true;
|
||||
buttonSortByType.Click += ButtonSortByType_Click;
|
||||
//
|
||||
// panelCompanyTools
|
||||
//
|
||||
panelCompanyTools.Controls.Add(buttonSortByColor);
|
||||
panelCompanyTools.Controls.Add(buttonAddStormtrooperBase);
|
||||
panelCompanyTools.Controls.Add(buttonSortByType);
|
||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||
panelCompanyTools.Controls.Add(buttonRemoveStormtrooper);
|
||||
@ -109,7 +83,7 @@
|
||||
panelCompanyTools.Enabled = false;
|
||||
panelCompanyTools.Location = new Point(6, 361);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(161, 276);
|
||||
panelCompanyTools.Size = new Size(161, 261);
|
||||
panelCompanyTools.TabIndex = 7;
|
||||
//
|
||||
// buttonAddStormtrooperBase
|
||||
@ -125,7 +99,7 @@
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Location = new Point(7, 48);
|
||||
maskedTextBox.Location = new Point(8, 99);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(153, 23);
|
||||
@ -135,7 +109,7 @@
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(5, 158);
|
||||
buttonRefresh.Location = new Point(7, 209);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(155, 32);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
@ -146,9 +120,9 @@
|
||||
// buttonRemoveStormtrooper
|
||||
//
|
||||
buttonRemoveStormtrooper.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRemoveStormtrooper.Location = new Point(5, 77);
|
||||
buttonRemoveStormtrooper.Location = new Point(6, 128);
|
||||
buttonRemoveStormtrooper.Name = "buttonRemoveStormtrooper";
|
||||
buttonRemoveStormtrooper.Size = new Size(153, 33);
|
||||
buttonRemoveStormtrooper.Size = new Size(166, 33);
|
||||
buttonRemoveStormtrooper.TabIndex = 4;
|
||||
buttonRemoveStormtrooper.Text = "Удалить Штурмовик";
|
||||
buttonRemoveStormtrooper.UseVisualStyleBackColor = true;
|
||||
@ -157,9 +131,9 @@
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(3, 116);
|
||||
buttonGoToCheck.Location = new Point(7, 167);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(158, 36);
|
||||
buttonGoToCheck.Size = new Size(166, 36);
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
@ -274,7 +248,7 @@
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 24);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(911, 687);
|
||||
pictureBox.Size = new Size(911, 646);
|
||||
pictureBox.TabIndex = 3;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
@ -322,7 +296,7 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1084, 711);
|
||||
ClientSize = new Size(1084, 670);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
@ -367,7 +341,5 @@
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button buttonSortByColor;
|
||||
private Button buttonSortByType;
|
||||
}
|
||||
}
|
@ -91,11 +91,6 @@ public partial class FormStormtrooperCollection : Form
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||
}
|
||||
catch(ObjectIsEqualException ex)
|
||||
{
|
||||
MessageBox.Show("Такой объект уже существует ");
|
||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@ -252,7 +247,7 @@ public partial class FormStormtrooperCollection : Form
|
||||
listBoxCollection.Items.Clear();
|
||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||
{
|
||||
string? colName = _storageCollection.Keys?[i].Name;
|
||||
string? colName = _storageCollection.Keys?[i];
|
||||
if (!string.IsNullOrEmpty(colName))
|
||||
{
|
||||
listBoxCollection.Items.Add(colName);
|
||||
@ -339,35 +334,11 @@ public partial class FormStormtrooperCollection : Form
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// сортировка по типу
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSortByType_Click(object sender, EventArgs e)
|
||||
{
|
||||
CompareStorntrooper(new DrawningStormtrooperBaseByType());
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка по цвету
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSortByColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
CompareStorntrooper(new DrawningStormtrooperBaseByColor());
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка по сравнителю
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
private void CompareStorntrooper(IComparer<DrawningStormtrooperBase?> comparer)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_company.Sort(comparer);
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user