Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e227e7f26e | |||
| 811bba9e54 | |||
| a56ec182e5 | |||
| dfce1d08e1 | |||
| 3c14b35930 | |||
| a7aa4f92d6 | |||
| 619e8623ae | |||
| 27cbe93ede | |||
| c67d41e1ab | |||
| 6f2ab62ff2 | |||
| 392a0ee51f | |||
| c0cdda8b07 | |||
| 086e1efc24 | |||
| 3a7188b36e | |||
| 3972db5683 | |||
| 15f17de6aa | |||
| e1a39a5ee5 | |||
| 401fa5cbd7 | |||
| dd9105c2e4 | |||
| 3a18cfc72a |
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
{
|
||||
private IDrawingObject _drawningObject = null;
|
||||
protected int[,] _map = null;
|
||||
@@ -139,5 +139,45 @@ namespace Liner
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
|
||||
public bool Equals(AbstractMap? other)
|
||||
{
|
||||
if(other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherMap = other as AbstractMap;
|
||||
if(otherMap == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_width != otherMap._width)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_height != otherMap._height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_size_x != otherMap._size_x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_size_y != otherMap._size_y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
if (_map[i, j] != otherMap._map[i, j])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Liner
|
||||
{
|
||||
return _ship?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
public DrawingShip GetShip => _ship;
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_ship?.MoveTransport(direction);
|
||||
@@ -30,5 +31,56 @@ namespace Liner
|
||||
{
|
||||
_ship.DrawTransport(g);
|
||||
}
|
||||
public string GetInfo() => _ship?.GetDataForSave();
|
||||
public static IDrawingObject Create(string data) => new DrawingObjectShip(data.CreateDrawingShip());
|
||||
|
||||
public bool Equals(IDrawingObject? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherShip = other as DrawingObjectShip;
|
||||
if (otherShip == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ship = _ship.Ship;
|
||||
var otherShipShip = otherShip._ship.Ship;
|
||||
if (ship.GetType().Name != otherShipShip.GetType().Name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ship.Speed != otherShipShip.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ship.Weight != otherShipShip.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ship.BodyColor != otherShipShip.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ship is EntityLiner liner && otherShipShip is EntityLiner otherLiner)
|
||||
{
|
||||
if (liner.DopColor != otherLiner.DopColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (liner.Pool != otherLiner.Pool)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (liner.DopDeck != otherLiner.DopDeck)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
38
Liner/Liner/ExtentionShip.cs
Normal file
38
Liner/Liner/ExtentionShip.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal static class ExtentionShip
|
||||
{
|
||||
public static readonly char _separatorForObject = ':';
|
||||
public static DrawingShip CreateDrawingShip(this string info)
|
||||
{
|
||||
string[] strs=info.Split(_separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),Color.FromName(strs[2]));
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningLiner(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]));
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
public static string GetDataForSave(this DrawingShip drawingShip)
|
||||
{
|
||||
var ship = drawingShip.Ship;
|
||||
var str = $"{ship.Speed}{_separatorForObject}{ship.Weight}{_separatorForObject}{ship.BodyColor.Name}";
|
||||
if (ship is not EntityLiner liner)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{_separatorForObject}{liner.DopColor.Name}{_separatorForObject}{liner.DopDeck}{_separatorForObject}{liner.Pool}";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
109
Liner/Liner/FormMapWithSetShips.Designer.cs
generated
109
Liner/Liner/FormMapWithSetShips.Designer.cs
generated
@@ -45,13 +45,24 @@
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.ButtonAddShip = new System.Windows.Forms.Button();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.buttonSortType = new System.Windows.Forms.Button();
|
||||
this.buttonSortColor = new System.Windows.Forms.Button();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox
|
||||
//
|
||||
this.groupBox.Controls.Add(this.buttonSortColor);
|
||||
this.groupBox.Controls.Add(this.buttonSortType);
|
||||
this.groupBox.Controls.Add(this.groupBox1);
|
||||
this.groupBox.Controls.Add(this.buttonRight);
|
||||
this.groupBox.Controls.Add(this.buttonDown);
|
||||
@@ -63,9 +74,9 @@
|
||||
this.groupBox.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox.Controls.Add(this.ButtonAddShip);
|
||||
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox.Location = new System.Drawing.Point(696, 0);
|
||||
this.groupBox.Location = new System.Drawing.Point(696, 28);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(279, 668);
|
||||
this.groupBox.Size = new System.Drawing.Size(279, 746);
|
||||
this.groupBox.TabIndex = 0;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Инструменты";
|
||||
@@ -139,7 +150,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Liner.Properties.Resources._3;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(233, 626);
|
||||
this.buttonRight.Location = new System.Drawing.Point(233, 704);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 17;
|
||||
@@ -151,7 +162,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Liner.Properties.Resources._2;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(197, 626);
|
||||
this.buttonDown.Location = new System.Drawing.Point(197, 704);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 16;
|
||||
@@ -163,7 +174,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::Liner.Properties.Resources._4;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(197, 590);
|
||||
this.buttonUp.Location = new System.Drawing.Point(197, 668);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 15;
|
||||
@@ -175,7 +186,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Liner.Properties.Resources._1;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(161, 626);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(161, 704);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 14;
|
||||
@@ -184,7 +195,7 @@
|
||||
//
|
||||
// ButtonShowOnMap
|
||||
//
|
||||
this.ButtonShowOnMap.Location = new System.Drawing.Point(16, 558);
|
||||
this.ButtonShowOnMap.Location = new System.Drawing.Point(16, 633);
|
||||
this.ButtonShowOnMap.Name = "ButtonShowOnMap";
|
||||
this.ButtonShowOnMap.Size = new System.Drawing.Size(222, 29);
|
||||
this.ButtonShowOnMap.TabIndex = 13;
|
||||
@@ -194,7 +205,7 @@
|
||||
//
|
||||
// ButtonShowStorage
|
||||
//
|
||||
this.ButtonShowStorage.Location = new System.Drawing.Point(16, 505);
|
||||
this.ButtonShowStorage.Location = new System.Drawing.Point(16, 578);
|
||||
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
||||
this.ButtonShowStorage.Size = new System.Drawing.Size(222, 29);
|
||||
this.ButtonShowStorage.TabIndex = 12;
|
||||
@@ -204,7 +215,7 @@
|
||||
//
|
||||
// ButtonRemoveShip
|
||||
//
|
||||
this.ButtonRemoveShip.Location = new System.Drawing.Point(16, 452);
|
||||
this.ButtonRemoveShip.Location = new System.Drawing.Point(16, 543);
|
||||
this.ButtonRemoveShip.Name = "ButtonRemoveShip";
|
||||
this.ButtonRemoveShip.Size = new System.Drawing.Size(222, 29);
|
||||
this.ButtonRemoveShip.TabIndex = 11;
|
||||
@@ -214,7 +225,7 @@
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(16, 419);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(16, 510);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(222, 27);
|
||||
@@ -222,7 +233,7 @@
|
||||
//
|
||||
// ButtonAddShip
|
||||
//
|
||||
this.ButtonAddShip.Location = new System.Drawing.Point(16, 368);
|
||||
this.ButtonAddShip.Location = new System.Drawing.Point(16, 462);
|
||||
this.ButtonAddShip.Name = "ButtonAddShip";
|
||||
this.ButtonAddShip.Size = new System.Drawing.Size(222, 29);
|
||||
this.ButtonAddShip.TabIndex = 2;
|
||||
@@ -233,19 +244,78 @@
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 28);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(696, 668);
|
||||
this.pictureBox.Size = new System.Drawing.Size(696, 746);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.FileToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(975, 28);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
this.FileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";
|
||||
this.FileToolStripMenuItem.Size = new System.Drawing.Size(59, 24);
|
||||
this.FileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
|
||||
this.SaveToolStripMenuItem.Text = "Сохранение";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
|
||||
this.LoadToolStripMenuItem.Text = "Загрузка";
|
||||
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// buttonSortType
|
||||
//
|
||||
this.buttonSortType.Location = new System.Drawing.Point(16, 355);
|
||||
this.buttonSortType.Name = "buttonSortType";
|
||||
this.buttonSortType.Size = new System.Drawing.Size(222, 29);
|
||||
this.buttonSortType.TabIndex = 19;
|
||||
this.buttonSortType.Text = "Сортировать по типу";
|
||||
this.buttonSortType.UseVisualStyleBackColor = true;
|
||||
this.buttonSortType.Click += new System.EventHandler(this.ButtonSortType_Click);
|
||||
//
|
||||
// buttonSortColor
|
||||
//
|
||||
this.buttonSortColor.Location = new System.Drawing.Point(16, 390);
|
||||
this.buttonSortColor.Name = "buttonSortColor";
|
||||
this.buttonSortColor.Size = new System.Drawing.Size(222, 29);
|
||||
this.buttonSortColor.TabIndex = 20;
|
||||
this.buttonSortColor.Text = "Сортировать по цвету";
|
||||
this.buttonSortColor.UseVisualStyleBackColor = true;
|
||||
this.buttonSortColor.Click += new System.EventHandler(this.ButtonSortColor_Click);
|
||||
//
|
||||
// FormMapWithSetShips
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(975, 668);
|
||||
this.ClientSize = new System.Drawing.Size(975, 774);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormMapWithSetShips";
|
||||
this.Text = "FormMapWithSetShips";
|
||||
this.groupBox.ResumeLayout(false);
|
||||
@@ -253,7 +323,10 @@
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -276,5 +349,13 @@
|
||||
private ListBox ListBoxMaps;
|
||||
private Button ButtonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button buttonSortColor;
|
||||
private Button buttonSortType;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -20,9 +21,12 @@ namespace Liner
|
||||
{"Болото",new SwampMap() }
|
||||
};
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
public FormMapWithSetShips()
|
||||
|
||||
private ILogger _logger;
|
||||
public FormMapWithSetShips(ILogger<FormMapWithSetShips>logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||
ComboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapDict)
|
||||
@@ -57,20 +61,29 @@ namespace Liner
|
||||
}
|
||||
private void AddShip(DrawingShip ship)
|
||||
{
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
try
|
||||
{
|
||||
return;
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectShip(ship) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation("Добавлен объект {@Ship}", ship);
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogWarning("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectShip(ship) != -1)
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogWarning("Ошибка, переполнение хранилища :{0}", ex.Message);
|
||||
MessageBox.Show($"Ошибка хранилище переполнено: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -87,14 +100,30 @@ namespace Liner
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
try
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
var deletedShip = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
|
||||
if (deletedShip != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation("Из текущей карты удалён объект {@Ship}", deletedShip);
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Не удалось удалить объект по позиции {0}. Объект равен null", pos);
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (ShipNotFoundException ex)
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
_logger.LogWarning("Ошибка удаления: {0}", ex.Message);
|
||||
MessageBox.Show($"Ошибка удаления: {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning("Неизвестная ошибка удаления: {0}", ex.Message);
|
||||
MessageBox.Show($"Неизвестная ошибка: {ex.Message}");
|
||||
}
|
||||
}
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
@@ -143,19 +172,23 @@ namespace Liner
|
||||
if (ComboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning("При добавлении карты {0}", ComboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта");
|
||||
return;
|
||||
}
|
||||
if (!_mapDict.ContainsKey(ComboBoxSelectorMap.Text))
|
||||
{
|
||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning("Отсутствует карта с типом {0}", ComboBoxSelectorMap.Text);
|
||||
return;
|
||||
}
|
||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapDict[ComboBoxSelectorMap.Text]);
|
||||
ReloadMaps();
|
||||
_logger.LogInformation($"Добавлена карта: {textBoxNewMapName.Text}");
|
||||
}
|
||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation("Осуществлён переход на карту под названием {0}", ListBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
}
|
||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -165,9 +198,67 @@ namespace Liner
|
||||
}
|
||||
if (MessageBox.Show($"Удалить карту {ListBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_logger.LogInformation("Удалена карта {0}", ListBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
_mapsCollection.DelMap(ListBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
ReloadMaps();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.SaveData(saveFileDialog.FileName);
|
||||
_logger.LogInformation("Сохранение прошло успешно. Расположение файла: {0}", saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
MessageBox.Show($"Не сохранилось:{ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning("Не удалось сохранить файл '{0}'. Текст ошибки: {1}", saveFileDialog.FileName, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.LoadData(openFileDialog.FileName);
|
||||
_logger.LogInformation("Загрузка данных из файла '{0}' прошла успешно", openFileDialog.FileName);
|
||||
ReloadMaps();
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogWarning("Не удалось загрузить файл '{0}'. Текст ошибки: {1}", openFileDialog.FileName, ex.Message);
|
||||
MessageBox.Show($"Не загрузилось:{ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonSortType_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new ShipCompareByType());
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
private void ButtonSortColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new ShipCompareByColor());
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>144, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>311, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
@@ -14,5 +14,6 @@ namespace Liner
|
||||
void DrawningObject(Graphics g);
|
||||
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
string GetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Liner
|
||||
{
|
||||
internal class MapWithSetShipsGeneric<T, U>
|
||||
where T : class, IDrawingObject
|
||||
where T : class, IDrawingObject, IEquatable<T>
|
||||
where U : AbstractMap
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
@@ -58,6 +58,26 @@ namespace Liner
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
public string GetData(char separatorType, char separatorData)
|
||||
{
|
||||
string data = $"{_map.GetType().Name}{separatorType}";
|
||||
foreach (var ship in _setShips.GetShips())
|
||||
{
|
||||
data += $"{ship.GetInfo()}{separatorData}";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
public void LoadData(string[] records)
|
||||
{
|
||||
foreach (var rec in records)
|
||||
{
|
||||
_setShips.Insert(DrawingObjectShip.Create(rec) as T);
|
||||
}
|
||||
}
|
||||
public void Sort(IComparer<T> comparer)
|
||||
{
|
||||
_setShips.SortSet(comparer);
|
||||
}
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setShips.Count - 1;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -8,13 +10,15 @@ namespace Liner
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
readonly Dictionary<string, MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>> _mapStorages;
|
||||
readonly Dictionary<string, MapWithSetShipsGeneric<IDrawingObject, AbstractMap>> _mapStorages;
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly char separatorDict = '|';
|
||||
private readonly char separatorData = ';';
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string, MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>>();
|
||||
_mapStorages = new Dictionary<string, MapWithSetShipsGeneric<IDrawingObject, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
@@ -22,14 +26,14 @@ namespace Liner
|
||||
{
|
||||
if (!_mapStorages.ContainsKey(name))
|
||||
{
|
||||
_mapStorages.Add(name, new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages.Add(name, new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
}
|
||||
public void DelMap(string name)
|
||||
{
|
||||
if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name);
|
||||
}
|
||||
public MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap> this[string ind]
|
||||
public MapWithSetShipsGeneric<IDrawingObject, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -40,5 +44,58 @@ namespace Liner
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
sw.Write($"MapsCollection{Environment.NewLine}");
|
||||
foreach (var storage in _mapStorages)
|
||||
{
|
||||
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string str = "";
|
||||
if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection"))
|
||||
{
|
||||
throw new FileFormatException("Формат данных в файле не правильный");
|
||||
}
|
||||
_mapStorages.Clear();
|
||||
while ((str = sr.ReadLine()) != null)
|
||||
{
|
||||
var tempElem = str.Split(separatorDict);
|
||||
AbstractMap map = null;
|
||||
switch (tempElem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "SeaMap":
|
||||
map = new SeaMap();
|
||||
break;
|
||||
case "SwampMap":
|
||||
map = new SwampMap();
|
||||
break;
|
||||
|
||||
}
|
||||
_mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal static class Program
|
||||
@@ -11,7 +16,27 @@ namespace Liner
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMapWithSetShips());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormMapWithSetShips>());
|
||||
}
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormMapWithSetShips>();
|
||||
|
||||
var serilogLogger = new LoggerConfiguration()
|
||||
.WriteTo.RollingFile("Logs\\log.txt")
|
||||
.CreateLogger();
|
||||
|
||||
services.AddLogging(builder =>
|
||||
{
|
||||
builder.SetMinimumLevel(LogLevel.Information);
|
||||
builder.AddSerilog(logger: serilogLogger, dispose: true);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Liner
|
||||
{
|
||||
internal class SetShipsGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
public int Count => _places.Count;
|
||||
@@ -23,7 +23,15 @@ namespace Liner
|
||||
}
|
||||
public int Insert(T ship, int position)
|
||||
{
|
||||
if (position < 0 || position > Count || _maxCount == Count) return -1;
|
||||
if (_places.Contains(ship))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (Count == _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
}
|
||||
if (position < 0 || position > _maxCount) return -1;
|
||||
_places.Insert(position, ship);
|
||||
return position;
|
||||
}
|
||||
@@ -31,7 +39,7 @@ namespace Liner
|
||||
{
|
||||
if (position >= Count || position < 0)
|
||||
{
|
||||
return null;
|
||||
throw new ShipNotFoundException(position);
|
||||
}
|
||||
T ship = _places[position];
|
||||
_places.RemoveAt(position);
|
||||
@@ -71,5 +79,13 @@ namespace Liner
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SortSet(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Liner/Liner/ShipCompareByColor.cs
Normal file
71
Liner/Liner/ShipCompareByColor.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal class ShipCompareByColor : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? x, IDrawingObject? y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xShip= x as DrawingObjectShip;
|
||||
var yShip = y as DrawingObjectShip;
|
||||
if (xShip == null && yShip == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xShip == null && yShip != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xShip != null && yShip == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
string xShipColor = xShip.GetShip.Ship.BodyColor.Name;
|
||||
string yShipColor = yShip.GetShip.Ship.BodyColor.Name;
|
||||
if (xShipColor != yShipColor)
|
||||
{
|
||||
return xShipColor.CompareTo(yShipColor);
|
||||
}
|
||||
if (xShip.GetShip.GetType().Name != yShip.GetShip.GetType().Name)
|
||||
{
|
||||
if (xShip.GetShip.GetType().Name == "DrawingShip")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (xShip.GetShip.Ship is EntityLiner xLiner && yShip.GetShip.Ship is EntityLiner yLiner)
|
||||
{
|
||||
string xShipDopColor = xLiner.DopColor.Name;
|
||||
string yShipDopColor = yLiner.DopColor.Name;
|
||||
var dopColorCompare = xShipDopColor.CompareTo(yShipDopColor);
|
||||
if (dopColorCompare != 0)
|
||||
{
|
||||
return dopColorCompare;
|
||||
}
|
||||
}
|
||||
var speedCompare = xShip.GetShip.Ship.Speed.CompareTo(yShip.GetShip.Ship.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xShip.GetShip.Ship.Weight.CompareTo(yShip.GetShip.Ship.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Liner/Liner/ShipCompareByType.cs
Normal file
55
Liner/Liner/ShipCompareByType.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
internal class ShipCompareByType : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject? x, IDrawingObject? y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xShip = x as DrawingObjectShip;
|
||||
var yShip = y as DrawingObjectShip;
|
||||
if (xShip == null && yShip == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xShip == null && yShip != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xShip != null && yShip == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (xShip.GetShip.GetType().Name != yShip.GetShip.GetType().Name)
|
||||
{
|
||||
if (xShip.GetShip.GetType().Name == "DrawingShip")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var speedCompare = xShip.GetShip.Ship.Speed.CompareTo(yShip.GetShip.Ship.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xShip.GetShip.Ship.Weight.CompareTo(yShip.GetShip.Ship.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Liner/Liner/ShipNotFoundException.cs
Normal file
19
Liner/Liner/ShipNotFoundException.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
[Serializable]
|
||||
internal class ShipNotFoundException: ApplicationException
|
||||
{
|
||||
public ShipNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||
public ShipNotFoundException() : base() { }
|
||||
public ShipNotFoundException(string message) : base(message) { }
|
||||
public ShipNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected ShipNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
19
Liner/Liner/StorageOverflowException.cs
Normal file
19
Liner/Liner/StorageOverflowException.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liner
|
||||
{
|
||||
[Serializable]
|
||||
internal class StorageOverflowException: ApplicationException
|
||||
{
|
||||
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
||||
public StorageOverflowException():base(){}
|
||||
public StorageOverflowException(string message):base(message){}
|
||||
public StorageOverflowException(string message, Exception exception):base(message, exception){}
|
||||
protected StorageOverflowException(SerializationInfo info, StreamingContext context): base(info, context){}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user