4 Commits
lab05 ... lab08

Author SHA1 Message Date
d8637d4a9d Небольшие правки 2024-05-20 13:29:41 +03:00
79db737a1e Лабораторная работа 8 2024-05-19 15:08:52 +03:00
c9945dab89 Лабораторная работа 7 2024-05-05 20:11:54 +03:00
45c7d06667 6 лабораторная 2024-04-22 18:28:12 +03:00
47 changed files with 1032 additions and 821 deletions

View File

@@ -1,25 +0,0 @@

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_Lab02", "AiSD Lab02\AiSD_Lab02.csproj", "{FA17B31D-8779-415E-B3A9-140812864D38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {268E47D2-9C2D-4863-BCE2-130796952BAF}
EndGlobalSection
EndGlobal

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FA17B31D-8779-415E-B3A9-140812864D38}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AiSD_Lab02</RootNamespace>
<AssemblyName>AiSD Lab02</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EntityItem.cs" />
<Compile Include="FibNums.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -1,7 +0,0 @@
namespace AiSD_Lab02;
public class EntityItem
{
public int Weight { get; set; }
public int Value { get; set; }
}

View File

@@ -1,64 +0,0 @@
namespace AiSD_Lab02;
public class FibNums
{
public int Fib(int num)
{
if (num < 2) return 1;
else return Fib(num - 1) + Fib(num - 2);
}
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;
}
}

View File

@@ -1,56 +0,0 @@
using System.Collections.Generic;
using System;
namespace AiSD_Lab02;
public class Program
{
public static void Main(string[] args)
{
List<EntityItem> items = new List<EntityItem>()
{
new EntityItem { Weight = 2, Value = 10 },
new EntityItem { Weight = 3, Value = 5 },
new EntityItem { Weight = 5, Value = 15 },
new EntityItem { Weight = 7, Value = 7 },
new EntityItem { Weight = 1, Value = 6 }
};
int capacity = 10;
for (int i = 0; i < items.Count - 1; i++)
{
for (int j = 0; j < items.Count - i - 1; j++)
{
double ratio1 = items[j].Value / (double)items[j].Weight;
double ratio2 = items[j + 1].Value / (double)items[j + 1].Weight;
if (ratio1 < ratio2)
{
EntityItem temp = items[j];
items[j] = items[j + 1];
items[j + 1] = temp;
}
}
}
int totalValue = 0;
int totalWeight = 0;
foreach (EntityItem item in items)
{
if (totalWeight + item.Weight <= capacity)
{
totalValue += item.Value;
totalWeight += item.Weight;
Console.WriteLine($"Предмет: вес={item.Weight}, значение={item.Value}");
}
}
Console.WriteLine($"Суммарное значение: {totalValue}");
Console.WriteLine($"Суммарный вес: {totalWeight}");
FibNums fibNums = new FibNums();
Console.WriteLine(fibNums.Fib(5));
}
}

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные с этой сборкой.
[assembly: AssemblyTitle("AiSD Lab02")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AiSD Lab02")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
[assembly: Guid("fa17b31d-8779-415e-b3a9-140812864d38")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,25 +0,0 @@

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 Lab02", "AiSD Lab02\AiSD Lab02.csproj", "{FA17B31D-8779-415E-B3A9-140812864D38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {268E47D2-9C2D-4863-BCE2-130796952BAF}
EndGlobalSection
EndGlobal

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FA17B31D-8779-415E-B3A9-140812864D38}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AiSD_Lab02</RootNamespace>
<AssemblyName>AiSD Lab02</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EntityItem.cs" />
<Compile Include="KnapsackGreedy.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
public class EntityItem
{
public int Weight { get; set; }
public int Value { get; set; }
public EntityItem(int weight, int value)
{
Weight = weight;
Value = value;
}
}

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AiSD_Lab02
{
internal class FibNums
{
}
}

View File

@@ -1,28 +0,0 @@
using System.Collections.Generic;
using System;
public class Program
{
public static void Main(string[] args)
{
List<EntityItem> items = new List<EntityItem>()
{
new EntityItem(2, 10),
new EntityItem(3, 5),
new EntityItem(5, 15),
new EntityItem(7, 7),
new EntityItem(1, 6)
};
int capacity = 10;
List<EntityItem> result = FillKnapsack(items, capacity);
Console.WriteLine("Предмет в рюкзаке:");
foreach (EntityItem item in result)
{
Console.WriteLine($"Вес: {item.Weight}, Стоимость: {item.Value}");
}
}
}
}

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные с этой сборкой.
[assembly: AssemblyTitle("AiSD Lab02")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AiSD Lab02")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
[assembly: Guid("fa17b31d-8779-415e-b3a9-140812864d38")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,25 +0,0 @@

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

View File

@@ -1,10 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -1,67 +0,0 @@
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace AiSD_Lab1;
public class Deque
{
Landmark first;
public Deque(string data)
{
Landmark newEl = new Landmark(data);
first = newEl;
}
public void AddFirst(string data)
{
Landmark newEl = new Landmark(data);
newEl.next = first;
first = newEl;
}
public Landmark RemoveFirst()
{
Landmark delEl = first;
first = delEl.next;
delEl.next = null;
return delEl;
}
public void RemoveLast()
{
Landmark delEl = first;
while (delEl.next.next != null)
{
delEl = delEl.next;
}
delEl.next = null;
}
public void AddLast(string data)
{
Landmark newEl = first;
while (newEl.next != null)
{
newEl = newEl.next;
}
newEl.next = new Landmark(data);
}
public string GetAll()
{
string Deque = "";
Landmark curr = first;
while (curr.next != null)
{
Deque += " " + curr.data;
curr = curr.next;
}
Deque += " " + curr.data;
return Deque;
}
}

View File

@@ -1,12 +0,0 @@
namespace AiSD_Lab1;
public class Landmark
{
public String data;
public Landmark next;
public Landmark(String _data)
{
data = _data;
}
}

View File

@@ -1,27 +0,0 @@
using System;
namespace AiSD_Lab1;
public class Program
{
public static void Main(String[] args)
{
Console.WriteLine("Сортировка слиянием");
Sort sort = new Sort();
sort.RandomArr();
sort.PrintArr();
sort.MergeSort(sort.arr, 0, sort.arr.Length - 1);
sort.PrintArr();
Deque deque = new Deque("Статуя свободы");
Console.WriteLine(deque.GetAll());
deque.AddFirst("Успенский собор");
Console.WriteLine(deque.GetAll());
deque.AddLast("Эйфелева башня");
Console.WriteLine(deque.GetAll());
deque.RemoveLast();
Console.WriteLine(deque.GetAll());
deque.RemoveFirst();
Console.WriteLine(deque.GetAll());
}
}

View File

@@ -1,150 +0,0 @@
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;
}
}

View File

@@ -1,4 +1,5 @@
using ProjectPlane.Drawnings;
using ProjectPlane.Exceptions;
namespace ProjectPlane.CollectionGenericObjects;
@@ -21,12 +22,23 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
_collection.MaxCount = GetMaxCount;
}
public static int operator +(AbstractCompany company, DrawningShip ship)
{
return company._collection.Insert(ship);
try
{
return company._collection.Insert(ship, 0, new DrawningShipEqutables());
}
catch (ObjectAlreadyInCollectionException)
{
return -1;
}
catch (CollectionOverflowException)
{
return -1;
}
}
public static DrawningShip? operator -(AbstractCompany company, int position)
@@ -37,7 +49,14 @@ public abstract class AbstractCompany
public DrawningShip? GetRandomObject()
{
Random rnd = new();
return _collection?.Get(rnd.Next(GetMaxCount));
try
{
return _collection?.Get(rnd.Next(GetMaxCount));
}
catch (ObjectNotFoundException)
{
return null;
}
}
public Bitmap? Show()
@@ -45,11 +64,19 @@ public abstract class AbstractCompany
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
Graphics graphics = Graphics.FromImage(bitmap);
DrawBackgound(graphics);
SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
DrawningShip? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
try
{
DrawningShip? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}
catch (ObjectNotFoundException)
{
continue;
}
}
return bitmap;
}
@@ -57,4 +84,6 @@ public abstract class AbstractCompany
protected abstract void DrawBackgound(Graphics g);
protected abstract void SetObjectsPosition();
public void Sort(IComparer<DrawningShip?> comparer) => _collection?.CollectionSort(comparer);
}

View File

@@ -0,0 +1,77 @@
namespace ProjectPlane.CollectionGenericObjects;
/// <summary>
/// Класс, хранящиий информацию по коллекции
/// </summary>
public class CollectionInfo : IEquatable<CollectionInfo>
{
/// <summary>
/// Название
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Тип
/// </summary>
public CollectionType CollectionType { get; private set; }
/// <summary>
/// Описание
/// </summary>
public string Description { get; private set; }
/// <summary>
/// Разделитель для записи информации по объекту в файл
/// </summary>
private static readonly string _separator = "-";
/// <summary>
/// Конструктор
/// </summary>
/// <param name="name">Название</param>
/// <param name="collectionType">Тип</param>
/// <param name="description">Описание</param>
public CollectionInfo(string name, CollectionType collectionType, string description)
{
Name = name;
CollectionType = collectionType;
Description = description;
}
/// <summary>
/// Создание объекта из строки
/// </summary>
/// <param name="data">Строка</param>
/// <returns>Объект или null</returns>
public static CollectionInfo? GetCollectionInfo(string data)
{
string[] strs = data.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (strs.Length < 1 || strs.Length > 3)
{
return null;
}
return new CollectionInfo(strs[0], (CollectionType)Enum.Parse(typeof(CollectionType), strs[1]),
strs.Length > 2 ? strs[2] : string.Empty);
}
public override string ToString()
{
return Name + _separator + CollectionType + _separator + Description;
}
public bool Equals(CollectionInfo? other)
{
return Name == other?.Name;
}
public override bool Equals(object? obj)
{
return Equals(obj as CollectionInfo);
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
}

View File

@@ -1,4 +1,4 @@

using ProjectPlane.Drawnings;
namespace ProjectPlane.CollectionGenericObjects;
public interface ICollectionGenericObjects<T>
@@ -6,14 +6,20 @@ public interface ICollectionGenericObjects<T>
{
int Count { get; }
int SetMaxCount { set; }
int MaxCount { get; set; }
int Insert(T obj);
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
int Insert(T obj, int position);
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
T? Remove(int position);
T? Get(int position);
CollectionType GetCollectionType { get; }
IEnumerable<T?> GetItems();
void CollectionSort(IComparer<T?> comparer);
}

View File

@@ -1,4 +1,5 @@
using System.CodeDom.Compiler;
using ProjectPlane.Exceptions;
using ProjectPlane.Drawnings;
namespace ProjectPlane.CollectionGenericObjects;
@@ -11,7 +12,9 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public int Count => _collection.Count;
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
public int MaxCount { get { return _collection.Count; } set { if (value > 0) { _maxCount = value; } } }
public CollectionType GetCollectionType => CollectionType.List;
public ListGenericObjects()
{
@@ -20,30 +23,52 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public T? Get(int position)
{
// TODO выброс ошибки, если выход за границы списка
if (position < 0 || position >= Count)
{
return null;
throw new PositionOutOfCollectionException(position);
}
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
// TODO выброс ошибки, если переполнение
if (comparer != null)
{
if (_collection.Contains(obj, comparer))
{
throw new ObjectAlreadyInCollectionException();
}
}
if (Count == _maxCount)
{
return -1;
throw new CollectionOverflowException(Count);
}
_collection.Add(obj);
return _collection.Count;
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (Count == _maxCount || position < 0 || position > Count)
// TODO выброс ошибки, если выход за границы списка
// TODO выброс ошибки, если переполнение
if (comparer != null)
{
return -1;
if (_collection.Contains(obj, comparer))
{
throw new ObjectAlreadyInCollectionException();
}
}
if (position < 0 || position > Count)
{
throw new PositionOutOfCollectionException(position);
}
if (Count == _maxCount)
{
throw new CollectionOverflowException(Count);
}
_collection.Insert(position, obj);
@@ -52,14 +77,28 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public T? Remove(int position)
{
// TODO выброс ошибки, если выход за границы списка
if (position < 0 || position > Count)
{
return null;
throw new PositionOutOfCollectionException(position);
}
T? obj = _collection[position];
_collection.RemoveAt(position);
return obj;
}
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < Count; ++i)
{
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
// TODO
_collection.Sort(comparer);
}
}

View File

@@ -1,4 +1,5 @@
using ProjectPlane.Drawnings;
using ProjectPlane.Exceptions;
namespace ProjectPlane.CollectionGenericObjects;
@@ -36,22 +37,30 @@ public class Marina : AbstractCompany
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection?.Get(i) != null)
try
{
int x = _placeSizeWidth * n;
int y = (10 + _placeSizeHeight * (_pictureHeight / _placeSizeHeight - 1)) - _placeSizeHeight * m;
if (_collection?.Get(i) != null)
{
int x = _placeSizeWidth * n;
int y = (10 + _placeSizeHeight * (_pictureHeight / _placeSizeHeight - 1)) - _placeSizeHeight * m;
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(x, y);
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(x, y);
}
if (n > 0)
n--;
else
{
n = _pictureWidth / _placeSizeWidth;
m++;
}
}
if (n > 0)
n--;
else
catch(ObjectNotFoundException)
{
n = _pictureWidth / _placeSizeWidth;
m++;
break;
}
}
}
}

View File

@@ -1,12 +1,19 @@
namespace ProjectPlane.CollectionGenericObjects;
using ProjectPlane.Exceptions;
using ProjectPlane.Drawnings;
namespace ProjectPlane.CollectionGenericObjects;
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
private T?[] _collection;
public int Count => _collection.Length;
public int SetMaxCount
public int MaxCount
{
get
{
return _collection.Length;
}
set
{
if (value > 0)
@@ -23,21 +30,44 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
}
}
public CollectionType GetCollectionType => CollectionType.Massive;
public MassiveGenericObjects()
{
_collection = Array.Empty<T?>();
}
public T? Get(int position)
{
if (position < 0 || position > Count)
// TODO выброс ошибки, если выход за границы массива
// TODO выброс ошибки, если объект пустой
if (position < 0 || position >= Count)
{
return null;
throw new PositionOutOfCollectionException(position);
}
if (_collection[position] == null)
{
throw new ObjectNotFoundException(position);
}
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
// TODO выброс ошибки, если переполнение
if (comparer != null)
{
foreach (T? item in _collection)
{
if ((comparer as IEqualityComparer<DrawningShip>).Equals(obj as DrawningShip, item as DrawningShip))
{
throw new ObjectAlreadyInCollectionException();
}
}
}
for (int i = 0; i < Count; i++)
{
if (_collection[i] == null)
@@ -46,13 +76,28 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return i;
}
}
return -1;
throw new CollectionOverflowException(Count);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (position < 0 || position > Count)
// TODO выброс ошибки, если выход за границы массива
// TODO выброс ошибки, если переполнение
if (comparer != null)
{
return -1;
foreach (T? item in _collection)
{
if ((comparer as IEqualityComparer<DrawningShip>).Equals(obj as DrawningShip, item as DrawningShip))
{
throw new ObjectAlreadyInCollectionException();
}
}
}
if (position < 0 || position >= Count)
{
throw new PositionOutOfCollectionException(position);
}
if (_collection[position] == null)
@@ -66,7 +111,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
if (_collection[i] == null)
{
_collection[i] = obj;
return position;
return i;
}
}
@@ -75,17 +120,24 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
if (_collection[i] == null)
{
_collection[i] = obj;
return position;
return i;
}
}
return -1;
throw new CollectionOverflowException(Count);
}
public T? Remove(int position)
{
if (position < 0 || position > Count || _collection[position] == null)
// TODO выброс ошибки, если выход за границы массива
// TODO выброс ошибки, если объект пустой
if (position < 0 || position >= Count)
{
return null;
throw new PositionOutOfCollectionException(position);
}
if (_collection[position] == null)
{
throw new ObjectNotFoundException(position);
}
T? obj = _collection[position];
@@ -93,4 +145,17 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return obj;
}
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < _collection.Length; ++i)
{
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
// TODO
Array.Sort(_collection, comparer);
}
}

View File

@@ -1,22 +1,28 @@
using ProjectPlane.Drawnings;
using ProjectPlane.CollectionGenericObjects;
using System.Xml.Linq;
using ProjectPlane.Exceptions;
namespace ProjectPlane.CollectionGenericObjects;
public class StorageCollection<T>
where T : class
where T : DrawningShip
{
private Dictionary<string, ICollectionGenericObjects<T>> _storages;
private readonly string _collectionKey = "CollectionsStorage";
private readonly string _separatorForKeyValue = "|";
private readonly string _separatorItems = ";";
public List<string> Keys => _storages.Keys.ToList();
private Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
public List<CollectionInfo> Keys => _storages.Keys.ToList();
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
@@ -24,21 +30,21 @@ public class StorageCollection<T>
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">Тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
public void AddCollection(CollectionInfo info)
{
if (name == null || _storages.ContainsKey(name))
if (info == null || _storages.ContainsKey(info))
{
return;
}
if (collectionType == CollectionType.Massive)
if (info.CollectionType == CollectionType.Massive)
{
_storages.Add(name, new MassiveGenericObjects<T>());
_storages.Add(info, new MassiveGenericObjects<T>());
}
if (collectionType == CollectionType.List)
if (info.CollectionType == CollectionType.List)
{
_storages.Add(name, new ListGenericObjects<T>());
_storages.Add(info, new ListGenericObjects<T>());
}
}
@@ -46,31 +52,143 @@ public class StorageCollection<T>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
public void DelCollection(CollectionInfo info)
{
if (name == null || !_storages.ContainsKey(name))
if (info == null || !_storages.ContainsKey(info))
{
return;
}
_storages.Remove(name);
_storages.Remove(info);
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
public void SaveData(string filename)
{
if (_storages.Count == 0)
{
throw new NullReferenceException("В хранилище отсутствуют коллекции для сохранения");
}
if (File.Exists(filename))
{
File.Delete(filename);
}
using (StreamWriter sw = new StreamWriter(filename))
{
sw.Write(_collectionKey);
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
sw.Write(Environment.NewLine);
// не сохраняем пустые коллекции
if (value.Value.Count == 0)
{
continue;
}
sw.Write(value.Key);
sw.Write(_separatorForKeyValue);
sw.Write(value.Value.MaxCount);
sw.Write(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
{
continue;
}
sw.Write(data);
sw.Write(_separatorItems);
}
}
}
}
public void LoadData(string filename)
{
if (!File.Exists(filename))
{
throw new FileNotFoundException("Файл не существует");
}
using (StreamReader sr = new(filename))
{
string line = sr.ReadLine();
if (line == null || line.Length == 0)
{
throw new FileFormatException("В файле нет данных");
}
if (!line.Equals(_collectionKey))
{
throw new FileFormatException("В файле неверные данные");
}
_storages.Clear();
while ((line = sr.ReadLine()) != null)
{
string[] record = line.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 3)
{
continue;
}
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
throw new Exception("Не удалось создать коллекцию");
collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
if (elem?.CreateDrawningShip() is T ship)
{
try
{
if (collection.Insert(ship, new DrawningShipEqutables()) == -1)
{
throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]);
}
}
catch (CollectionOverflowException ex)
{
throw new OverflowException("Коллекция переполнена", ex);
}
catch (ObjectAlreadyInCollectionException ex)
{
throw new InvalidOperationException("Объект уже присутствует в коллекции", ex);
}
}
}
_storages.Add(collectionInfo, collection);
}
}
}
public ICollectionGenericObjects<T>? this[CollectionInfo info]
{
get
{
if (_storages.ContainsKey(name))
if (_storages.ContainsKey(info))
{
return _storages[name];
return _storages[info];
}
return null;
}
}
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
{
return collectionType switch
{
CollectionType.Massive => new MassiveGenericObjects<T>(),
CollectionType.List => new ListGenericObjects<T>(),
_ => null,
};
}
}

View File

@@ -0,0 +1,42 @@
using ProjectPlane.Entities;
namespace ProjectPlane.Drawnings;
/// <summary>
/// Сравнение по цвету, скорости, весу
/// </summary>
public class DrawningShipCompareByColor : IComparer<DrawningShip?>
{
public int Compare(DrawningShip? x, DrawningShip? y)
{
// TODO прописать логику сравения по цветам, скорости, весу
if (x == null || x.EntityShip == null)
{
return 1;
}
if (y == null || y.EntityShip == null)
{
return -1;
}
var bodyColorCompare = y.EntityShip.ShipColor.Name.CompareTo(x.EntityShip.ShipColor.Name);
if (bodyColorCompare != 0)
{
return bodyColorCompare;
}
if (x is DrawCont && y is DrawCont)
{
var additionalColorCompare = (y.EntityShip as EntityContainer).ContainerColor.Name.CompareTo(
(x.EntityShip as EntityContainer).ContainerColor.Name);
if (additionalColorCompare != 0)
{
return additionalColorCompare;
}
}
var speedCompare = y.EntityShip.Speed.CompareTo(x.EntityShip.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return y.EntityShip.Weight.CompareTo(x.EntityShip.Weight);
}
}

View File

@@ -0,0 +1,29 @@
namespace ProjectPlane.Drawnings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class DrawningShipCompareByType : IComparer<DrawningShip?>
{
public int Compare(DrawningShip? x, DrawningShip? y)
{
if (x == null || x.EntityShip == null)
{
return 1;
}
if (y == null || y.EntityShip == null)
{
return -1;
}
if (x.GetType().Name != y.GetType().Name)
{
return y.GetType().Name.CompareTo(x.GetType().Name);
}
var speedCompare = y.EntityShip.Speed.CompareTo(x.EntityShip.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return y.EntityShip.Weight.CompareTo(x.EntityShip.Weight);
}
}

View File

@@ -0,0 +1,63 @@
using ProjectPlane.Entities;
using System.Diagnostics.CodeAnalysis;
namespace ProjectPlane.Drawnings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawningShipEqutables : IEqualityComparer<DrawningShip?>
{
public bool Equals(DrawningShip? x, DrawningShip? y)
{
if (x == null || x.EntityShip == null)
{
return false;
}
if (y == null || y.EntityShip == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityShip.Speed != y.EntityShip.Speed)
{
return false;
}
if (x.EntityShip.Weight != y.EntityShip.Weight)
{
return false;
}
if (x.EntityShip.ShipColor != y.EntityShip.ShipColor)
{
return false;
}
if (x is DrawCont && y is DrawCont)
{
// TODO доделать логику сравнения дополнительных параметров
if ((x.EntityShip as EntityContainer)?.ContainerColor !=
(y.EntityShip as EntityContainer)?.ContainerColor)
{
return false;
}
if ((x.EntityShip as EntityContainer)?.Container !=
(y.EntityShip as EntityContainer)?.Container)
{
return false;
}
if ((x.EntityShip as EntityContainer)?.Crane !=
(y.EntityShip as EntityContainer)?.Crane)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningShip? obj)
{
return obj.GetHashCode();
}
}

View File

@@ -0,0 +1,36 @@
using ProjectPlane.Entities;
using ProjectPlane.Drawnings;
namespace ProjectPlane.Drawnings;
public static class ExtentionDrawningShip
{
private static readonly string _separatorForObject = ":";
public static DrawningShip? CreateDrawningShip(this string info)
{
string[] strs = info.Split(_separatorForObject);
EntityShip? ship = EntityContainer.CreateEntityContainer(strs);
if (ship != null)
{
return new DrawCont(ship.Speed, ship.Weight, ship.ShipColor, (ship as EntityContainer).ContainerColor, (ship as EntityContainer).Container, (ship as EntityContainer).Crane);
}
ship = EntityShip.CreateEntityShip(strs);
if (ship != null)
{
return new DrawningShip(ship.Speed, ship.Weight, ship.ShipColor);
}
return null;
}
public static string GetDataForSave(this DrawningShip drawningShip)
{
string[]? array = drawningShip?.EntityShip?.GetStringRepresentation();
if (array == null)
{
return string.Empty;
}
return string.Join(_separatorForObject, array);
}
}

View File

@@ -30,4 +30,20 @@ public class EntityContainer : EntityShip
{
ContainerColor = newColor;
}
public override string[] GetStringRepresentation()
{
return new[] { nameof(EntityContainer), Speed.ToString(), Weight.ToString(), ShipColor.Name, ContainerColor.Name, Container.ToString(), Crane.ToString()};
}
public static EntityContainer? CreateEntityContainer(string[] strs)
{
if (strs.Length != 7 || strs[0] != nameof(EntityContainer))
{
return null;
}
return new EntityContainer(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
}
}

View File

@@ -26,4 +26,20 @@ public class EntityShip
{
ShipColor = newColor;
}
public virtual string[] GetStringRepresentation()
{
return new[] { nameof(EntityShip), Speed.ToString(), Weight.ToString(), ShipColor.Name };
}
public static EntityShip? CreateEntityShip(string[] strs)
{
if (strs.Length != 4 || strs[0] != nameof(EntityShip))
{
return null;
}
return new EntityShip(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
}
}

View File

@@ -0,0 +1,15 @@
using System.Runtime.Serialization;
namespace ProjectPlane.Exceptions;
/// <summary>
/// Класс, описывающий ошибку переполнения коллекции
/// </summary>
[Serializable]
internal class CollectionOverflowException : ApplicationException
{
public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { }
public CollectionOverflowException() : base() { }
public CollectionOverflowException(string message) : base(message) { }
public CollectionOverflowException(string message, Exception exception) : base(message, exception) { }
protected CollectionOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@@ -0,0 +1,20 @@
using System.Runtime.Serialization;
namespace ProjectPlane.Exceptions;
/// <summary>
/// Класс, описывающий ошибку переполнения коллекции
/// </summary>
[Serializable]
internal class ObjectAlreadyInCollectionException : ApplicationException
{
public ObjectAlreadyInCollectionException(int index) : base("Такой объект уже присутствует в коллекции. Позиция " + index) { }
public ObjectAlreadyInCollectionException() : base() { }
public ObjectAlreadyInCollectionException(string message) : base(message) { }
public ObjectAlreadyInCollectionException(string message, Exception exception) : base(message, exception) { }
protected ObjectAlreadyInCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@@ -0,0 +1,15 @@
using System.Runtime.Serialization;
namespace ProjectPlane.Exceptions;
/// <summary>
/// Класс, описывающий ошибку, что по указанной позиции нет элемента
/// </summary>
[Serializable]
internal class ObjectNotFoundException : ApplicationException
{
public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { }
public ObjectNotFoundException() : base() { }
public ObjectNotFoundException(string message) : base(message) { }
public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { }
protected ObjectNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@@ -0,0 +1,15 @@
using System.Runtime.Serialization;
namespace ProjectPlane.Exceptions;
/// <summary>
/// Класс, описывающий ошибку выхода за границы коллекции
/// </summary>
[Serializable]
internal class PositionOutOfCollectionException : ApplicationException
{
public PositionOutOfCollectionException(int i) : base("Выход за границы коллекции.Позиция " + i) { }
public PositionOutOfCollectionException() : base() { }
public PositionOutOfCollectionException(string message) : base(message) { }
public PositionOutOfCollectionException(string message, Exception exception) : base(message, exception) { }
protected PositionOutOfCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@@ -30,6 +30,8 @@
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
ButtonAddShip = new Button();
maskedTextBoxPosition = new MaskedTextBox();
ButtonRefresh = new Button();
@@ -46,10 +48,17 @@
labelCollectionName = new Label();
ComboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
menuStrip = new MenuStrip();
файлToolStripMenuItem = new ToolStripMenuItem();
saveToolStripMenuItem = new ToolStripMenuItem();
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@@ -59,15 +68,17 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(ComboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(785, 0);
groupBoxTools.Location = new Point(853, 24);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(200, 696);
groupBoxTools.Size = new Size(200, 692);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(ButtonAddShip);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(ButtonRefresh);
@@ -76,13 +87,33 @@
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 400);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(194, 274);
panelCompanyTools.Size = new Size(194, 292);
panelCompanyTools.TabIndex = 9;
//
// buttonSortByColor
//
buttonSortByColor.Location = new Point(6, 252);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(182, 34);
buttonSortByColor.TabIndex = 8;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += ButtonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Location = new Point(6, 213);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(182, 34);
buttonSortByType.TabIndex = 7;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += ButtonSortByType_Click;
//
// ButtonAddShip
//
ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonAddShip.Location = new Point(6, 20);
ButtonAddShip.Location = new Point(6, 3);
ButtonAddShip.Name = "ButtonAddShip";
ButtonAddShip.Size = new Size(182, 40);
ButtonAddShip.TabIndex = 1;
@@ -92,7 +123,7 @@
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(6, 111);
maskedTextBoxPosition.Location = new Point(6, 49);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(188, 23);
@@ -102,7 +133,7 @@
// ButtonRefresh
//
ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonRefresh.Location = new Point(6, 230);
ButtonRefresh.Location = new Point(6, 168);
ButtonRefresh.Name = "ButtonRefresh";
ButtonRefresh.Size = new Size(182, 39);
ButtonRefresh.TabIndex = 6;
@@ -113,18 +144,18 @@
// ButtonDel
//
ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonDel.Location = new Point(6, 140);
ButtonDel.Location = new Point(6, 78);
ButtonDel.Name = "ButtonDel";
ButtonDel.Size = new Size(182, 39);
ButtonDel.TabIndex = 4;
ButtonDel.Text = "Удплить контейнеровоз";
ButtonDel.Text = "Удалить контейнеровоз";
ButtonDel.UseVisualStyleBackColor = true;
ButtonDel.Click += ButtonDel_Click;
//
// ButtonGoToCheck
//
ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonGoToCheck.Location = new Point(6, 185);
ButtonGoToCheck.Location = new Point(6, 123);
ButtonGoToCheck.Name = "ButtonGoToCheck";
ButtonGoToCheck.Size = new Size(182, 39);
ButtonGoToCheck.TabIndex = 5;
@@ -239,19 +270,53 @@
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(785, 696);
pictureBox.Size = new Size(853, 692);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// menuStrip
//
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1053, 24);
menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip";
//
// файлToolStripMenuItem
//
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(48, 20);
файлToolStripMenuItem.Text = "Файл";
//
// saveToolStripMenuItem
//
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(181, 22);
saveToolStripMenuItem.Text = "Сохранение";
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
//
// loadToolStripMenuItem
//
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(181, 22);
loadToolStripMenuItem.Text = "Загрузка";
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
//
// FormShipCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(985, 696);
ClientSize = new Size(1053, 716);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormShipCollection";
Text = "Коллекция кораблей";
groupBoxTools.ResumeLayout(false);
@@ -260,7 +325,10 @@
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
@@ -283,5 +351,13 @@
private ListBox listBoxCollection;
private RadioButton radioButtonMassive;
private Panel panelCompanyTools;
private MenuStrip menuStrip;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem saveToolStripMenuItem;
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
}
}

View File

@@ -1,5 +1,7 @@
using ProjectPlane.CollectionGenericObjects;
using ProjectPlane.Drawnings;
using ProjectPlane.Exceptions;
using Microsoft.Extensions.Logging;
namespace ProjectPlane;
@@ -9,10 +11,13 @@ public partial class FormShipCollection : Form
private AbstractCompany? _company = null;
public FormShipCollection()
private readonly ILogger _logger;
public FormShipCollection(ILogger<FormShipCollection> logger)
{
InitializeComponent();
_storageCollection = new();
_logger = logger;
}
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
@@ -20,7 +25,7 @@ public partial class FormShipCollection : Form
panelCompanyTools.Enabled = false;
}
private void ButtonAddShip_Click(object sender, EventArgs e)
private void ButtonAddShip_Click(object sender, EventArgs e)
{
FormShipConfig form = new();
form.AddEvent(SetShip);
@@ -33,18 +38,36 @@ public partial class FormShipCollection : Form
{
return;
}
if (_company + ship != -1)
try
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
if (_company + ship != -1)
{
MessageBox.Show("Объект добавлен");
_logger.LogInformation($"Добавлен объект {ship.GetDataForSave()}");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
else
catch (CollectionOverflowException ex)
{
MessageBox.Show("Не удалось добавить объект");
MessageBox.Show(ex.Message);
_logger.LogWarning($"Ошибка: {ex.Message}");
}
catch (ArgumentException ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning($"Ошибка: {ex.Message}");
}
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonDel_Click(object sender, EventArgs e)
{
@@ -58,15 +81,25 @@ public partial class FormShipCollection : Form
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_company - pos != null)
try
{
MessageBox.Show("Объект удалён");
pictureBox.Image = _company.Show();
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_company - pos != null)
{
MessageBox.Show("Объект удален");
_logger.LogInformation($"Удален объект по позиции {pos}");
pictureBox.Image = _company.Show();
}
}
else
catch (ObjectNotFoundException ex)
{
MessageBox.Show("Не удалось удалить объект");
MessageBox.Show(ex.Message);
_logger.LogError($"Ошибка: {ex.Message}");
}
catch (PositionOutOfCollectionException ex)
{
MessageBox.Show(ex.Message);
_logger.LogError($"Ошибка: {ex.Message}");
}
}
@@ -102,6 +135,11 @@ public partial class FormShipCollection : Form
}
/// <summary>
/// перерисовка коллекции
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
@@ -117,7 +155,7 @@ public partial class FormShipCollection : Form
listBoxCollection.Items.Clear();
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
{
string? colName = _storageCollection.Keys?[i];
string? colName = _storageCollection.Keys?[i].Name;
if (!string.IsNullOrEmpty(colName))
{
listBoxCollection.Items.Add(colName);
@@ -130,6 +168,7 @@ public partial class FormShipCollection : Form
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
{
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка: Заполнены не все данные для добавления коллекции");
return;
}
@@ -142,8 +181,10 @@ public partial class FormShipCollection : Form
{
collectionType = CollectionType.List;
}
CollectionInfo collectionInfo = new CollectionInfo(textBoxCollectionName.Text, collectionType, string.Empty);
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
_storageCollection.AddCollection(collectionInfo);
_logger.LogInformation($"Добавлена коллекция: {textBoxCollectionName.Text} типа: {collectionType}");
RerfreshListBoxItems();
}
@@ -159,7 +200,10 @@ public partial class FormShipCollection : Form
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
_storageCollection.DelCollection(collectionInfo);
_logger.LogInformation($"Удалена коллекция: {listBoxCollection.SelectedItem.ToString()}");
RerfreshListBoxItems();
}
@@ -171,7 +215,8 @@ public partial class FormShipCollection : Form
return;
}
ICollectionGenericObjects<DrawningShip>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
ICollectionGenericObjects<DrawningShip>? collection = _storageCollection[collectionInfo];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
@@ -187,4 +232,61 @@ public partial class FormShipCollection : Form
panelCompanyTools.Enabled = true;
RerfreshListBoxItems();
}
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_storageCollection.SaveData(saveFileDialog.FileName);
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
}
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_storageCollection.LoadData(openFileDialog.FileName);
MessageBox.Show("Загрузка прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
RerfreshListBoxItems();
_logger.LogInformation("Загрузка из фала: {filename}", openFileDialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
}
private void ButtonSortByType_Click(object sender, EventArgs e)
{
CompareShips(new DrawningShipCompareByType());
}
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
CompareShips(new DrawningShipCompareByColor());
}
private void CompareShips(IComparer<DrawningShip?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox.Image = _company.Show();
}
}

View File

@@ -117,4 +117,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="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>261, 17</value>
</metadata>
</root>

View File

@@ -1,3 +1,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
namespace ProjectPlane
{
internal static class Program
@@ -8,10 +13,28 @@ namespace ProjectPlane
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormShipCollection());
ServiceCollection services = new();
ConfigureServices(services);
using ServiceProvider serviceProvider = services.BuildServiceProvider();
Application.Run(serviceProvider.GetRequiredService<FormShipCollection>());
}
private static void ConfigureServices(ServiceCollection services)
{
services
.AddSingleton<FormShipCollection>()
.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
var config = new ConfigurationBuilder()
.AddJsonFile("serilogConfig.json", optional: false, reloadOnChange: true)
.Build();
option.AddSerilog(Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger());
});
}
}
}

View File

@@ -8,6 +8,19 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.10" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
@@ -23,4 +36,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="serilogConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,5 +0,0 @@
using ProjectPlane.Drawnings;
namespace ProjectPlane;
public delegate void ShipDelegate(DrawningShip ship);

View File

@@ -0,0 +1,35 @@
2024-05-05 19:31:54.5854 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:37:42.0203 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:37:45.8102 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:37:49.7304 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:37:53.9630 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:White:Black:False:False
2024-05-05 19:37:57.7237 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:01.6675 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:06.7083 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:11.3735 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:15.1331 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:20.0620 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:24.7261 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:31.0722 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:34.3915 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:38:40.7924 | WARNING | ProjectPlane.FormShipCollection | Ошибка: В коллекции превышено допустимое количество: 13
2024-05-05 19:44:19.0599 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:44:23.5467 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:35.2923 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:39.0113 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:41.8356 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:45.7168 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:49.4368 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:52.7510 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:46:57.4698 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:00.6705 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:03.5259 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:06.1029 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:09.0793 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:11.9753 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:15.0238 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:18.0164 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:21.2964 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:White
2024-05-05 19:47:26.9699 | WARNING | ProjectPlane.FormShipCollection | Ошибка: В коллекции превышено допустимое количество: 15
2024-05-05 19:47:37.1140 | INFORMATION | ProjectPlane.FormShipCollection | Удален объект по позиции 5
2024-05-05 19:47:41.2912 | ERROR | ProjectPlane.FormShipCollection | Ошибка: Не найден объект по позиции 5

View File

@@ -0,0 +1,21 @@
2024-05-19 14:40:29.0277 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: fgjd типа: List
2024-05-19 14:40:36.9497 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Yellow
2024-05-19 14:41:42.9096 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Yellow:Red:True:True
2024-05-19 14:42:44.9889 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Blue
2024-05-19 14:42:55.1814 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Red
2024-05-19 14:43:35.2025 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Blue:Purple:True:True
2024-05-19 14:44:32.1260 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: dhd типа: Massive
2024-05-19 14:44:43.1068 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Red
2024-05-19 14:44:49.7075 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Blue
2024-05-19 14:45:05.2935 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Red:Black:True:True
2024-05-19 14:45:34.8489 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Blue:Black:False:True
2024-05-19 15:03:53.6387 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: вапр типа: Massive
2024-05-19 15:04:10.5066 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Blue
2024-05-19 15:04:15.2984 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Red
2024-05-19 15:04:21.7942 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Blue:Black:True:True
2024-05-19 15:04:40.3403 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Purple
2024-05-19 15:04:51.3945 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: вао типа: List
2024-05-19 15:05:05.4559 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Yellow
2024-05-19 15:05:17.1129 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Purple:Yellow:True:True
2024-05-19 15:06:00.3431 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Blue:Black:True:True
2024-05-19 15:06:12.9361 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Green

View File

@@ -0,0 +1,12 @@
2024-05-20 13:25:42.8162 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: edhh типа: Massive
2024-05-20 13:25:50.1068 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Blue
2024-05-20 13:25:54.2419 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Red
2024-05-20 13:26:02.3952 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Blue:Red:True:True
2024-05-20 13:26:19.6205 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Purple
2024-05-20 13:26:34.6992 | INFORMATION | ProjectPlane.FormShipCollection | Добавлена коллекция: eha blya типа: List
2024-05-20 13:26:47.2484 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Black:Black:True:True
2024-05-20 13:27:00.5461 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Black:White:True:True
2024-05-20 13:28:19.2272 | INFORMATION | ProjectPlane.FormShipCollection | Удален объект по позиции 1
2024-05-20 13:28:39.0064 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityContainer:100:100:Red:Purple:True:True
2024-05-20 13:28:46.8157 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Red
2024-05-20 13:29:12.9298 | INFORMATION | ProjectPlane.FormShipCollection | Добавлен объект EntityShip:100:100:Black

View File

@@ -0,0 +1,25 @@
{
"AllowedHosts": "*",
"Serilog": {
"Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Console" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "C:\\Users\\rozko\\\\Documents\\Labs_OOP\\ProjectPlane\\ProjectPlane\\log.txt",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.ffff} | {Level:u} | {SourceContext} | {Message:1j}{NewLine}{Exception}"
}
}
]
}
}