готовая лаба 6
This commit is contained in:
parent
ee6765df72
commit
813efb47b7
@ -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))
|
||||
|
@ -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]),
|
||||
|
2
Sailboat/Sailboat/FormBoatCollection.Designer.cs
generated
2
Sailboat/Sailboat/FormBoatCollection.Designer.cs
generated
@ -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
|
||||
//
|
||||
|
@ -166,37 +166,40 @@ namespace Sailboat
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Обработка нажатия "Сохранение"
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Обработка нажатия "Загрузка"
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
//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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,6 @@
|
||||
<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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>144, 0</value>
|
||||
</metadata>
|
||||
|
Loading…
x
Reference in New Issue
Block a user