5 Commits

Author SHA1 Message Date
7b6adc2828 ужас 2023-12-24 01:16:42 +04:00
f8eb440279 кошмар 2023-12-24 01:10:45 +04:00
ea7d59908e all 2023-12-20 09:58:42 +04:00
6c507a6877 Хорошо когда собака друг, плохо когда друг собака 2023-12-19 22:39:15 +04:00
8e6becc7b1 опять треш 2023-12-19 18:44:22 +04:00
12 changed files with 102 additions and 85 deletions

View File

@@ -57,7 +57,7 @@ namespace Catamaran
private void buttonCreateSailCatamaran_Click(object sender, EventArgs e)
{
Random random = new();
//TODO <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
//<EFBFBD> TODO <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
Color color = Color.FromArgb(random.Next(0, 256),
random.Next(0, 256), random.Next(0, 256));
ColorDialog dialogColor = new();

View File

@@ -1,12 +1,11 @@
using System;
using Catamaran.DrawningObjects;
using Catamaran.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Catamaran.DrawningObjects;
using Catamaran.Entities;
namespace Catamaran.Generics
{
internal class CatamaranCompareByColor : IComparer<DrawningCatamaran?>
@@ -28,15 +27,15 @@ namespace Catamaran.Generics
}
if (x.EntityCatamaran is EntitySailCatamaran xEntitySailCatamaran && y.EntityCatamaran is EntitySailCatamaran yEntitySailCatamaran)
{
var dumpBoxColorCompare = xEntitySailCatamaran.BodyColor.Name.CompareTo(yEntitySailCatamaran.BodyColor.Name);
if (dumpBoxColorCompare != 0)
var BodyColorCompare = xEntitySailCatamaran.BodyColor.Name.CompareTo(yEntitySailCatamaran.BodyColor.Name);
if (BodyColorCompare != 0)
{
return dumpBoxColorCompare;
return BodyColorCompare;
}
var tentColorCompare = xEntitySailCatamaran.AdditionalColor.Name.CompareTo(yEntitySailCatamaran.AdditionalColor.Name);
if (tentColorCompare != 0)
var AdditionalColorCompare = xEntitySailCatamaran.AdditionalColor.Name.CompareTo(yEntitySailCatamaran.AdditionalColor.Name);
if (AdditionalColorCompare != 0)
{
return tentColorCompare;
return AdditionalColorCompare;
}
}
var speedCompare = x.EntityCatamaran.Speed.CompareTo(y.EntityCatamaran.Speed);

View File

@@ -1,9 +1,10 @@
using Catamaran.DrawningObjects;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Catamaran.DrawningObjects;
namespace Catamaran.Generics
{
@@ -23,8 +24,7 @@ namespace Catamaran.Generics
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare =
x.EntityCatamaran.Speed.CompareTo(y.EntityCatamaran.Speed);
var speedCompare = x.EntityCatamaran.Speed.CompareTo(y.EntityCatamaran.Speed);
if (speedCompare != 0)
{
return speedCompare;

View File

@@ -17,6 +17,7 @@ namespace Catamaran.Generics
}
public bool Equals(CatamaransCollectionInfo? other)
{
// TODO прописать логику сравнения по свойству Name
if (Name == other?.Name)
return true;
@@ -27,4 +28,5 @@ namespace Catamaran.Generics
return this.Name.GetHashCode();
}
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic.Logging;
using Catamaran.DrawningObjects;
using Catamaran.MovementStrategy;
namespace Catamaran.Generics
@@ -41,8 +41,6 @@ namespace Catamaran.Generics
/// Получение объектов коллекции
/// </summary>
public IEnumerable<T?> GetCatamarans => _collection.GetCatamarans();
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
/// <summary>
/// Конструктор
/// </summary>
@@ -68,7 +66,7 @@ namespace Catamaran.Generics
{
return false;
}
return (bool)collect?._collection.Insert(obj, new DrawingCatamaranEqutables());
return collect?._collection.Insert(obj, new DrawningCatamaranEqutables()) ?? false;
}
/// <summary>
/// Перегрузка оператора вычитания
@@ -108,6 +106,12 @@ namespace Catamaran.Generics
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer"></param>
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
/// <summary>
/// Метод отрисовки фона
/// </summary>
@@ -134,7 +138,6 @@ namespace Catamaran.Generics
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
{
// TODO получение объекта
// TODO установка позиции

View File

@@ -12,7 +12,7 @@ namespace Catamaran.Generics
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<CatamaransCollectionInfo, CatamaransGenericCollection<DrawningCatamaran,
readonly Dictionary<CatamaransCollectionInfo, CatamaransGenericCollection<DrawningCatamaran,
DrawningObjectCatamaran>> _catamaranStorages;
/// <summary>
/// Возвращение списка названий наборов
@@ -173,7 +173,7 @@ namespace Catamaran.Generics
}
}
}
_catamaranStorages.Add(new CatamaransCollectionInfo(record[0], string.Empty), collection);
_catamaranStorages.Add(new CatamaransCollectionInfo(record[0],string.Empty), collection);
}
}
}

View File

@@ -1,16 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Catamaran.DrawningObjects;
using Catamaran.Entities;
using System.Diagnostics.CodeAnalysis;
namespace Catamaran.Generics
{
internal class DrawingCatamaranEqutables : IEqualityComparer<DrawningCatamaran?>
internal class DrawningCatamaranEqutables : IEqualityComparer<DrawningCatamaran?>
{
public bool Equals(DrawningCatamaran? x, DrawningCatamaran? y)
{
@@ -40,6 +41,7 @@ namespace Catamaran.Generics
}
if (x is DrawningSailCatamaran && y is DrawningSailCatamaran)
{
// TODO доделать логику сравнения дополнительных параметров
EntitySailCatamaran EntityX = (EntitySailCatamaran)x.EntityCatamaran;
EntitySailCatamaran EntityY = (EntitySailCatamaran)y.EntityCatamaran;
if (EntityX.Sail != EntityY.Sail)
@@ -56,4 +58,4 @@ namespace Catamaran.Generics
return obj.GetHashCode();
}
}
}
}

View File

@@ -30,6 +30,8 @@
{
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
this.groupBoxTools = new System.Windows.Forms.GroupBox();
this.ButtonSortByColor = new System.Windows.Forms.Button();
this.ButtonSortByType = new System.Windows.Forms.Button();
this.groupBoxSets = new System.Windows.Forms.GroupBox();
this.textBoxStorageName = new System.Windows.Forms.TextBox();
this.buttonDelObject = new System.Windows.Forms.Button();
@@ -45,8 +47,6 @@
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.SortByType = new System.Windows.Forms.Button();
this.SortByColor = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.groupBoxTools.SuspendLayout();
this.groupBoxSets.SuspendLayout();
@@ -63,8 +63,8 @@
//
// groupBoxTools
//
this.groupBoxTools.Controls.Add(this.SortByColor);
this.groupBoxTools.Controls.Add(this.SortByType);
this.groupBoxTools.Controls.Add(this.ButtonSortByColor);
this.groupBoxTools.Controls.Add(this.ButtonSortByType);
this.groupBoxTools.Controls.Add(this.groupBoxSets);
this.groupBoxTools.Controls.Add(this.maskedTextBoxNumber);
this.groupBoxTools.Controls.Add(this.ButtonRefreshCollection);
@@ -78,6 +78,26 @@
this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Инструменты";
//
// ButtonSortByColor
//
this.ButtonSortByColor.Location = new System.Drawing.Point(0, 287);
this.ButtonSortByColor.Name = "ButtonSortByColor";
this.ButtonSortByColor.Size = new System.Drawing.Size(139, 23);
this.ButtonSortByColor.TabIndex = 7;
this.ButtonSortByColor.Text = "Сортировка по цвету";
this.ButtonSortByColor.UseVisualStyleBackColor = true;
this.ButtonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click);
//
// ButtonSortByType
//
this.ButtonSortByType.Location = new System.Drawing.Point(1, 255);
this.ButtonSortByType.Name = "ButtonSortByType";
this.ButtonSortByType.Size = new System.Drawing.Size(140, 23);
this.ButtonSortByType.TabIndex = 6;
this.ButtonSortByType.Text = "Сортировка по типу";
this.ButtonSortByType.UseVisualStyleBackColor = true;
this.ButtonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click);
//
// groupBoxSets
//
this.groupBoxSets.Controls.Add(this.textBoxStorageName);
@@ -130,14 +150,14 @@
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Location = new System.Drawing.Point(0, 351);
this.maskedTextBoxNumber.Location = new System.Drawing.Point(0, 356);
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(137, 23);
this.maskedTextBoxNumber.TabIndex = 3;
//
// ButtonRefreshCollection
//
this.ButtonRefreshCollection.Location = new System.Drawing.Point(0, 420);
this.ButtonRefreshCollection.Location = new System.Drawing.Point(0, 425);
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
this.ButtonRefreshCollection.Size = new System.Drawing.Size(140, 34);
this.ButtonRefreshCollection.TabIndex = 2;
@@ -147,7 +167,7 @@
//
// ButtonRemoveCatamaran
//
this.ButtonRemoveCatamaran.Location = new System.Drawing.Point(-1, 380);
this.ButtonRemoveCatamaran.Location = new System.Drawing.Point(0, 385);
this.ButtonRemoveCatamaran.Name = "ButtonRemoveCatamaran";
this.ButtonRemoveCatamaran.Size = new System.Drawing.Size(140, 34);
this.ButtonRemoveCatamaran.TabIndex = 1;
@@ -157,9 +177,9 @@
//
// ButtonAddCatamaran
//
this.ButtonAddCatamaran.Location = new System.Drawing.Point(-1, 311);
this.ButtonAddCatamaran.Location = new System.Drawing.Point(0, 316);
this.ButtonAddCatamaran.Name = "ButtonAddCatamaran";
this.ButtonAddCatamaran.Size = new System.Drawing.Size(140, 34);
this.ButtonAddCatamaran.Size = new System.Drawing.Size(137, 34);
this.ButtonAddCatamaran.TabIndex = 0;
this.ButtonAddCatamaran.Text = "Добавить катамаран";
this.ButtonAddCatamaran.UseVisualStyleBackColor = true;
@@ -202,26 +222,6 @@
//
this.openFileDialog.FileName = "openFileDialog1";
//
// SortByType
//
this.SortByType.Location = new System.Drawing.Point(-1, 255);
this.SortByType.Name = "SortByType";
this.SortByType.Size = new System.Drawing.Size(140, 23);
this.SortByType.TabIndex = 6;
this.SortByType.Text = "Сортировка по типу";
this.SortByType.UseVisualStyleBackColor = true;
this.SortByType.Click += new System.EventHandler(this.buttonSortByType_Click);
//
// SortByColor
//
this.SortByColor.Location = new System.Drawing.Point(0, 282);
this.SortByColor.Name = "SortByColor";
this.SortByColor.Size = new System.Drawing.Size(139, 23);
this.SortByColor.TabIndex = 7;
this.SortByColor.Text = "Сортировка по цвету";
this.SortByColor.UseVisualStyleBackColor = true;
this.SortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click);
//
// FormCatamaranCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@@ -262,7 +262,7 @@
private ToolStripMenuItem LoadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button SortByColor;
private Button SortByType;
private Button ButtonSortByColor;
private Button ButtonSortByType;
}
}

View File

@@ -112,16 +112,17 @@ namespace Catamaran
}
}
}
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCatamarans();
}
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender,
EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCatamarans();
}
/// <summary>
/// Удаление набора
/// </summary>
@@ -281,7 +282,23 @@ namespace Catamaran
ReloadObjects();
}
}
private void buttonSortByType_Click(object sender, EventArgs e) => CompareCatamarans(new CatamaranCompareByType());
/// <summary>
/// Сортировка по типу
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByType_Click(object sender, EventArgs e) => CompareCatamarans(new CatamaranCompareByType());
/// <summary>
/// Сортировка по цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByColor_Click(object sender, EventArgs e) => CompareCatamarans(new CatamaranCompareByColor()); // TODO продумать логику
/// <summary>
/// Сортировка по сравнителю
/// </summary>
/// <param name="comparer"></param>
private void CompareCatamarans(IComparer<DrawningCatamaran?> comparer)
{
if (listBoxStorages.SelectedIndex == -1)
@@ -297,6 +314,6 @@ namespace Catamaran
obj.Sort(comparer);
pictureBoxCollection.Image = obj.ShowCatamarans();
}
private void buttonSortByColor_Click(object sender, EventArgs e) => CompareCatamarans(new CatamaranCompareByColor());
}
}

View File

@@ -122,7 +122,7 @@ namespace Catamaran
case "labelModifiedObject":
_catamaran = new DrawningSailCatamaran((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxSail.Checked,
checkBoxFloatDetails.Checked, pictureBoxObject.Width,
checkBoxFloatDetails.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
}
@@ -168,7 +168,6 @@ namespace Catamaran
EventAddCatamaran?.Invoke(_catamaran);
Close();
}
};
};
}
}

View File

@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;

View File

@@ -27,8 +27,6 @@ namespace Catamaran.Generics
/// Максимальное количество объектов в списке
/// </summary>
private readonly int _maxCount;
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
/// <summary>
/// Конструктор
/// </summary>
@@ -38,6 +36,8 @@ namespace Catamaran.Generics
_maxCount = count;
_places = new List<T?>(_maxCount);
}
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
/// <summary>
/// Добавление объекта в набор
/// </summary>
@@ -50,15 +50,17 @@ namespace Catamaran.Generics
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// </summary>
/// <param name="catamaran">Добавляемая лодка</param>
/// <param name="boat">Добавляемая лодка</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public bool Insert(T catamaran, int position, IEqualityComparer<T?>? equal = null)
{
{
if (position < 0 || position >= _maxCount)
throw new CatamaranNotFoundException(position);
if (Count >= _maxCount)
throw new StorageOverflowException(_maxCount);
if (equal != null && _places.Contains(catamaran, equal))
throw new ArgumentException("Данный объект уже есть в коллекции");
_places.Insert(0, catamaran);
@@ -73,14 +75,8 @@ namespace Catamaran.Generics
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (position >= Count || position < 0)
{
throw new CatamaranNotFoundException("Invalid operation");
}
if (_places[position] == null)
{
if (!(position >= 0 && position < Count))
throw new CatamaranNotFoundException(position);
}
_places.RemoveAt(position);
return true;
}