parent
8e06837ec5
commit
fbf00076a0
119
DumpTruck/FormTruckCollection.Designer.cs
generated
119
DumpTruck/FormTruckCollection.Designer.cs
generated
@ -32,6 +32,10 @@
|
|||||||
this.panelStorages = new System.Windows.Forms.Panel();
|
this.panelStorages = new System.Windows.Forms.Panel();
|
||||||
this.labelStorages = new System.Windows.Forms.Label();
|
this.labelStorages = new System.Windows.Forms.Label();
|
||||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||||
|
this.menuStripFile = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.toolStripMenuItemFile = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItemSave = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItemLoad = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.buttonDelObject = new System.Windows.Forms.Button();
|
this.buttonDelObject = new System.Windows.Forms.Button();
|
||||||
this.buttonAddObject = new System.Windows.Forms.Button();
|
this.buttonAddObject = new System.Windows.Forms.Button();
|
||||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||||
@ -40,15 +44,9 @@
|
|||||||
this.labelTools = new System.Windows.Forms.Label();
|
this.labelTools = new System.Windows.Forms.Label();
|
||||||
this.buttonRemoveTruck = new System.Windows.Forms.Button();
|
this.buttonRemoveTruck = new System.Windows.Forms.Button();
|
||||||
this.buttonAddTruck = new System.Windows.Forms.Button();
|
this.buttonAddTruck = new System.Windows.Forms.Button();
|
||||||
this.menuStripFile = new System.Windows.Forms.MenuStrip();
|
|
||||||
this.toolStripMenuItemFile = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.toolStripMenuItemSave = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.toolStripMenuItemLoad = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||||
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.buttonSortByType = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSortByColor = new System.Windows.Forms.Button();
|
|
||||||
this.panelTools.SuspendLayout();
|
this.panelTools.SuspendLayout();
|
||||||
this.panelStorages.SuspendLayout();
|
this.panelStorages.SuspendLayout();
|
||||||
this.menuStripFile.SuspendLayout();
|
this.menuStripFile.SuspendLayout();
|
||||||
@ -59,8 +57,6 @@
|
|||||||
//
|
//
|
||||||
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.panelTools.Controls.Add(this.buttonSortByColor);
|
|
||||||
this.panelTools.Controls.Add(this.buttonSortByType);
|
|
||||||
this.panelTools.Controls.Add(this.panelStorages);
|
this.panelTools.Controls.Add(this.panelStorages);
|
||||||
this.panelTools.Controls.Add(this.maskedTextBoxNumber);
|
this.panelTools.Controls.Add(this.maskedTextBoxNumber);
|
||||||
this.panelTools.Controls.Add(this.buttonRefreshCollection);
|
this.panelTools.Controls.Add(this.buttonRefreshCollection);
|
||||||
@ -76,12 +72,13 @@
|
|||||||
//
|
//
|
||||||
this.panelStorages.Controls.Add(this.labelStorages);
|
this.panelStorages.Controls.Add(this.labelStorages);
|
||||||
this.panelStorages.Controls.Add(this.textBoxStorageName);
|
this.panelStorages.Controls.Add(this.textBoxStorageName);
|
||||||
|
this.panelStorages.Controls.Add(this.menuStripFile);
|
||||||
this.panelStorages.Controls.Add(this.buttonDelObject);
|
this.panelStorages.Controls.Add(this.buttonDelObject);
|
||||||
this.panelStorages.Controls.Add(this.buttonAddObject);
|
this.panelStorages.Controls.Add(this.buttonAddObject);
|
||||||
this.panelStorages.Controls.Add(this.listBoxStorages);
|
this.panelStorages.Controls.Add(this.listBoxStorages);
|
||||||
this.panelStorages.Location = new System.Drawing.Point(3, 18);
|
this.panelStorages.Location = new System.Drawing.Point(3, 18);
|
||||||
this.panelStorages.Name = "panelStorages";
|
this.panelStorages.Name = "panelStorages";
|
||||||
this.panelStorages.Size = new System.Drawing.Size(200, 215);
|
this.panelStorages.Size = new System.Drawing.Size(200, 246);
|
||||||
this.panelStorages.TabIndex = 5;
|
this.panelStorages.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// labelStorages
|
// labelStorages
|
||||||
@ -100,6 +97,40 @@
|
|||||||
this.textBoxStorageName.Size = new System.Drawing.Size(150, 23);
|
this.textBoxStorageName.Size = new System.Drawing.Size(150, 23);
|
||||||
this.textBoxStorageName.TabIndex = 3;
|
this.textBoxStorageName.TabIndex = 3;
|
||||||
//
|
//
|
||||||
|
// menuStripFile
|
||||||
|
//
|
||||||
|
this.menuStripFile.Dock = System.Windows.Forms.DockStyle.None;
|
||||||
|
this.menuStripFile.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripMenuItemFile});
|
||||||
|
this.menuStripFile.Location = new System.Drawing.Point(25, 222);
|
||||||
|
this.menuStripFile.Name = "menuStripFile";
|
||||||
|
this.menuStripFile.Size = new System.Drawing.Size(176, 24);
|
||||||
|
this.menuStripFile.TabIndex = 2;
|
||||||
|
this.menuStripFile.Text = "menuStripFile";
|
||||||
|
//
|
||||||
|
// toolStripMenuItemFile
|
||||||
|
//
|
||||||
|
this.toolStripMenuItemFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripMenuItemSave,
|
||||||
|
this.toolStripMenuItemLoad});
|
||||||
|
this.toolStripMenuItemFile.Name = "toolStripMenuItemFile";
|
||||||
|
this.toolStripMenuItemFile.Size = new System.Drawing.Size(48, 20);
|
||||||
|
this.toolStripMenuItemFile.Text = "Файл";
|
||||||
|
//
|
||||||
|
// toolStripMenuItemSave
|
||||||
|
//
|
||||||
|
this.toolStripMenuItemSave.Name = "toolStripMenuItemSave";
|
||||||
|
this.toolStripMenuItemSave.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.toolStripMenuItemSave.Text = "Сохранить";
|
||||||
|
this.toolStripMenuItemSave.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItemLoad
|
||||||
|
//
|
||||||
|
this.toolStripMenuItemLoad.Name = "toolStripMenuItemLoad";
|
||||||
|
this.toolStripMenuItemLoad.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.toolStripMenuItemLoad.Text = "Загрузить";
|
||||||
|
this.toolStripMenuItemLoad.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// buttonDelObject
|
// buttonDelObject
|
||||||
//
|
//
|
||||||
this.buttonDelObject.Location = new System.Drawing.Point(25, 185);
|
this.buttonDelObject.Location = new System.Drawing.Point(25, 185);
|
||||||
@ -132,14 +163,14 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 339);
|
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 306);
|
||||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(150, 23);
|
this.maskedTextBoxNumber.Size = new System.Drawing.Size(150, 23);
|
||||||
this.maskedTextBoxNumber.TabIndex = 4;
|
this.maskedTextBoxNumber.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// buttonRefreshCollection
|
// buttonRefreshCollection
|
||||||
//
|
//
|
||||||
this.buttonRefreshCollection.Location = new System.Drawing.Point(28, 404);
|
this.buttonRefreshCollection.Location = new System.Drawing.Point(28, 395);
|
||||||
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||||
this.buttonRefreshCollection.Size = new System.Drawing.Size(150, 30);
|
this.buttonRefreshCollection.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonRefreshCollection.TabIndex = 3;
|
this.buttonRefreshCollection.TabIndex = 3;
|
||||||
@ -159,7 +190,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveTruck
|
// buttonRemoveTruck
|
||||||
//
|
//
|
||||||
this.buttonRemoveTruck.Location = new System.Drawing.Point(28, 368);
|
this.buttonRemoveTruck.Location = new System.Drawing.Point(28, 335);
|
||||||
this.buttonRemoveTruck.Name = "buttonRemoveTruck";
|
this.buttonRemoveTruck.Name = "buttonRemoveTruck";
|
||||||
this.buttonRemoveTruck.Size = new System.Drawing.Size(150, 30);
|
this.buttonRemoveTruck.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonRemoveTruck.TabIndex = 2;
|
this.buttonRemoveTruck.TabIndex = 2;
|
||||||
@ -169,7 +200,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddTruck
|
// buttonAddTruck
|
||||||
//
|
//
|
||||||
this.buttonAddTruck.Location = new System.Drawing.Point(28, 303);
|
this.buttonAddTruck.Location = new System.Drawing.Point(28, 270);
|
||||||
this.buttonAddTruck.Name = "buttonAddTruck";
|
this.buttonAddTruck.Name = "buttonAddTruck";
|
||||||
this.buttonAddTruck.Size = new System.Drawing.Size(150, 30);
|
this.buttonAddTruck.Size = new System.Drawing.Size(150, 30);
|
||||||
this.buttonAddTruck.TabIndex = 1;
|
this.buttonAddTruck.TabIndex = 1;
|
||||||
@ -177,45 +208,11 @@
|
|||||||
this.buttonAddTruck.UseVisualStyleBackColor = true;
|
this.buttonAddTruck.UseVisualStyleBackColor = true;
|
||||||
this.buttonAddTruck.Click += new System.EventHandler(this.buttonAddTruck_Click);
|
this.buttonAddTruck.Click += new System.EventHandler(this.buttonAddTruck_Click);
|
||||||
//
|
//
|
||||||
// menuStripFile
|
|
||||||
//
|
|
||||||
this.menuStripFile.Dock = System.Windows.Forms.DockStyle.None;
|
|
||||||
this.menuStripFile.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripMenuItemFile});
|
|
||||||
this.menuStripFile.Location = new System.Drawing.Point(9, 4);
|
|
||||||
this.menuStripFile.Name = "menuStripFile";
|
|
||||||
this.menuStripFile.Size = new System.Drawing.Size(56, 24);
|
|
||||||
this.menuStripFile.TabIndex = 2;
|
|
||||||
this.menuStripFile.Text = "menuStripFile";
|
|
||||||
//
|
|
||||||
// toolStripMenuItemFile
|
|
||||||
//
|
|
||||||
this.toolStripMenuItemFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripMenuItemSave,
|
|
||||||
this.toolStripMenuItemLoad});
|
|
||||||
this.toolStripMenuItemFile.Name = "toolStripMenuItemFile";
|
|
||||||
this.toolStripMenuItemFile.Size = new System.Drawing.Size(48, 20);
|
|
||||||
this.toolStripMenuItemFile.Text = "Файл";
|
|
||||||
//
|
|
||||||
// toolStripMenuItemSave
|
|
||||||
//
|
|
||||||
this.toolStripMenuItemSave.Name = "toolStripMenuItemSave";
|
|
||||||
this.toolStripMenuItemSave.Size = new System.Drawing.Size(133, 22);
|
|
||||||
this.toolStripMenuItemSave.Text = "Сохранить";
|
|
||||||
this.toolStripMenuItemSave.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// toolStripMenuItemLoad
|
|
||||||
//
|
|
||||||
this.toolStripMenuItemLoad.Name = "toolStripMenuItemLoad";
|
|
||||||
this.toolStripMenuItemLoad.Size = new System.Drawing.Size(133, 22);
|
|
||||||
this.toolStripMenuItemLoad.Text = "Загрузить";
|
|
||||||
this.toolStripMenuItemLoad.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
//
|
//
|
||||||
this.pictureBoxCollection.Location = new System.Drawing.Point(2, 31);
|
this.pictureBoxCollection.Location = new System.Drawing.Point(2, 3);
|
||||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
this.pictureBoxCollection.Size = new System.Drawing.Size(588, 417);
|
this.pictureBoxCollection.Size = new System.Drawing.Size(588, 445);
|
||||||
this.pictureBoxCollection.TabIndex = 1;
|
this.pictureBoxCollection.TabIndex = 1;
|
||||||
this.pictureBoxCollection.TabStop = false;
|
this.pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -228,26 +225,6 @@
|
|||||||
//
|
//
|
||||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||||
//
|
//
|
||||||
// buttonSortByType
|
|
||||||
//
|
|
||||||
this.buttonSortByType.Location = new System.Drawing.Point(28, 238);
|
|
||||||
this.buttonSortByType.Name = "buttonSortByType";
|
|
||||||
this.buttonSortByType.Size = new System.Drawing.Size(150, 25);
|
|
||||||
this.buttonSortByType.TabIndex = 6;
|
|
||||||
this.buttonSortByType.Text = "Сортировка по типу";
|
|
||||||
this.buttonSortByType.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click);
|
|
||||||
//
|
|
||||||
// buttonSortByColor
|
|
||||||
//
|
|
||||||
this.buttonSortByColor.Location = new System.Drawing.Point(28, 269);
|
|
||||||
this.buttonSortByColor.Name = "buttonSortByColor";
|
|
||||||
this.buttonSortByColor.Size = new System.Drawing.Size(150, 25);
|
|
||||||
this.buttonSortByColor.TabIndex = 7;
|
|
||||||
this.buttonSortByColor.Text = "Сортировка по цвету";
|
|
||||||
this.buttonSortByColor.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click);
|
|
||||||
//
|
|
||||||
// FormTruckCollection
|
// FormTruckCollection
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -255,7 +232,6 @@
|
|||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
this.Controls.Add(this.pictureBoxCollection);
|
this.Controls.Add(this.pictureBoxCollection);
|
||||||
this.Controls.Add(this.panelTools);
|
this.Controls.Add(this.panelTools);
|
||||||
this.Controls.Add(this.menuStripFile);
|
|
||||||
this.MainMenuStrip = this.menuStripFile;
|
this.MainMenuStrip = this.menuStripFile;
|
||||||
this.Name = "FormTruckCollection";
|
this.Name = "FormTruckCollection";
|
||||||
this.Text = "FormTruckCollection";
|
this.Text = "FormTruckCollection";
|
||||||
@ -267,7 +243,6 @@
|
|||||||
this.menuStripFile.PerformLayout();
|
this.menuStripFile.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +267,5 @@
|
|||||||
private ToolStripMenuItem toolStripMenuItemLoad;
|
private ToolStripMenuItem toolStripMenuItemLoad;
|
||||||
private OpenFileDialog openFileDialog;
|
private OpenFileDialog openFileDialog;
|
||||||
private SaveFileDialog saveFileDialog;
|
private SaveFileDialog saveFileDialog;
|
||||||
private Button buttonSortByColor;
|
|
||||||
private Button buttonSortByType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,7 +46,7 @@ namespace DumpTruck
|
|||||||
listBoxStorages.Items.Clear();
|
listBoxStorages.Items.Clear();
|
||||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
{
|
{
|
||||||
listBoxStorages.Items.Add(_storage.Keys[i].Name);
|
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||||
}
|
}
|
||||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||||
>= listBoxStorages.Items.Count))
|
>= listBoxStorages.Items.Count))
|
||||||
@ -138,11 +138,6 @@ namespace DumpTruck
|
|||||||
MessageBox.Show(ex.Message);
|
MessageBox.Show(ex.Message);
|
||||||
_logger.LogWarning($"Не удалось добавить объект: {ex.Message}");
|
_logger.LogWarning($"Не удалось добавить объект: {ex.Message}");
|
||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message);
|
|
||||||
_logger.LogWarning($"Не удалось добавить объект: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAddTruck_Click(object sender, EventArgs e)
|
private void buttonAddTruck_Click(object sender, EventArgs e)
|
||||||
@ -257,39 +252,5 @@ namespace DumpTruck
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка по типу
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonSortByType_Click(object sender, EventArgs e) =>
|
|
||||||
CompareTrucks(new TruckCompareByType());
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка по цвету
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonSortByColor_Click(object sender, EventArgs e) =>
|
|
||||||
CompareTrucks(new TruckCompareByColor());
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка по сравнителю
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer"></param>
|
|
||||||
private void CompareTrucks(IComparer<DrawingTruck?> comparer)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
obj.Sort(comparer);
|
|
||||||
pictureBoxCollection.Image = obj.ShowTrucks();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
using DumpTruck.DrawingObjects;
|
|
||||||
using DumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DumpTruck.Generics
|
|
||||||
{
|
|
||||||
internal class DrawiningCarEqutables : IEqualityComparer<DrawingTruck?>
|
|
||||||
{
|
|
||||||
public bool Equals(DrawingTruck? x, DrawingTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(x));
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(y));
|
|
||||||
}
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.Speed != y.EntityTruck.Speed)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.Weight != y.EntityTruck.Weight)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.BodyColor != y.EntityTruck.BodyColor)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x is DrawingDumpTruck && y is DrawingDumpTruck)
|
|
||||||
{
|
|
||||||
EntityDumpTruck xDumpTruck = (EntityDumpTruck)x.EntityTruck;
|
|
||||||
EntityDumpTruck yDumpTruck = (EntityDumpTruck)y.EntityTruck;
|
|
||||||
|
|
||||||
if (xDumpTruck.DumpBoxColor != yDumpTruck.DumpBoxColor)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (xDumpTruck.TentColor != yDumpTruck.TentColor)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (xDumpTruck.Tent != yDumpTruck.Tent)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (xDumpTruck.DumpBox != yDumpTruck.DumpBox)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public int GetHashCode([DisallowNull] DrawingTruck obj)
|
|
||||||
{
|
|
||||||
return obj.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -26,17 +26,11 @@ namespace DumpTruck.Generics
|
|||||||
/// Максимальное количество объектов в списке
|
/// Максимальное количество объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _maxCount;
|
private readonly int _maxCount;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сортировка набора объектов
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="comparer"></param>
|
/// <param name="count"></param>
|
||||||
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
|
public SetGeneric(int count)
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
public SetGeneric(int count)
|
|
||||||
{
|
{
|
||||||
_maxCount = count;
|
_maxCount = count;
|
||||||
_places = new List<T?>(count);
|
_places = new List<T?>(count);
|
||||||
@ -46,9 +40,9 @@ namespace DumpTruck.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="truck">Добавляемый грузовик</param>
|
/// <param name="truck">Добавляемый грузовик</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T truck, IEqualityComparer<T?>? equal = null)
|
public int Insert(T truck)
|
||||||
{
|
{
|
||||||
return Insert(truck, 0, equal);
|
return Insert(truck, 0);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
@ -56,14 +50,12 @@ namespace DumpTruck.Generics
|
|||||||
/// <param name="truck">Добавляемый грузовик</param>
|
/// <param name="truck">Добавляемый грузовик</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T truck, int position, IEqualityComparer<T?>? equal = null)
|
public int Insert(T truck, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position > Count)
|
||||||
throw new TruckNotFoundException(position);
|
throw new TruckNotFoundException(position);
|
||||||
if (Count >= _maxCount)
|
if (Count >= _maxCount)
|
||||||
throw new StorageOverflowException(_maxCount);
|
throw new StorageOverflowException(_maxCount);
|
||||||
if (equal != null && _places.Contains(truck, equal))
|
|
||||||
throw new ArgumentException("Данный объект уже есть в коллекции");
|
|
||||||
_places.Insert(position, truck);
|
_places.Insert(position, truck);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
using DumpTruck.DrawingObjects;
|
|
||||||
using DumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DumpTruck.Generics
|
|
||||||
{
|
|
||||||
internal class TruckCompareByColor : IComparer<DrawingTruck?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawingTruck? x, DrawingTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(x));
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(y));
|
|
||||||
}
|
|
||||||
var bodyColorCompare = x.EntityTruck.BodyColor.Name.CompareTo(y.EntityTruck.BodyColor.Name);
|
|
||||||
if (bodyColorCompare != 0)
|
|
||||||
{
|
|
||||||
return bodyColorCompare;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck is EntityDumpTruck xEntityDumpTruck && y.EntityTruck is EntityDumpTruck yEntityDumpTruck)
|
|
||||||
{
|
|
||||||
var dumpBoxColorCompare = xEntityDumpTruck.DumpBoxColor.Name.CompareTo(yEntityDumpTruck.DumpBoxColor.Name);
|
|
||||||
if (dumpBoxColorCompare != 0)
|
|
||||||
{
|
|
||||||
return dumpBoxColorCompare;
|
|
||||||
}
|
|
||||||
var tentColorCompare = xEntityDumpTruck.TentColor.Name.CompareTo(yEntityDumpTruck.TentColor.Name);
|
|
||||||
if (tentColorCompare != 0)
|
|
||||||
{
|
|
||||||
return tentColorCompare;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var speedCompare = x.EntityTruck.Speed.CompareTo(y.EntityTruck.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTruck.Weight.CompareTo(y.EntityTruck.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using DumpTruck.DrawingObjects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DumpTruck.Generics
|
|
||||||
{
|
|
||||||
internal class TruckCompareByType : IComparer<DrawingTruck?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawingTruck? x, DrawingTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(x));
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(y));
|
|
||||||
}
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
|
||||||
}
|
|
||||||
var speedCompare = x.EntityTruck.Speed.CompareTo(y.EntityTruck.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTruck.Weight.CompareTo(y.EntityTruck.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DumpTruck.Generics
|
|
||||||
{
|
|
||||||
internal class TrucksCollectionInfo : IEquatable<TrucksCollectionInfo>
|
|
||||||
{
|
|
||||||
public string Name { get; private set; }
|
|
||||||
public string Description { get; private set; }
|
|
||||||
public TrucksCollectionInfo(string name, string description)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
public bool Equals(TrucksCollectionInfo? other)
|
|
||||||
{
|
|
||||||
if (Name == other?.Name)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return Name.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -41,12 +41,6 @@ namespace DumpTruck.Generics
|
|||||||
/// Получение объектов коллекции
|
/// Получение объектов коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<T?> GetTrucks => _collection.GetTrucks();
|
public IEnumerable<T?> GetTrucks => _collection.GetTrucks();
|
||||||
/// <summary>
|
|
||||||
/// Сортировка
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer"></param>
|
|
||||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -72,7 +66,7 @@ namespace DumpTruck.Generics
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return collect._collection.Insert(obj, new DrawiningCarEqutables());
|
return collect._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
|
||||||
using DumpTruck.DrawingObjects;
|
using DumpTruck.DrawingObjects;
|
||||||
using DumpTruck.MovementStrategy;
|
using DumpTruck.MovementStrategy;
|
||||||
|
|
||||||
@ -29,11 +28,11 @@ namespace DumpTruck.Generics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище)
|
/// Словарь (хранилище)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
readonly Dictionary<TrucksCollectionInfo, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>> _truckStorages;
|
readonly Dictionary<string, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>> _truckStorages;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращение списка названий наборов
|
/// Возвращение списка названий наборов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<TrucksCollectionInfo> Keys => _truckStorages.Keys.ToList();
|
public List<string> Keys => _truckStorages.Keys.ToList();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна отрисовки
|
/// Ширина окна отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,7 +48,7 @@ namespace DumpTruck.Generics
|
|||||||
/// <param name="pictureHeight"></param>
|
/// <param name="pictureHeight"></param>
|
||||||
public TrucksGenericStorage(int pictureWidth, int pictureHeight)
|
public TrucksGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
{
|
{
|
||||||
_truckStorages = new Dictionary<TrucksCollectionInfo, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>>();
|
_truckStorages = new Dictionary<string, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>>();
|
||||||
_pictureWidth = pictureWidth;
|
_pictureWidth = pictureWidth;
|
||||||
_pictureHeight = pictureHeight;
|
_pictureHeight = pictureHeight;
|
||||||
}
|
}
|
||||||
@ -59,7 +58,7 @@ namespace DumpTruck.Generics
|
|||||||
/// <param name="name">Название набора</param>
|
/// <param name="name">Название набора</param>
|
||||||
public void AddSet(string name)
|
public void AddSet(string name)
|
||||||
{
|
{
|
||||||
if (!_truckStorages.ContainsKey(new TrucksCollectionInfo(name, string.Empty))) _truckStorages.Add(new TrucksCollectionInfo(name, string.Empty), new TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>(_pictureWidth, _pictureHeight));
|
if (!_truckStorages.ContainsKey(name)) _truckStorages.Add(name, new TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>(_pictureWidth, _pictureHeight));
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление набора
|
/// Удаление набора
|
||||||
@ -67,7 +66,7 @@ namespace DumpTruck.Generics
|
|||||||
/// <param name="name">Название набора</param>
|
/// <param name="name">Название набора</param>
|
||||||
public void DelSet(string name)
|
public void DelSet(string name)
|
||||||
{
|
{
|
||||||
if (_truckStorages.ContainsKey(new TrucksCollectionInfo(name, string.Empty))) _truckStorages.Remove(new TrucksCollectionInfo(name, string.Empty));
|
if (_truckStorages.ContainsKey(name)) _truckStorages.Remove(name);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Доступ к набору
|
/// Доступ к набору
|
||||||
@ -76,11 +75,10 @@ namespace DumpTruck.Generics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>?
|
public TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>?
|
||||||
this[string ind]
|
this[string ind]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_truckStorages.ContainsKey(new TrucksCollectionInfo(ind, string.Empty)))
|
if (_truckStorages.ContainsKey(ind)) return _truckStorages[ind];
|
||||||
return _truckStorages[new TrucksCollectionInfo(ind, string.Empty)];
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,18 +94,18 @@ namespace DumpTruck.Generics
|
|||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
}
|
}
|
||||||
StringBuilder data = new();
|
StringBuilder data = new();
|
||||||
foreach (KeyValuePair<TrucksCollectionInfo, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>> record in _truckStorages)
|
foreach (KeyValuePair<string, TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>> record in _truckStorages)
|
||||||
{
|
{
|
||||||
StringBuilder records = new();
|
StringBuilder records = new();
|
||||||
foreach (DrawingTruck? elem in record.Value.GetTrucks)
|
foreach (DrawingTruck? elem in record.Value.GetTrucks)
|
||||||
{
|
{
|
||||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
}
|
}
|
||||||
data.AppendLine($"{record.Key.Name}{_separatorForKeyValue}{records}");
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
}
|
}
|
||||||
if (data.Length == 0)
|
if (data.Length == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Невалиданя операция, нет данных для сохранения");
|
throw new InvalidOperationException("Невалиданя операция, нет данных для сохранения");
|
||||||
}
|
}
|
||||||
using StreamWriter sw = new(filename);
|
using StreamWriter sw = new(filename);
|
||||||
sw.Write($"TruckStorage{Environment.NewLine}{data}");
|
sw.Write($"TruckStorage{Environment.NewLine}{data}");
|
||||||
@ -121,18 +119,18 @@ namespace DumpTruck.Generics
|
|||||||
{
|
{
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
{
|
||||||
throw new Exception("Файл не найден");
|
throw new FileNotFoundException("Файл не найден");
|
||||||
}
|
}
|
||||||
using (StreamReader sr = new(filename))
|
using (StreamReader sr = new(filename))
|
||||||
{
|
{
|
||||||
string str = sr.ReadLine();
|
string str = sr.ReadLine();
|
||||||
if (str == null || str.Length == 0)
|
if (str == null || str.Length == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Нет данных для загрузки");
|
throw new NullReferenceException("Нет данных для загрузки");
|
||||||
}
|
}
|
||||||
if (!str.StartsWith("TruckStorage"))
|
if (!str.StartsWith("TruckStorage"))
|
||||||
{
|
{
|
||||||
throw new Exception("Неверный формат данных");
|
throw new InvalidDataException("Неверный формат данных");
|
||||||
}
|
}
|
||||||
_truckStorages.Clear();
|
_truckStorages.Clear();
|
||||||
while ((str = sr.ReadLine()) != null)
|
while ((str = sr.ReadLine()) != null)
|
||||||
@ -151,11 +149,11 @@ namespace DumpTruck.Generics
|
|||||||
{
|
{
|
||||||
if (collection + truck == -1)
|
if (collection + truck == -1)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка добавления в коллекцию");
|
throw new ApplicationException("Ошибка добавления в коллекцию");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_truckStorages.Add(new TrucksCollectionInfo(record[0], string.Empty), collection);
|
_truckStorages.Add(record[0], collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user