ISEbd-12 Rozhkov.I.E. LabWork04 Simple #3
25
AiSD_Lab1/AiSD_Lab1.sln
Normal file
25
AiSD_Lab1/AiSD_Lab1.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.7.34031.279
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AiSD_Lab1", "AiSD_Lab1\AiSD_Lab1.csproj", "{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F9A02028-472E-4A74-938E-A366C44E2A55}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
10
AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj
Normal file
10
AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
30
AiSD_Lab1/AiSD_Lab1/Deque.cs
Normal file
30
AiSD_Lab1/AiSD_Lab1/Deque.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace AiSD_Lab1;
|
||||||
|
|
||||||
|
public class Deque<T> : Node<T>
|
||||||
|
{
|
||||||
|
Node<T>? head;
|
||||||
|
|
||||||
|
Node<T>? tail;
|
||||||
|
|
||||||
|
int count;
|
||||||
|
|
||||||
|
public AddFirst(T node)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddLast(T node)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemoveFirst()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemoveLast()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
11
AiSD_Lab1/AiSD_Lab1/Node.cs
Normal file
11
AiSD_Lab1/AiSD_Lab1/Node.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace AiSD_Lab1;
|
||||||
|
|
||||||
|
public class Node<T>
|
||||||
|
{
|
||||||
|
public Node(T data)
|
||||||
|
{
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
public T Data { get; set; }
|
||||||
|
public Node<T>? Next { get; set; }
|
||||||
|
}
|
1
AiSD_Lab1/AiSD_Lab1/Program.cs
Normal file
1
AiSD_Lab1/AiSD_Lab1/Program.cs
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
150
AiSD_Lab1/AiSD_Lab1/Sort.cs
Normal file
150
AiSD_Lab1/AiSD_Lab1/Sort.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AiSD_Lab1;
|
||||||
|
|
||||||
|
public class Sort
|
||||||
|
{
|
||||||
|
public int[] arr = new int[5];
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Заполняет массив рандомными значениями
|
||||||
|
/// </summary>
|
||||||
|
public void RandomArr()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < arr.Length; i++)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
arr[i] = random.Next(-100, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод массива в консоль
|
||||||
|
/// </summary>
|
||||||
|
public void PrintArr()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Array:");
|
||||||
|
for (int i = 0; i < arr.Length; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine("[" + i + "]: " + arr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проверяет, отсортирован ли массив по возрастанию
|
||||||
|
/// </summary>
|
||||||
|
public void IsSortedUp()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < arr.Length - 1; i++)
|
||||||
|
{
|
||||||
|
if (arr[i] > arr[i + 1])
|
||||||
|
{
|
||||||
|
Console.WriteLine("Массив НЕ отсортирован по возрастанию");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine("Массив отсортирован по возрастанию");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проверяет, отсортирован ли массив по убыванию
|
||||||
|
/// </summary>
|
||||||
|
public void IsSortedDown()
|
||||||
|
{
|
||||||
|
for (int i = 1; i < arr.Length; i++)
|
||||||
|
{
|
||||||
|
if (arr[i - 1] < arr[i])
|
||||||
|
{
|
||||||
|
Console.WriteLine("Массив НЕ отсортирован по убыванию");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine("Массив отсортирован по убыванию");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка выбором
|
||||||
|
/// </summary>
|
||||||
|
public void Choise()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < arr.Length; i++)
|
||||||
|
{
|
||||||
|
int min = i;
|
||||||
|
for(int j = i + 1; j < arr.Length; j++)
|
||||||
|
{
|
||||||
|
if (arr[j] < arr[min])
|
||||||
|
{
|
||||||
|
min = j;
|
||||||
|
}
|
||||||
|
int temp = arr[min];
|
||||||
|
arr[min] = arr[i];
|
||||||
|
arr[i] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Метод для слияния массивов
|
||||||
|
/// </summary>
|
||||||
|
public void Merge(int[] array, int lowIndex, int middleIndex, int highIndex)
|
||||||
|
{
|
||||||
|
// Индекс первого элемента левой части массива
|
||||||
|
int left = lowIndex;
|
||||||
|
// Индекс первого элемента правой части массива
|
||||||
|
int right = middleIndex + 1;
|
||||||
|
// Массив для слияния
|
||||||
|
int[] tempArray = new int[highIndex - lowIndex + 1];
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
// Проходимся по левой и правой половине массива
|
||||||
|
while ((left <= middleIndex) && (right <= highIndex))
|
||||||
|
{
|
||||||
|
if (array[left] < array[right])
|
||||||
|
{
|
||||||
|
tempArray[index] = array[left];
|
||||||
|
left++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempArray[index] = array[right];
|
||||||
|
right++;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = left; i <= middleIndex; i++)
|
||||||
|
{
|
||||||
|
tempArray[index] = array[i];
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = right; i <= highIndex; i++)
|
||||||
|
{
|
||||||
|
tempArray[index] = array[i];
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вносим в массив отсортированные элементы
|
||||||
|
for (int i = 0; i < tempArray.Length; i++)
|
||||||
|
{
|
||||||
|
array[lowIndex + i] = tempArray[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Сортировка слиянием
|
||||||
|
public int[] MergeSort(int[] array, int lowIndex, int highIndex)
|
||||||
|
{
|
||||||
|
if (lowIndex < highIndex)
|
||||||
|
{
|
||||||
|
// Индекс середины массива
|
||||||
|
int middleInd = (lowIndex + highIndex) / 2;
|
||||||
|
MergeSort(array, lowIndex, middleInd);
|
||||||
|
MergeSort(array, middleInd + 1, highIndex);
|
||||||
|
Merge(array, lowIndex, middleInd, highIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
namespace ProjectPlane.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
Massive = 1,
|
||||||
|
|
||||||
|
List = 2
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
using System.CodeDom.Compiler;
|
||||||
|
|
||||||
|
namespace ProjectPlane.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
private readonly List<T?> _collection;
|
||||||
|
|
||||||
|
private int _maxCount;
|
||||||
|
|
||||||
|
public int Count => _collection.Count;
|
||||||
|
|
||||||
|
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||||
|
|
||||||
|
public ListGenericObjects()
|
||||||
|
{
|
||||||
|
_collection = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_collection.Add(obj);
|
||||||
|
return _collection.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount || position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_collection.Insert(position, obj);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
T? obj = _collection[position];
|
||||||
|
_collection.RemoveAt(position);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
using ProjectPlane.Drawnings;
|
||||||
|
using ProjectPlane.CollectionGenericObjects;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ProjectPlane.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public class StorageCollection<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
private Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||||
|
|
||||||
|
public List<string> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public StorageCollection()
|
||||||
|
{
|
||||||
|
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление коллекции в хранилище
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <param name="collectionType">Тип коллекции</param>
|
||||||
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
|
{
|
||||||
|
if (name == null || _storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionType == CollectionType.Massive)
|
||||||
|
{
|
||||||
|
_storages.Add(name, new MassiveGenericObjects<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionType == CollectionType.List)
|
||||||
|
{
|
||||||
|
_storages.Add(name, new ListGenericObjects<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
if (name == null || !_storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_storages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObjects<T>? this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return _storages[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
172
ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs
generated
172
ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs
generated
@ -29,6 +29,15 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
|
ButtonCreateCompany = new Button();
|
||||||
|
panelStorage = new Panel();
|
||||||
|
radioButtonMassive = new RadioButton();
|
||||||
|
ButtonCollectionDel = new Button();
|
||||||
|
listBoxCollection = new ListBox();
|
||||||
|
ButtonCollectionAdd = new Button();
|
||||||
|
radioButtonList = new RadioButton();
|
||||||
|
textBoxCollectionName = new TextBox();
|
||||||
|
labelCollectionName = new Label();
|
||||||
ButtonRefresh = new Button();
|
ButtonRefresh = new Button();
|
||||||
ButtonGoToCheck = new Button();
|
ButtonGoToCheck = new Button();
|
||||||
ButtonDel = new Button();
|
ButtonDel = new Button();
|
||||||
@ -37,33 +46,125 @@
|
|||||||
ButtonAddShip = new Button();
|
ButtonAddShip = new Button();
|
||||||
ComboBoxSelectorCompany = new ComboBox();
|
ComboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
panelCompanyTools.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(ButtonRefresh);
|
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||||
groupBoxTools.Controls.Add(ButtonGoToCheck);
|
groupBoxTools.Controls.Add(ButtonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(ButtonDel);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
|
||||||
groupBoxTools.Controls.Add(ButtonAddCont);
|
|
||||||
groupBoxTools.Controls.Add(ButtonAddShip);
|
|
||||||
groupBoxTools.Controls.Add(ComboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(ComboBoxSelectorCompany);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(785, 0);
|
groupBoxTools.Location = new Point(785, 0);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(200, 678);
|
groupBoxTools.Size = new Size(200, 696);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// ButtonCreateCompany
|
||||||
|
//
|
||||||
|
ButtonCreateCompany.Location = new Point(6, 371);
|
||||||
|
ButtonCreateCompany.Name = "ButtonCreateCompany";
|
||||||
|
ButtonCreateCompany.Size = new Size(188, 23);
|
||||||
|
ButtonCreateCompany.TabIndex = 8;
|
||||||
|
ButtonCreateCompany.Text = "Создать компанию";
|
||||||
|
ButtonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
|
ButtonCreateCompany.Click += ButtonCreateCompany_Click;
|
||||||
|
//
|
||||||
|
// panelStorage
|
||||||
|
//
|
||||||
|
panelStorage.Controls.Add(radioButtonMassive);
|
||||||
|
panelStorage.Controls.Add(ButtonCollectionDel);
|
||||||
|
panelStorage.Controls.Add(listBoxCollection);
|
||||||
|
panelStorage.Controls.Add(ButtonCollectionAdd);
|
||||||
|
panelStorage.Controls.Add(radioButtonList);
|
||||||
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
|
panelStorage.Controls.Add(labelCollectionName);
|
||||||
|
panelStorage.Dock = DockStyle.Top;
|
||||||
|
panelStorage.Location = new Point(3, 19);
|
||||||
|
panelStorage.Name = "panelStorage";
|
||||||
|
panelStorage.Size = new Size(194, 317);
|
||||||
|
panelStorage.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// radioButtonMassive
|
||||||
|
//
|
||||||
|
radioButtonMassive.AutoSize = true;
|
||||||
|
radioButtonMassive.Location = new Point(3, 57);
|
||||||
|
radioButtonMassive.Name = "radioButtonMassive";
|
||||||
|
radioButtonMassive.Size = new Size(67, 19);
|
||||||
|
radioButtonMassive.TabIndex = 7;
|
||||||
|
radioButtonMassive.TabStop = true;
|
||||||
|
radioButtonMassive.Text = "Массив";
|
||||||
|
radioButtonMassive.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// ButtonCollectionDel
|
||||||
|
//
|
||||||
|
ButtonCollectionDel.Location = new Point(3, 274);
|
||||||
|
ButtonCollectionDel.Name = "ButtonCollectionDel";
|
||||||
|
ButtonCollectionDel.Size = new Size(188, 23);
|
||||||
|
ButtonCollectionDel.TabIndex = 6;
|
||||||
|
ButtonCollectionDel.Text = "Удалить коллекцию";
|
||||||
|
ButtonCollectionDel.UseVisualStyleBackColor = true;
|
||||||
|
ButtonCollectionDel.Click += ButtonCollectionDel_Click;
|
||||||
|
//
|
||||||
|
// listBoxCollection
|
||||||
|
//
|
||||||
|
listBoxCollection.FormattingEnabled = true;
|
||||||
|
listBoxCollection.ItemHeight = 15;
|
||||||
|
listBoxCollection.Location = new Point(3, 122);
|
||||||
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
|
listBoxCollection.Size = new Size(188, 124);
|
||||||
|
listBoxCollection.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// ButtonCollectionAdd
|
||||||
|
//
|
||||||
|
ButtonCollectionAdd.Location = new Point(3, 93);
|
||||||
|
ButtonCollectionAdd.Name = "ButtonCollectionAdd";
|
||||||
|
ButtonCollectionAdd.Size = new Size(188, 23);
|
||||||
|
ButtonCollectionAdd.TabIndex = 4;
|
||||||
|
ButtonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
|
ButtonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
|
ButtonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
||||||
|
//
|
||||||
|
// radioButtonList
|
||||||
|
//
|
||||||
|
radioButtonList.AutoSize = true;
|
||||||
|
radioButtonList.Location = new Point(95, 57);
|
||||||
|
radioButtonList.Name = "radioButtonList";
|
||||||
|
radioButtonList.Size = new Size(66, 19);
|
||||||
|
radioButtonList.TabIndex = 3;
|
||||||
|
radioButtonList.TabStop = true;
|
||||||
|
radioButtonList.Text = "Список";
|
||||||
|
radioButtonList.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// textBoxCollectionName
|
||||||
|
//
|
||||||
|
textBoxCollectionName.Location = new Point(3, 28);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(188, 23);
|
||||||
|
textBoxCollectionName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCollectionName
|
||||||
|
//
|
||||||
|
labelCollectionName.AutoSize = true;
|
||||||
|
labelCollectionName.Location = new Point(36, 10);
|
||||||
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
|
labelCollectionName.Size = new Size(125, 15);
|
||||||
|
labelCollectionName.TabIndex = 0;
|
||||||
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
|
//
|
||||||
// ButtonRefresh
|
// ButtonRefresh
|
||||||
//
|
//
|
||||||
ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
ButtonRefresh.Location = new Point(6, 425);
|
ButtonRefresh.Location = new Point(6, 230);
|
||||||
ButtonRefresh.Name = "ButtonRefresh";
|
ButtonRefresh.Name = "ButtonRefresh";
|
||||||
ButtonRefresh.Size = new Size(188, 39);
|
ButtonRefresh.Size = new Size(182, 39);
|
||||||
ButtonRefresh.TabIndex = 6;
|
ButtonRefresh.TabIndex = 6;
|
||||||
ButtonRefresh.Text = "Обновить";
|
ButtonRefresh.Text = "Обновить";
|
||||||
ButtonRefresh.UseVisualStyleBackColor = true;
|
ButtonRefresh.UseVisualStyleBackColor = true;
|
||||||
@ -72,9 +173,9 @@
|
|||||||
// ButtonGoToCheck
|
// ButtonGoToCheck
|
||||||
//
|
//
|
||||||
ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
ButtonGoToCheck.Location = new Point(6, 320);
|
ButtonGoToCheck.Location = new Point(6, 185);
|
||||||
ButtonGoToCheck.Name = "ButtonGoToCheck";
|
ButtonGoToCheck.Name = "ButtonGoToCheck";
|
||||||
ButtonGoToCheck.Size = new Size(188, 39);
|
ButtonGoToCheck.Size = new Size(182, 39);
|
||||||
ButtonGoToCheck.TabIndex = 5;
|
ButtonGoToCheck.TabIndex = 5;
|
||||||
ButtonGoToCheck.Text = "Передать на тесты";
|
ButtonGoToCheck.Text = "Передать на тесты";
|
||||||
ButtonGoToCheck.UseVisualStyleBackColor = true;
|
ButtonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -83,9 +184,9 @@
|
|||||||
// ButtonDel
|
// ButtonDel
|
||||||
//
|
//
|
||||||
ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
ButtonDel.Location = new Point(6, 237);
|
ButtonDel.Location = new Point(6, 140);
|
||||||
ButtonDel.Name = "ButtonDel";
|
ButtonDel.Name = "ButtonDel";
|
||||||
ButtonDel.Size = new Size(188, 39);
|
ButtonDel.Size = new Size(182, 39);
|
||||||
ButtonDel.TabIndex = 4;
|
ButtonDel.TabIndex = 4;
|
||||||
ButtonDel.Text = "Удплить контейнеровоз";
|
ButtonDel.Text = "Удплить контейнеровоз";
|
||||||
ButtonDel.UseVisualStyleBackColor = true;
|
ButtonDel.UseVisualStyleBackColor = true;
|
||||||
@ -93,7 +194,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
maskedTextBoxPosition.Location = new Point(6, 198);
|
maskedTextBoxPosition.Location = new Point(6, 111);
|
||||||
maskedTextBoxPosition.Mask = "00";
|
maskedTextBoxPosition.Mask = "00";
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
maskedTextBoxPosition.Size = new Size(188, 23);
|
maskedTextBoxPosition.Size = new Size(188, 23);
|
||||||
@ -103,9 +204,9 @@
|
|||||||
// ButtonAddCont
|
// ButtonAddCont
|
||||||
//
|
//
|
||||||
ButtonAddCont.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
ButtonAddCont.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
ButtonAddCont.Location = new Point(6, 138);
|
ButtonAddCont.Location = new Point(6, 66);
|
||||||
ButtonAddCont.Name = "ButtonAddCont";
|
ButtonAddCont.Name = "ButtonAddCont";
|
||||||
ButtonAddCont.Size = new Size(188, 39);
|
ButtonAddCont.Size = new Size(182, 39);
|
||||||
ButtonAddCont.TabIndex = 2;
|
ButtonAddCont.TabIndex = 2;
|
||||||
ButtonAddCont.Text = "Добавление контейнеровоза";
|
ButtonAddCont.Text = "Добавление контейнеровоза";
|
||||||
ButtonAddCont.UseVisualStyleBackColor = true;
|
ButtonAddCont.UseVisualStyleBackColor = true;
|
||||||
@ -114,9 +215,9 @@
|
|||||||
// ButtonAddShip
|
// ButtonAddShip
|
||||||
//
|
//
|
||||||
ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
ButtonAddShip.Location = new Point(6, 81);
|
ButtonAddShip.Location = new Point(6, 20);
|
||||||
ButtonAddShip.Name = "ButtonAddShip";
|
ButtonAddShip.Name = "ButtonAddShip";
|
||||||
ButtonAddShip.Size = new Size(188, 40);
|
ButtonAddShip.Size = new Size(182, 40);
|
||||||
ButtonAddShip.TabIndex = 1;
|
ButtonAddShip.TabIndex = 1;
|
||||||
ButtonAddShip.Text = "Добавление корабля";
|
ButtonAddShip.Text = "Добавление корабля";
|
||||||
ButtonAddShip.UseVisualStyleBackColor = true;
|
ButtonAddShip.UseVisualStyleBackColor = true;
|
||||||
@ -128,7 +229,7 @@
|
|||||||
ComboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
ComboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
ComboBoxSelectorCompany.FormattingEnabled = true;
|
ComboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
ComboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
ComboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
ComboBoxSelectorCompany.Location = new Point(6, 22);
|
ComboBoxSelectorCompany.Location = new Point(6, 342);
|
||||||
ComboBoxSelectorCompany.Name = "ComboBoxSelectorCompany";
|
ComboBoxSelectorCompany.Name = "ComboBoxSelectorCompany";
|
||||||
ComboBoxSelectorCompany.Size = new Size(188, 23);
|
ComboBoxSelectorCompany.Size = new Size(188, 23);
|
||||||
ComboBoxSelectorCompany.TabIndex = 0;
|
ComboBoxSelectorCompany.TabIndex = 0;
|
||||||
@ -139,22 +240,39 @@
|
|||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 0);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(785, 678);
|
pictureBox.Size = new Size(785, 696);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(ButtonAddShip);
|
||||||
|
panelCompanyTools.Controls.Add(ButtonAddCont);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
panelCompanyTools.Controls.Add(ButtonRefresh);
|
||||||
|
panelCompanyTools.Controls.Add(ButtonDel);
|
||||||
|
panelCompanyTools.Controls.Add(ButtonGoToCheck);
|
||||||
|
panelCompanyTools.Enabled = false;
|
||||||
|
panelCompanyTools.Location = new Point(3, 400);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(194, 274);
|
||||||
|
panelCompanyTools.TabIndex = 9;
|
||||||
|
//
|
||||||
// FormShipCollection
|
// FormShipCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(985, 678);
|
ClientSize = new Size(985, 696);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Name = "FormShipCollection";
|
Name = "FormShipCollection";
|
||||||
Text = "Коллекция кораблей";
|
Text = "Коллекция кораблей";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
panelStorage.ResumeLayout(false);
|
||||||
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
panelCompanyTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,5 +287,15 @@
|
|||||||
private Button ButtonDel;
|
private Button ButtonDel;
|
||||||
private Button ButtonGoToCheck;
|
private Button ButtonGoToCheck;
|
||||||
private Button ButtonRefresh;
|
private Button ButtonRefresh;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private Label labelCollectionName;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private Button ButtonCollectionAdd;
|
||||||
|
private Button ButtonCreateCompany;
|
||||||
|
private Button ButtonCollectionDel;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private Panel panelCompanyTools;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +1,23 @@
|
|||||||
|
using ProjectPlane.CollectionGenericObjects;
|
||||||
using ProjectPlane.CollectionGenericObjects;
|
|
||||||
using ProjectPlane.Drawnings;
|
using ProjectPlane.Drawnings;
|
||||||
|
|
||||||
namespace ProjectPlane;
|
namespace ProjectPlane;
|
||||||
|
|
||||||
public partial class FormShipCollection : Form
|
public partial class FormShipCollection : Form
|
||||||
{
|
{
|
||||||
|
private readonly StorageCollection<DrawningShip> _storageCollection;
|
||||||
|
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
public FormShipCollection()
|
public FormShipCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (ComboBoxSelectorCompany.Text)
|
panelCompanyTools.Enabled = false;
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new Marina(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningShip>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateObject(string type)
|
private void CreateObject(string type)
|
||||||
@ -138,4 +135,86 @@ public partial class FormShipCollection : Form
|
|||||||
|
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RadioButtonMassive_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RerfreshListBoxItems()
|
||||||
|
{
|
||||||
|
listBoxCollection.Items.Clear();
|
||||||
|
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||||
|
{
|
||||||
|
string? colName = _storageCollection.Keys?[i];
|
||||||
|
if (!string.IsNullOrEmpty(colName))
|
||||||
|
{
|
||||||
|
listBoxCollection.Items.Add(colName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ButtonCollectionAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionType collectionType = CollectionType.None;
|
||||||
|
if (radioButtonMassive.Checked)
|
||||||
|
{
|
||||||
|
collectionType = CollectionType.Massive;
|
||||||
|
}
|
||||||
|
else if (radioButtonList.Checked)
|
||||||
|
{
|
||||||
|
collectionType = CollectionType.List;
|
||||||
|
}
|
||||||
|
|
||||||
|
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCollectionDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Вы уверены, что хотите удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICollectionGenericObjects<DrawningShip>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (ComboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new Marina(pictureBox.Width, pictureBox.Height, collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
panelCompanyTools.Enabled = true;
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
Левые файлы