diff --git a/Sailboat/Sailboat/BoatsGenericStorage.cs b/Sailboat/Sailboat/BoatsGenericStorage.cs
index 8b68b99..c282fdc 100644
--- a/Sailboat/Sailboat/BoatsGenericStorage.cs
+++ b/Sailboat/Sailboat/BoatsGenericStorage.cs
@@ -119,7 +119,7 @@ namespace Sailboat.Generics
}
using FileStream fs = new(filename, FileMode.Create);
byte[] info = new
- UTF8Encoding(true).GetBytes($"CarStorage{Environment.NewLine}{data}");
+ UTF8Encoding(true).GetBytes($"BoatStorage{Environment.NewLine}{data}");
fs.Write(info, 0, info.Length);
return true;
}
@@ -150,7 +150,7 @@ namespace Sailboat.Generics
{
return false;
}
- if (!strs[0].StartsWith("CarStorage"))
+ if (!strs[0].StartsWith("BoatStorage"))
{
//если нет такой записи, то это не те данные
return false;
@@ -158,8 +158,7 @@ namespace Sailboat.Generics
_boatStorages.Clear();
foreach (string data in strs)
{
- string[] record = data.Split(_separatorForKeyValue,
- StringSplitOptions.RemoveEmptyEntries);
+ string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 2)
{
continue;
@@ -170,8 +169,7 @@ namespace Sailboat.Generics
StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
- DrawingBoat? boat =
- elem?.CreateDrawingBoat(_separatorForObject, _pictureWidth, _pictureHeight);
+ DrawingBoat? boat = elem?.CreateDrawingBoat(_separatorForObject, _pictureWidth, _pictureHeight);
if (boat != null)
{
if (!(collection + boat))
diff --git a/Sailboat/Sailboat/ExtentionDrawingBoat.cs b/Sailboat/Sailboat/ExtentionDrawingBoat.cs
index 190503f..07da6f2 100644
--- a/Sailboat/Sailboat/ExtentionDrawingBoat.cs
+++ b/Sailboat/Sailboat/ExtentionDrawingBoat.cs
@@ -26,7 +26,7 @@ namespace Sailboat.DrawingObjects
return new DrawingBoat(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
}
- if (strs.Length == 7)
+ if (strs.Length == 6)
{
return new DrawingSailboat(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]),
diff --git a/Sailboat/Sailboat/FormBoatCollection.Designer.cs b/Sailboat/Sailboat/FormBoatCollection.Designer.cs
index 871bc2d..f18e0c1 100644
--- a/Sailboat/Sailboat/FormBoatCollection.Designer.cs
+++ b/Sailboat/Sailboat/FormBoatCollection.Designer.cs
@@ -191,12 +191,14 @@
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
this.SaveToolStripMenuItem.Text = "Сохранение";
+ this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
//
// LoadToolStripMenuItem
//
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
this.LoadToolStripMenuItem.Text = "Загрузка";
+ this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
//
// openFileDialog
//
diff --git a/Sailboat/Sailboat/FormBoatCollection.cs b/Sailboat/Sailboat/FormBoatCollection.cs
index 8ea390a..1aa637c 100644
--- a/Sailboat/Sailboat/FormBoatCollection.cs
+++ b/Sailboat/Sailboat/FormBoatCollection.cs
@@ -166,37 +166,40 @@ namespace Sailboat
}
}
- /////
- ///// Обработка нажатия "Сохранение"
- /////
- /////
- /////
- //private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
- //{
- // if (saveFileDialog.ShowDialog() == DialogResult.OK)
- // {
- // if (_storage.SaveData(saveFileDialog.FileName))
- // {
- // MessageBox.Show("Сохранение прошло успешно",
- // "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // }
- // else
- // {
- // MessageBox.Show("Не сохранилось", "Результат",
- // MessageBoxButtons.OK, MessageBoxIcon.Error);
- // }
- // }
- //}
+ private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storage.SaveData(saveFileDialog.FileName))
+ {
+ MessageBox.Show("Сохранение прошло успешно",
+ "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не сохранилось", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
- /////
- ///// Обработка нажатия "Загрузка"
- /////
- /////
- /////
- //private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
- //{
- // // TODO продумать логику
- //}
+ private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storage.LoadData(openFileDialog.FileName))
+ {
+ MessageBox.Show("Загрузка прошла успешно",
+ "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не загрузилось", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ ReloadObjects();
+ }
}
}
diff --git a/Sailboat/Sailboat/FormBoatCollection.resx b/Sailboat/Sailboat/FormBoatCollection.resx
index 66d62b4..3198a4b 100644
--- a/Sailboat/Sailboat/FormBoatCollection.resx
+++ b/Sailboat/Sailboat/FormBoatCollection.resx
@@ -60,9 +60,6 @@
17, 17
-
- 17, 17
-
144, 0