6 лаба готова
This commit is contained in:
parent
091db401f9
commit
8b4ed85f88
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
8
Battleship/Battleship/FormShipConfig.Designer.cs
generated
8
Battleship/Battleship/FormShipConfig.Designer.cs
generated
@ -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);
|
||||
|
@ -100,6 +100,7 @@ namespace Battleship.Generics
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
|
||||
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<DrawningShip, DrawningObjectShip> collection = new(_pictureWidth, _pictureHeight);
|
||||
ShipGenericCollection<DrawningShip, DrawningObjectShip>
|
||||
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user