Compare commits
No commits in common. "05d0e5510309a4c85e1b12c5fa68523e3b4ad653" and "cd4cf22b7ea17f39c51042f796581653dba0a4b4" have entirely different histories.
05d0e55103
...
cd4cf22b7e
@ -8,7 +8,7 @@ namespace ProjectMachine
|
||||
{
|
||||
internal class DrawningObject : IDrawningObject
|
||||
{
|
||||
public DrawningMachine _machine = null;
|
||||
private DrawningMachine _machine = null;
|
||||
|
||||
public DrawningObject(DrawningMachine machine)
|
||||
{
|
||||
@ -17,8 +17,6 @@ namespace ProjectMachine
|
||||
|
||||
public float Step => _machine?.Machine?.Step ?? 0;
|
||||
|
||||
public DrawningMachine GetTank => _machine;
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _machine?.GetCurrentPosition() ?? default;
|
||||
|
@ -51,8 +51,6 @@
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.buttonSortByType = new System.Windows.Forms.Button();
|
||||
this.buttonSortByColor = new System.Windows.Forms.Button();
|
||||
this.groupBoxTools.SuspendLayout();
|
||||
this.groupBoxMaps.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
@ -61,8 +59,6 @@
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
this.groupBoxTools.Controls.Add(this.buttonSortByColor);
|
||||
this.groupBoxTools.Controls.Add(this.buttonSortByType);
|
||||
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||
@ -74,9 +70,9 @@
|
||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBoxTools.Controls.Add(this.buttonAddTank);
|
||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(812, 28);
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(799, 28);
|
||||
this.groupBoxTools.Name = "groupBoxTools";
|
||||
this.groupBoxTools.Size = new System.Drawing.Size(233, 843);
|
||||
this.groupBoxTools.Size = new System.Drawing.Size(233, 758);
|
||||
this.groupBoxTools.TabIndex = 0;
|
||||
this.groupBoxTools.TabStop = false;
|
||||
this.groupBoxTools.Text = "Инструменты";
|
||||
@ -154,7 +150,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::ProjectMachine.Properties.Resources.лево;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(69, 788);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(69, 703);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(34, 30);
|
||||
this.buttonLeft.TabIndex = 13;
|
||||
@ -167,7 +163,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::ProjectMachine.Properties.Resources.вверх;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(105, 752);
|
||||
this.buttonUp.Location = new System.Drawing.Point(105, 667);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(34, 30);
|
||||
this.buttonUp.TabIndex = 12;
|
||||
@ -180,7 +176,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::ProjectMachine.Properties.Resources.право;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(141, 788);
|
||||
this.buttonRight.Location = new System.Drawing.Point(141, 703);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(34, 30);
|
||||
this.buttonRight.TabIndex = 11;
|
||||
@ -193,7 +189,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::ProjectMachine.Properties.Resources.вниз;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(105, 788);
|
||||
this.buttonDown.Location = new System.Drawing.Point(105, 703);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(34, 30);
|
||||
this.buttonDown.TabIndex = 10;
|
||||
@ -203,7 +199,7 @@
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(20, 689);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(21, 611);
|
||||
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47);
|
||||
@ -214,7 +210,7 @@
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(20, 634);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(21, 556);
|
||||
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(200, 47);
|
||||
@ -225,7 +221,7 @@
|
||||
//
|
||||
// buttonRemoveTank
|
||||
//
|
||||
this.buttonRemoveTank.Location = new System.Drawing.Point(20, 579);
|
||||
this.buttonRemoveTank.Location = new System.Drawing.Point(21, 501);
|
||||
this.buttonRemoveTank.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonRemoveTank.Name = "buttonRemoveTank";
|
||||
this.buttonRemoveTank.Size = new System.Drawing.Size(200, 47);
|
||||
@ -236,7 +232,7 @@
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(22, 544);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(21, 466);
|
||||
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
@ -246,7 +242,7 @@
|
||||
//
|
||||
// buttonAddTank
|
||||
//
|
||||
this.buttonAddTank.Location = new System.Drawing.Point(20, 489);
|
||||
this.buttonAddTank.Location = new System.Drawing.Point(21, 411);
|
||||
this.buttonAddTank.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonAddTank.Name = "buttonAddTank";
|
||||
this.buttonAddTank.Size = new System.Drawing.Size(200, 47);
|
||||
@ -260,7 +256,7 @@
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 28);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(812, 843);
|
||||
this.pictureBox.Size = new System.Drawing.Size(799, 758);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
@ -271,7 +267,7 @@
|
||||
this.файлToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1045, 28);
|
||||
this.menuStrip.Size = new System.Drawing.Size(1032, 28);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -306,33 +302,11 @@
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
this.buttonSortByType.Location = new System.Drawing.Point(20, 366);
|
||||
this.buttonSortByType.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonSortByType.Name = "buttonSortByType";
|
||||
this.buttonSortByType.Size = new System.Drawing.Size(200, 47);
|
||||
this.buttonSortByType.TabIndex = 15;
|
||||
this.buttonSortByType.Text = "Сортировать по типу";
|
||||
this.buttonSortByType.UseVisualStyleBackColor = true;
|
||||
this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click);
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
this.buttonSortByColor.Location = new System.Drawing.Point(22, 421);
|
||||
this.buttonSortByColor.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonSortByColor.Name = "buttonSortByColor";
|
||||
this.buttonSortByColor.Size = new System.Drawing.Size(200, 47);
|
||||
this.buttonSortByColor.TabIndex = 16;
|
||||
this.buttonSortByColor.Text = "Сортировать по цвету";
|
||||
this.buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click);
|
||||
//
|
||||
// FormMapWithSetTank
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1045, 871);
|
||||
this.ClientSize = new System.Drawing.Size(1032, 786);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBoxTools);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
@ -376,7 +350,5 @@
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button buttonSortByColor;
|
||||
private Button buttonSortByType;
|
||||
}
|
||||
}
|
@ -146,11 +146,6 @@ namespace ProjectMachine
|
||||
_logger.Warning("Ошибка переполнения хранилища: {0}", ex.Message);
|
||||
MessageBox.Show($"Ошибка переполнения хранилища: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warning("Такой объект уже есть:");
|
||||
MessageBox.Show($"Такой объект уже есть:", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
@ -299,34 +294,6 @@ namespace ProjectMachine
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка по типу
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSortByType_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new TankCompareByType());
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка по цвету
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSortByColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new TankCompareByColor());
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,14 +139,6 @@ namespace ProjectMachine
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public void Sort(IComparer<T> comparer)
|
||||
{
|
||||
_setTank.SortSet(comparer);
|
||||
}
|
||||
/// <summary>
|
||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||
/// </summary>
|
||||
private void Shaking()
|
||||
|
@ -51,7 +51,7 @@ namespace ProjectMachine
|
||||
public int Insert(T tank, int position)
|
||||
{
|
||||
if (_places.Contains(tank))
|
||||
throw new ArgumentException($"Такой объект уже есть");
|
||||
throw new ArgumentException($"Объект {tank} уже есть");
|
||||
if (Count >= _maxCount)
|
||||
throw new StorageOverflowException(Count);
|
||||
if (position < 0 || position >= _maxCount)
|
||||
@ -112,18 +112,6 @@ namespace ProjectMachine
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сортировка набора объектов
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public void SortSet(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectMachine
|
||||
{
|
||||
internal class TankCompareByColor : IComparer<IDrawningObject>
|
||||
{
|
||||
public int Compare(IDrawningObject? x, IDrawningObject? y)
|
||||
{
|
||||
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xTank = x as DrawningObject;
|
||||
var yTank = y as DrawningObject;
|
||||
if (xTank == null && yTank == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xTank == null && yTank != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xTank != null && yTank == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xColorName = xTank._machine.Machine.BodyColor.Name;
|
||||
var yColorName = yTank._machine.Machine.BodyColor.Name;
|
||||
return xColorName.CompareTo(yColorName);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectMachine
|
||||
{
|
||||
internal class TankCompareByType : IComparer<IDrawningObject>
|
||||
{
|
||||
public int Compare(IDrawningObject? x, IDrawningObject? y)
|
||||
{
|
||||
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xTank = x as DrawningObject;
|
||||
var yTank = y as DrawningObject;
|
||||
if (xTank == null && yTank == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xTank == null && yTank != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xTank != null && yTank == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (xTank.GetTank.GetType().Name != yTank.GetTank.GetType().Name)
|
||||
{
|
||||
if (xTank.GetTank.GetType().Name == "DrawningMachine")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var speedCompare = xTank.GetTank.Machine.Speed.CompareTo(yTank.GetTank.Machine.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xTank.GetTank.Machine.Weight.CompareTo(yTank.GetTank.Machine.Weight);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user