diff --git a/Battleship/Battleship/FormShipCollection.Designer.cs b/Battleship/Battleship/FormShipCollection.Designer.cs
index 8de68bf..cae2aff 100644
--- a/Battleship/Battleship/FormShipCollection.Designer.cs
+++ b/Battleship/Battleship/FormShipCollection.Designer.cs
@@ -244,8 +244,8 @@
private MenuStrip menuStrip1;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem сохранениеToolStripMenuItem;
- private ToolStripMenuItem загрузкаToolStripMenuItem;
private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog;
+ private ToolStripMenuItem загрузкаToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Battleship/Battleship/FormShipCollection.cs b/Battleship/Battleship/FormShipCollection.cs
index a73971a..d7a3d54 100644
--- a/Battleship/Battleship/FormShipCollection.cs
+++ b/Battleship/Battleship/FormShipCollection.cs
@@ -59,17 +59,18 @@ namespace Battleship
{
if (_storage.LoadData(openFileDialog.FileName))
{
- MessageBox.Show("Сохранение прошло успешно",
- "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
- ReloadObjects();
+ MessageBox.Show("Загрузка прошла успешно",
+ "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не загрузилось", "Результат",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+ ReloadObjects();
}
+
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
diff --git a/Battleship/Battleship/FormShipConfig.Designer.cs b/Battleship/Battleship/FormShipConfig.Designer.cs
index 3c5dee8..6cd4303 100644
--- a/Battleship/Battleship/FormShipConfig.Designer.cs
+++ b/Battleship/Battleship/FormShipConfig.Designer.cs
@@ -119,7 +119,7 @@
//
// panelPurple
//
- this.panelPurple.BackColor = System.Drawing.Color.Purple;
+ this.panelPurple.BackColor = System.Drawing.Color.Plum;
this.panelPurple.Location = new System.Drawing.Point(187, 78);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(50, 50);
@@ -164,7 +164,7 @@
//
// panelBlue
//
- this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
+ this.panelBlue.BackColor = System.Drawing.Color.SlateBlue;
this.panelBlue.Location = new System.Drawing.Point(131, 22);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(50, 50);
@@ -173,7 +173,7 @@
//
// panelGreen
//
- this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
+ this.panelGreen.BackColor = System.Drawing.Color.OliveDrab;
this.panelGreen.Location = new System.Drawing.Point(75, 22);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(50, 50);
@@ -182,7 +182,7 @@
//
// panelRed
//
- this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.BackColor = System.Drawing.Color.Maroon;
this.panelRed.Location = new System.Drawing.Point(19, 22);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(50, 50);
diff --git a/Battleship/Battleship/ShipsGenericStorage.cs b/Battleship/Battleship/ShipsGenericStorage.cs
index 06d5cbf..34b004b 100644
--- a/Battleship/Battleship/ShipsGenericStorage.cs
+++ b/Battleship/Battleship/ShipsGenericStorage.cs
@@ -100,6 +100,7 @@ namespace Battleship.Generics
///
/// Путь и имя файла
/// true - загрузка прошла успешно, false - ошибка при загрузке данных
+
public bool LoadData(string filename)
{
if (!File.Exists(filename))
@@ -116,12 +117,13 @@ namespace Battleship.Generics
bufferTextFromFile += temp.GetString(b);
}
}
- var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
+ var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
+ StringSplitOptions.RemoveEmptyEntries);
if (strs == null || strs.Length == 0)
{
return false;
}
- if (!strs[0].StartsWith("ShipsStorage"))
+ if (!strs[0].StartsWith("ShipStorage"))
{
//если нет такой записи, то это не те данные
return false;
@@ -129,19 +131,18 @@ namespace Battleship.Generics
_shipStorages.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;
}
- ShipGenericCollection collection = new(_pictureWidth, _pictureHeight);
+ ShipGenericCollection
+ collection = new(_pictureWidth, _pictureHeight);
string[] set = record[1].Split(_separatorRecords,
StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
- DrawningShip? ship =
- elem?.CreateDrawningShip(_separatorForObject, _pictureWidth, _pictureHeight);
+ DrawningShip? ship = elem?.CreateDrawningShip(_separatorForObject, _pictureWidth, _pictureHeight);
if (ship != null)
{
if (!(collection + ship))