Laba06
This commit is contained in:
parent
689ec4a5ce
commit
3e6e60a533
@ -7,10 +7,9 @@ using static ProjectContainerShip.Direction;
|
|||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
namespace ProjectContainerShip.MovementStrategy
|
namespace ProjectContainerShip.MovementStrategy
|
||||||
{
|
{/// <summary>
|
||||||
/// <summary>
|
/// Класс-стратегия перемещения объекта
|
||||||
/// Класс-стратегия перемещения объекта
|
/// </summary>
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractStrategy
|
public abstract class AbstractStrategy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ProjectContainerShip.DrawningObjects;
|
using ProjectContainerShip.DrawningObjects;
|
||||||
using ProjectContainerShip.Generics;
|
|
||||||
using ProjectContainerShip.MovementStrategy;
|
using ProjectContainerShip.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectContainerShip.Generics
|
namespace ProjectContainerShip.Generics
|
||||||
@ -18,6 +17,10 @@ namespace ProjectContainerShip.Generics
|
|||||||
where T : DrawningShip
|
where T : DrawningShip
|
||||||
where U : IMoveableObject
|
where U : IMoveableObject
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<T?> GetShip => _collection.GetShip();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна прорисовки
|
/// Ширина окна прорисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,14 +60,14 @@ namespace ProjectContainerShip.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator +(ContainerGenericCollection<T, U> collect, T?
|
public static int? operator +(ContainerGenericCollection<T, U> collect, T?
|
||||||
obj)
|
obj)
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
return collect?._collection.Insert(obj) ?? false;
|
return collect?._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
@ -72,14 +75,15 @@ namespace ProjectContainerShip.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? operator -(ContainerGenericCollection<T, U> collect, int pos)
|
public static bool operator -(ContainerGenericCollection<T, U> collect, int
|
||||||
|
pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection[pos];
|
T? obj = collect._collection[pos];
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
collect._collection.Remove(pos);
|
return collect._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return obj;
|
return false;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject
|
/// Получение объекта IMoveableObject
|
||||||
|
@ -32,6 +32,18 @@ namespace ProjectContainerShip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записей коллекции данных в файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pictureWidth"></param>
|
/// <param name="pictureWidth"></param>
|
||||||
@ -51,8 +63,8 @@ namespace ProjectContainerShip
|
|||||||
{
|
{
|
||||||
if (!_shipStorages.ContainsKey(name))
|
if (!_shipStorages.ContainsKey(name))
|
||||||
{
|
{
|
||||||
ContainerGenericCollection<DrawningShip, DrawningObjectShip> newSet = new ContainerGenericCollection<DrawningShip, DrawningObjectShip>(_pictureWidth, _pictureHeight);
|
var shipCollection = new ContainerGenericCollection<DrawningShip, DrawningObjectShip>(_pictureWidth, _pictureHeight);
|
||||||
_shipStorages.Add(name, newSet);
|
_shipStorages.Add(name, shipCollection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,6 +94,95 @@ namespace ProjectContainerShip
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение информации в хранилище в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
foreach (KeyValuePair<string,
|
||||||
|
ContainerGenericCollection<DrawningShip, DrawningObjectShip>> record in _shipStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawningShip? elem in record.Value.GetShip)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
|
{
|
||||||
|
writer.WriteLine("shipStorages");
|
||||||
|
writer.Write(data.ToString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader reader = new StreamReader(filename))
|
||||||
|
{
|
||||||
|
string cheker = reader.ReadLine();
|
||||||
|
if (cheker == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!cheker.StartsWith("shipStorages"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_shipStorages.Clear();
|
||||||
|
string strs;
|
||||||
|
bool firstinit = true;
|
||||||
|
while ((strs = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (strs == null && firstinit)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strs == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
firstinit = false;
|
||||||
|
string name = strs.Split(_separatorForKeyValue)[0];
|
||||||
|
ContainerGenericCollection<DrawningShip, DrawningObjectShip> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
foreach (string data in strs.Split(_separatorForKeyValue)[1].Split(_separatorRecords))
|
||||||
|
{
|
||||||
|
DrawningShip? ship =
|
||||||
|
data?.CreateDrawningShip(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (ship != null)
|
||||||
|
{
|
||||||
|
int? result = collection + ship;
|
||||||
|
if (result == null || result.Value == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_shipStorages.Add(name, collection);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,8 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Resources\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -37,7 +37,7 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor);
|
||||||
if (containerShip.Container)
|
if (containerShip.Container)
|
||||||
{
|
{
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 7, 35, 5);
|
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 7, 35, 5);
|
||||||
|
@ -32,5 +32,19 @@ namespace ProjectContainerShip.MovementStrategy
|
|||||||
public int GetStep => (int)(_drawningShip?.EntityShip?.Step ?? 0);
|
public int GetStep => (int)(_drawningShip?.EntityShip?.Step ?? 0);
|
||||||
public bool CheckCanMove(DirectionType direction) => _drawningShip?.CanMove(direction) ?? false;
|
public bool CheckCanMove(DirectionType direction) => _drawningShip?.CanMove(direction) ?? false;
|
||||||
public void MoveObject(DirectionType direction) => _drawningShip?.MoveTransport(direction);
|
public void MoveObject(DirectionType direction) => _drawningShip?.MoveTransport(direction);
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (_drawningShip != null)
|
||||||
|
{
|
||||||
|
_drawningShip.SetPosition(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Draw(Graphics g)
|
||||||
|
{
|
||||||
|
if (_drawningShip != null)
|
||||||
|
{
|
||||||
|
_drawningShip.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,12 +57,9 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
public DrawningShip(int speed, double weight, Color bodyColor, int width, int height)
|
public DrawningShip(int speed, double weight, Color bodyColor, int width, int height)
|
||||||
{
|
{
|
||||||
if (width > _shipWidth && height > _shipHeight)
|
|
||||||
{
|
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityShip = new EntityShip(speed, weight, bodyColor);
|
EntityShip = new EntityShip(speed, weight, bodyColor);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -97,7 +94,6 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
else _startPosX = 0;
|
else _startPosX = 0;
|
||||||
if ((y > 0) && (y < _pictureHeight))
|
if ((y > 0) && (y < _pictureHeight))
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
|
|
||||||
else _startPosY = 0;
|
else _startPosY = 0;
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
@ -118,7 +114,6 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
/// Высота объекта
|
/// Высота объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetHeight => _shipHeight;
|
public int GetHeight => _shipHeight;
|
||||||
public object GetObjectPosition { get; internal set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Проверка, что объект может переместится по указанному направлению
|
/// Проверка, что объект может переместится по указанному направлению
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -157,19 +152,19 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
_startPosX -= (int)EntityShip.Step;
|
_startPosX -= (int)EntityShip.Step;
|
||||||
break;
|
break;
|
||||||
//вверх
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
_startPosY -= (int)EntityShip.Step;
|
_startPosY -= (int)EntityShip.Step;
|
||||||
break;
|
break;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
_startPosX += (int)EntityShip.Step;
|
_startPosX += (int)EntityShip.Step;
|
||||||
break;
|
break;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
_startPosY += (int)EntityShip.Step;
|
_startPosY += (int)EntityShip.Step;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -177,11 +172,11 @@ namespace ProjectContainerShip.DrawningObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityShip == null)
|
if (EntityShip == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Brush bodyColor = new SolidBrush(EntityShip.BodyColor);
|
Brush bodyColor = new SolidBrush(EntityShip.BodyColor);
|
||||||
//границы корабля
|
//границы корабля
|
||||||
Brush brRd = new SolidBrush(Color.Red);
|
Brush brRd = new SolidBrush(Color.Red);
|
||||||
|
@ -21,7 +21,6 @@ namespace ProjectContainerShip.Entities
|
|||||||
/// Признак (опция) наличия дополнительных контейнеров
|
/// Признак (опция) наличия дополнительных контейнеров
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Container { get; private set; }
|
public bool Container { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация полей объекта-класса контейнеровоза
|
/// Инициализация полей объекта-класса контейнеровоза
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -29,8 +28,8 @@ namespace ProjectContainerShip.Entities
|
|||||||
/// <param name="weight">Вес </param>
|
/// <param name="weight">Вес </param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
/// <param name="crane">Признак наличия труб</param>
|
/// <param name="crane">Признак наличия крана</param>
|
||||||
/// <param name="container">Признак наличия топлива</param>
|
/// <param name="container">Признак наличия контейнеров</param>
|
||||||
public EntityContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) : base(speed, weight, bodyColor)
|
public EntityContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
|
64
ContainerShip/ContainerShip/ExtentionDrawningContainer.cs
Normal file
64
ContainerShip/ContainerShip/ExtentionDrawningContainer.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectContainerShip.Entities;
|
||||||
|
|
||||||
|
namespace ProjectContainerShip.DrawningObjects
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Расширение для класса EntityShip
|
||||||
|
/// </summary>
|
||||||
|
public static class ExtentionDrawningContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <param name="width">Ширина</param>
|
||||||
|
/// <param name="height">Высота</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawningShip? CreateDrawningShip(this string info, char
|
||||||
|
separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawningShip(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
else if (strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawningContainerShip(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]),
|
||||||
|
Color.FromName(strs[3]),
|
||||||
|
Convert.ToBoolean(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5]), width, height);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningShip">Сохраняемый объект</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawningShip drawningShip, char separatorForObject)
|
||||||
|
{
|
||||||
|
var ship = drawningShip.EntityShip;
|
||||||
|
if (ship == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str = $"{ship.Speed}{separatorForObject}{ship.Weight}{separatorForObject}{ship.BodyColor.Name}";
|
||||||
|
if (ship is not EntityContainerShip dopShip)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{separatorForObject}{dopShip.AdditionalColor.Name}{separatorForObject}{dopShip.Crane}{separatorForObject}{dopShip.Container}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,13 +34,20 @@
|
|||||||
buttonRemoveEx = new Button();
|
buttonRemoveEx = new Button();
|
||||||
buttonRefreshCollection = new Button();
|
buttonRefreshCollection = new Button();
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
fileToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
groupBox2 = new GroupBox();
|
groupBox2 = new GroupBox();
|
||||||
textBoxStorageName = new TextBox();
|
textBoxStorageName = new TextBox();
|
||||||
buttonDelObject = new Button();
|
buttonDelObject = new Button();
|
||||||
listBoxStorages = new ListBox();
|
listBoxStorages = new ListBox();
|
||||||
buttonAddObject = new Button();
|
buttonAddObject = new Button();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
groupBox2.SuspendLayout();
|
groupBox2.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -55,14 +62,14 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
maskedTextBoxNumber.Location = new Point(21, 326);
|
maskedTextBoxNumber.Location = new Point(19, 404);
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
maskedTextBoxNumber.Size = new Size(95, 27);
|
maskedTextBoxNumber.Size = new Size(95, 27);
|
||||||
maskedTextBoxNumber.TabIndex = 1;
|
maskedTextBoxNumber.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonAddEx
|
// buttonAddEx
|
||||||
//
|
//
|
||||||
buttonAddEx.Location = new Point(21, 282);
|
buttonAddEx.Location = new Point(19, 371);
|
||||||
buttonAddEx.Name = "buttonAddEx";
|
buttonAddEx.Name = "buttonAddEx";
|
||||||
buttonAddEx.Size = new Size(95, 27);
|
buttonAddEx.Size = new Size(95, 27);
|
||||||
buttonAddEx.TabIndex = 2;
|
buttonAddEx.TabIndex = 2;
|
||||||
@ -72,7 +79,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveEx
|
// buttonRemoveEx
|
||||||
//
|
//
|
||||||
buttonRemoveEx.Location = new Point(19, 359);
|
buttonRemoveEx.Location = new Point(19, 437);
|
||||||
buttonRemoveEx.Name = "buttonRemoveEx";
|
buttonRemoveEx.Name = "buttonRemoveEx";
|
||||||
buttonRemoveEx.Size = new Size(95, 27);
|
buttonRemoveEx.Size = new Size(95, 27);
|
||||||
buttonRemoveEx.TabIndex = 3;
|
buttonRemoveEx.TabIndex = 3;
|
||||||
@ -82,7 +89,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRefreshCollection
|
// buttonRefreshCollection
|
||||||
//
|
//
|
||||||
buttonRefreshCollection.Location = new Point(21, 405);
|
buttonRefreshCollection.Location = new Point(19, 470);
|
||||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||||
buttonRefreshCollection.Size = new Size(95, 27);
|
buttonRefreshCollection.Size = new Size(95, 27);
|
||||||
buttonRefreshCollection.TabIndex = 4;
|
buttonRefreshCollection.TabIndex = 4;
|
||||||
@ -92,6 +99,7 @@
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
|
groupBox1.Controls.Add(menuStrip);
|
||||||
groupBox1.Controls.Add(groupBox2);
|
groupBox1.Controls.Add(groupBox2);
|
||||||
groupBox1.Controls.Add(buttonAddEx);
|
groupBox1.Controls.Add(buttonAddEx);
|
||||||
groupBox1.Controls.Add(buttonRefreshCollection);
|
groupBox1.Controls.Add(buttonRefreshCollection);
|
||||||
@ -99,18 +107,50 @@
|
|||||||
groupBox1.Controls.Add(buttonRemoveEx);
|
groupBox1.Controls.Add(buttonRemoveEx);
|
||||||
groupBox1.Location = new Point(812, 0);
|
groupBox1.Location = new Point(812, 0);
|
||||||
groupBox1.Name = "groupBox1";
|
groupBox1.Name = "groupBox1";
|
||||||
groupBox1.Size = new Size(120, 461);
|
groupBox1.Size = new Size(120, 503);
|
||||||
groupBox1.TabIndex = 5;
|
groupBox1.TabIndex = 5;
|
||||||
groupBox1.TabStop = false;
|
groupBox1.TabStop = false;
|
||||||
groupBox1.Text = "Инструменты";
|
groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(3, 23);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip.Size = new Size(114, 30);
|
||||||
|
menuStrip.TabIndex = 8;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// fileToolStripMenuItem
|
||||||
|
//
|
||||||
|
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||||
|
fileToolStripMenuItem.Size = new Size(59, 24);
|
||||||
|
fileToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
SaveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click_1;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
LoadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
groupBox2.Controls.Add(textBoxStorageName);
|
groupBox2.Controls.Add(textBoxStorageName);
|
||||||
groupBox2.Controls.Add(buttonDelObject);
|
groupBox2.Controls.Add(buttonDelObject);
|
||||||
groupBox2.Controls.Add(listBoxStorages);
|
groupBox2.Controls.Add(listBoxStorages);
|
||||||
groupBox2.Controls.Add(buttonAddObject);
|
groupBox2.Controls.Add(buttonAddObject);
|
||||||
groupBox2.Location = new Point(13, 28);
|
groupBox2.Location = new Point(6, 151);
|
||||||
groupBox2.Name = "groupBox2";
|
groupBox2.Name = "groupBox2";
|
||||||
groupBox2.Size = new Size(116, 214);
|
groupBox2.Size = new Size(116, 214);
|
||||||
groupBox2.TabIndex = 5;
|
groupBox2.TabIndex = 5;
|
||||||
@ -119,15 +159,14 @@
|
|||||||
//
|
//
|
||||||
// textBoxStorageName
|
// textBoxStorageName
|
||||||
//
|
//
|
||||||
textBoxStorageName.Location = new Point(8, 26);
|
textBoxStorageName.Location = new Point(13, 26);
|
||||||
textBoxStorageName.Name = "textBoxStorageName";
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
textBoxStorageName.Size = new Size(95, 27);
|
textBoxStorageName.Size = new Size(95, 27);
|
||||||
textBoxStorageName.TabIndex = 6;
|
textBoxStorageName.TabIndex = 6;
|
||||||
textBoxStorageName.TextChanged += textBoxStorageName_TextChanged;
|
|
||||||
//
|
//
|
||||||
// buttonDelObject
|
// buttonDelObject
|
||||||
//
|
//
|
||||||
buttonDelObject.Location = new Point(8, 162);
|
buttonDelObject.Location = new Point(13, 162);
|
||||||
buttonDelObject.Name = "buttonDelObject";
|
buttonDelObject.Name = "buttonDelObject";
|
||||||
buttonDelObject.Size = new Size(95, 27);
|
buttonDelObject.Size = new Size(95, 27);
|
||||||
buttonDelObject.TabIndex = 8;
|
buttonDelObject.TabIndex = 8;
|
||||||
@ -139,7 +178,7 @@
|
|||||||
//
|
//
|
||||||
listBoxStorages.FormattingEnabled = true;
|
listBoxStorages.FormattingEnabled = true;
|
||||||
listBoxStorages.ItemHeight = 20;
|
listBoxStorages.ItemHeight = 20;
|
||||||
listBoxStorages.Location = new Point(8, 92);
|
listBoxStorages.Location = new Point(13, 92);
|
||||||
listBoxStorages.Name = "listBoxStorages";
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
listBoxStorages.Size = new Size(95, 64);
|
listBoxStorages.Size = new Size(95, 64);
|
||||||
listBoxStorages.TabIndex = 6;
|
listBoxStorages.TabIndex = 6;
|
||||||
@ -147,7 +186,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddObject
|
// buttonAddObject
|
||||||
//
|
//
|
||||||
buttonAddObject.Location = new Point(8, 59);
|
buttonAddObject.Location = new Point(13, 59);
|
||||||
buttonAddObject.Name = "buttonAddObject";
|
buttonAddObject.Name = "buttonAddObject";
|
||||||
buttonAddObject.Size = new Size(95, 27);
|
buttonAddObject.Size = new Size(95, 27);
|
||||||
buttonAddObject.TabIndex = 7;
|
buttonAddObject.TabIndex = 7;
|
||||||
@ -155,6 +194,17 @@
|
|||||||
buttonAddObject.UseVisualStyleBackColor = true;
|
buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
buttonAddObject.Click += ButtonAddObject_Click;
|
buttonAddObject.Click += ButtonAddObject_Click;
|
||||||
//
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
saveFileDialog.Title = "Выберите текстовый файл";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.FileName = "openFileDialog1";
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
openFileDialog.Title = "Сохранить текстовый файл";
|
||||||
|
//
|
||||||
// FormContainerCollection
|
// FormContainerCollection
|
||||||
//
|
//
|
||||||
ClientSize = new Size(932, 503);
|
ClientSize = new Size(932, 503);
|
||||||
@ -164,6 +214,8 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
groupBox1.PerformLayout();
|
groupBox1.PerformLayout();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
groupBox2.ResumeLayout(false);
|
groupBox2.ResumeLayout(false);
|
||||||
groupBox2.PerformLayout();
|
groupBox2.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
@ -182,5 +234,11 @@
|
|||||||
private Button buttonDelObject;
|
private Button buttonDelObject;
|
||||||
private ListBox listBoxStorages;
|
private ListBox listBoxStorages;
|
||||||
private Button buttonAddObject;
|
private Button buttonAddObject;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem fileToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,24 +108,24 @@ namespace ProjectContainerShip
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var form = new FormContainerConfig();
|
var form = new FormContainerConfig();
|
||||||
form.AddEvent(deleg =>
|
form.AddEvent(ship =>
|
||||||
{
|
{
|
||||||
bool SelectedShip = (obj + deleg);
|
if (listBoxStorages.SelectedIndex != -1)
|
||||||
if (SelectedShip)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
var obj = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty];
|
||||||
pictureBoxCollection.Image = obj.ShowContainer();
|
if (obj != null)
|
||||||
}
|
{
|
||||||
else
|
if (obj + ship != 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowContainer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
form.Show();
|
form.Show();
|
||||||
@ -182,8 +182,59 @@ namespace ProjectContainerShip
|
|||||||
}
|
}
|
||||||
pictureBoxCollection.Image = obj.ShowContainer();
|
pictureBoxCollection.Image = obj.ShowContainer();
|
||||||
}
|
}
|
||||||
private void textBoxStorageName_TextChanged(object sender, EventArgs e)
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Сохранение"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void SaveToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.SaveData(saveFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Сохранение прошло успешно",
|
||||||
|
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не сохранилось", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Загрузка"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузка прошла успешно",
|
||||||
|
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
ReloadObjects();
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBoxCollection.Image = obj.ShowContainer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не загрузилось", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>259, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>126, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -89,7 +89,6 @@
|
|||||||
labelModifiedObject.TabIndex = 8;
|
labelModifiedObject.TabIndex = 8;
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
labelModifiedObject.Click += labelModifiedObject_Click;
|
|
||||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
//
|
//
|
||||||
// labelSimpleObject
|
// labelSimpleObject
|
||||||
@ -212,7 +211,6 @@
|
|||||||
checkBoxContainer.TabIndex = 5;
|
checkBoxContainer.TabIndex = 5;
|
||||||
checkBoxContainer.Text = "Признак наличия крана";
|
checkBoxContainer.Text = "Признак наличия крана";
|
||||||
checkBoxContainer.UseVisualStyleBackColor = true;
|
checkBoxContainer.UseVisualStyleBackColor = true;
|
||||||
checkBoxContainer.CheckedChanged += checkBoxBodyKit_CheckedChanged;
|
|
||||||
//
|
//
|
||||||
// checkBoxCrane
|
// checkBoxCrane
|
||||||
//
|
//
|
||||||
@ -224,7 +222,6 @@
|
|||||||
checkBoxCrane.TabIndex = 4;
|
checkBoxCrane.TabIndex = 4;
|
||||||
checkBoxCrane.Text = "Признак наличия котнейнеров";
|
checkBoxCrane.Text = "Признак наличия котнейнеров";
|
||||||
checkBoxCrane.UseVisualStyleBackColor = true;
|
checkBoxCrane.UseVisualStyleBackColor = true;
|
||||||
checkBoxCrane.CheckedChanged += checkBoxCrane_CheckedChanged;
|
|
||||||
//
|
//
|
||||||
// numericUpDownWeight
|
// numericUpDownWeight
|
||||||
//
|
//
|
||||||
@ -236,7 +233,6 @@
|
|||||||
numericUpDownWeight.Size = new Size(83, 27);
|
numericUpDownWeight.Size = new Size(83, 27);
|
||||||
numericUpDownWeight.TabIndex = 3;
|
numericUpDownWeight.TabIndex = 3;
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
numericUpDownWeight.ValueChanged += numericUpDownWeight_ValueChanged;
|
|
||||||
//
|
//
|
||||||
// numericUpDownSpeed
|
// numericUpDownSpeed
|
||||||
//
|
//
|
||||||
@ -248,7 +244,6 @@
|
|||||||
numericUpDownSpeed.Size = new Size(83, 27);
|
numericUpDownSpeed.Size = new Size(83, 27);
|
||||||
numericUpDownSpeed.TabIndex = 2;
|
numericUpDownSpeed.TabIndex = 2;
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
numericUpDownSpeed.ValueChanged += numericUpDownSpeed_ValueChanged;
|
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
|
@ -32,6 +32,7 @@ namespace ProjectContainerShip
|
|||||||
panelWhite.MouseDown += panelColor_MouseDown;
|
panelWhite.MouseDown += panelColor_MouseDown;
|
||||||
panelYellow.MouseDown += panelColor_MouseDown;
|
panelYellow.MouseDown += panelColor_MouseDown;
|
||||||
panelBlue.MouseDown += panelColor_MouseDown;
|
panelBlue.MouseDown += panelColor_MouseDown;
|
||||||
|
// TODO buttonCancel.Click with lambda
|
||||||
buttonCancel.Click += (sender, e) => Close();
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -123,7 +124,6 @@ namespace ProjectContainerShip
|
|||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
{
|
{
|
||||||
_ship.EntityShip.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
_ship.EntityShip.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
|
||||||
}
|
}
|
||||||
DrawShip();
|
DrawShip();
|
||||||
}
|
}
|
||||||
@ -136,7 +136,6 @@ namespace ProjectContainerShip
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
labelDopColor.AllowDrop = false;
|
labelDopColor.AllowDrop = false;
|
||||||
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
{
|
{
|
||||||
e.Effect = DragDropEffects.Copy;
|
e.Effect = DragDropEffects.Copy;
|
||||||
@ -167,25 +166,5 @@ namespace ProjectContainerShip
|
|||||||
EventAddShip?.Invoke(_ship);
|
EventAddShip?.Invoke(_ship);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
private void checkBoxBodyKit_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
private void labelModifiedObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
private void numericUpDownSpeed_ValueChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
private void numericUpDownWeight_ValueChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
private void checkBoxCrane_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace ProjectContainerShip
|
|||||||
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DrawningShip? _drawingContainerShip;
|
private DrawningShip? _drawingContainerShip;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -162,6 +163,7 @@ namespace ProjectContainerShip
|
|||||||
}
|
}
|
||||||
private void FormContainerShip_Load(object sender, EventArgs e)
|
private void FormContainerShip_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ namespace ProjectContainerShip
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormContainerCollection());
|
Application.Run(new FormContainerCollection());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,18 @@ namespace ProjectContainerShip.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ship">Добавляемый контейнеровоз</param>
|
/// <param name="ship">Добавляемый контейнеровоз</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T ship)
|
public int Insert(T ship)
|
||||||
{
|
{
|
||||||
if (_places.Count >= _maxCount)
|
return Insert(ship, 0);
|
||||||
{
|
}
|
||||||
return false;
|
public int Insert(T ship, int position)
|
||||||
}
|
{
|
||||||
_places.Insert(0, ship);
|
if (position < 0 || position >= _maxCount)
|
||||||
return true;
|
return -1;
|
||||||
|
if (Count >= _maxCount)
|
||||||
|
return -1;
|
||||||
|
_places.Insert(position, ship);
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
@ -71,23 +75,15 @@ namespace ProjectContainerShip.Generics
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _places.Count)
|
if (position < 0 || position > _maxCount)
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _places.Count)
|
if (position < 0 || position > _maxCount)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
_places[position] = value;
|
||||||
if (_places.Count >= _maxCount)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_places.Insert(position, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user