доработки

This commit is contained in:
AnnaLioness 2023-12-04 18:51:32 +04:00
parent 2b67952e64
commit 2480cef43f
6 changed files with 1 additions and 61 deletions

View File

@ -190,16 +190,6 @@ namespace Lab1ContainersShip
{ {
if (saveFileDialog.ShowDialog() == DialogResult.OK) if (saveFileDialog.ShowDialog() == DialogResult.OK)
{ {
/*if (_storage.SaveData(saveFileDialog.FileName))
{
MessageBox.Show("Сохранение прошло успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не сохранилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}*/
try try
{ {
_storage.SaveData(saveFileDialog.FileName); _storage.SaveData(saveFileDialog.FileName);
@ -218,17 +208,6 @@ namespace Lab1ContainersShip
{ {
if (openFileDialog.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
/*if (_storage.LoadData(openFileDialog.FileName))
{
ReloadObjects();
MessageBox.Show("Загрузка прошла успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не загрузилось", "Результат",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}*/
try try
{ {
_storage.LoadData(openFileDialog.FileName); _storage.LoadData(openFileDialog.FileName);

View File

@ -25,9 +25,4 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Remove="ShipCollection.resx" /> <EmbeddedResource Remove="ShipCollection.resx" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -21,13 +21,6 @@ namespace Lab1ContainersShip
/// <summary> /// <summary>
/// Главная точка входа для приложения. /// Главная точка входа для приложения.
/// </summary> /// </summary>
/*[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormShipCollection());
}*/
[STAThread] [STAThread]
static void Main() static void Main()
{ {
@ -45,12 +38,6 @@ namespace Lab1ContainersShip
} }
private static void ConfigureServices(ServiceCollection services) private static void ConfigureServices(ServiceCollection services)
{ {
/*services.AddSingleton<FormShipCollection>()
.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});*/
services.AddSingleton<FormShipCollection>().AddLogging(option => services.AddSingleton<FormShipCollection>().AddLogging(option =>
{ {
string[] path = Directory.GetCurrentDirectory().Split('\\'); string[] path = Directory.GetCurrentDirectory().Split('\\');

View File

@ -67,13 +67,11 @@ namespace Lab1ContainersShip
// TODO вставка по позиции // TODO вставка по позиции
if(_places.Count >= _maxCount) if(_places.Count >= _maxCount)
{ {
// return false;
throw new StorageOverflowException(position); throw new StorageOverflowException(position);
} }
if(position < 0 || position > _places.Count) if(position < 0 || position > _places.Count)
{ {
throw new ShipNotFoundException(position); throw new ShipNotFoundException(position);
//return false;
} }
if(position == _places.Count) if(position == _places.Count)
{ {
@ -102,7 +100,6 @@ namespace Lab1ContainersShip
} }
else else
{ {
// return false;
throw new ShipNotFoundException(position); throw new ShipNotFoundException(position);
} }
@ -140,7 +137,6 @@ namespace Lab1ContainersShip
set set
{ {
//Insert(value, position);
try try
{ {
Insert(value, position); Insert(value, position);

View File

@ -130,7 +130,7 @@ public void SaveData(string filename)
} }
if (data.Length == 0) if (data.Length == 0)
{ {
throw new Exception("Невалиданя операция, нет данных для сохранения"); throw new InvalidOperationException("Невалиданя операция, нет данных для сохранения");
} }
using(StreamWriter sr = new StreamWriter(filename)) using(StreamWriter sr = new StreamWriter(filename))
{ {
@ -180,10 +180,6 @@ public void SaveData(string filename)
elem?.CreateDrawingShip(_separatorForObject, _pictureWidth, _pictureHeight); elem?.CreateDrawingShip(_separatorForObject, _pictureWidth, _pictureHeight);
if (ship != null) if (ship != null)
{ {
/*if (collection + ship == -1)
{
throw new Exception("Ошибка добавления в коллекцию");
}*/
try try
{ {
int t = collection + ship; int t = collection + ship;

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="carlog-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>