diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.Designer.cs
index f2322bf..79a993d 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.Designer.cs
@@ -39,14 +39,21 @@
ButtonDelObject = new Button();
ButtonAddObject = new Button();
textBoxStorageName = new TextBox();
+ menuStrip = new MenuStrip();
+ toolStripMenuItem1 = new ToolStripMenuItem();
+ openFileDialog = new ToolStripMenuItem();
+ saveFileDialog = new ToolStripMenuItem();
+ openFileDialog_ = new OpenFileDialog();
+ saveFileDialog_ = new OpenFileDialog();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
panel1.SuspendLayout();
panel2.SuspendLayout();
+ menuStrip.SuspendLayout();
SuspendLayout();
//
// pictureBoxCollection
//
- pictureBoxCollection.Location = new Point(12, 12);
+ pictureBoxCollection.Location = new Point(12, 40);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(680, 432);
pictureBoxCollection.TabIndex = 0;
@@ -95,7 +102,7 @@
panel1.Controls.Add(ButtonRemoveSPAU);
panel1.Controls.Add(ButtonAddSPAU);
panel1.Controls.Add(maskedTextBoxNumber);
- panel1.Location = new Point(711, 217);
+ panel1.Location = new Point(711, 245);
panel1.Name = "panel1";
panel1.Size = new Size(176, 227);
panel1.TabIndex = 5;
@@ -106,9 +113,9 @@
panel2.Controls.Add(ButtonDelObject);
panel2.Controls.Add(ButtonAddObject);
panel2.Controls.Add(textBoxStorageName);
- panel2.Location = new Point(711, 12);
+ panel2.Location = new Point(711, 40);
panel2.Name = "panel2";
- panel2.Size = new Size(174, 198);
+ panel2.Size = new Size(174, 199);
panel2.TabIndex = 6;
//
// listBoxStorages
@@ -148,14 +155,57 @@
textBoxStorageName.Size = new Size(143, 27);
textBoxStorageName.TabIndex = 0;
//
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1 });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(899, 28);
+ menuStrip.TabIndex = 7;
+ menuStrip.Text = "menuStrip1";
+ //
+ // toolStripMenuItem1
+ //
+ toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { openFileDialog, saveFileDialog });
+ toolStripMenuItem1.Name = "toolStripMenuItem1";
+ toolStripMenuItem1.Size = new Size(59, 24);
+ toolStripMenuItem1.Text = "Файл";
+ //
+ // openFileDialog
+ //
+ openFileDialog.Name = "openFileDialog";
+ openFileDialog.Size = new Size(224, 26);
+ openFileDialog.Text = "Открыть файл";
+ openFileDialog.Click += LoadToolStripMenuItem_Click;
+ //
+ // saveFileDialog
+ //
+ saveFileDialog.Name = "saveFileDialog";
+ saveFileDialog.Size = new Size(224, 26);
+ saveFileDialog.Text = "Сохранить файл";
+ saveFileDialog.Click += SaveToolStripMenuItem_Click;
+ //
+ // openFileDialog_
+ //
+ openFileDialog_.FileName = "openFileDialog";
+ openFileDialog_.Filter = "txt file | *.txt";
+ //
+ // saveFileDialog_
+ //
+ saveFileDialog_.FileName = "saveFileDialog";
+ saveFileDialog_.Filter = "txt file | *.txt";
+ //
// FormSPAUCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(899, 456);
+ ClientSize = new Size(899, 484);
Controls.Add(panel2);
Controls.Add(panel1);
Controls.Add(pictureBoxCollection);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
Name = "FormSPAUCollection";
Text = "FormSPAUCollection";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
@@ -163,7 +213,10 @@
panel1.PerformLayout();
panel2.ResumeLayout(false);
panel2.PerformLayout();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -179,5 +232,11 @@
private TextBox textBoxStorageName;
private Button ButtonDelObject;
private ListBox listBoxStorages;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem toolStripMenuItem1;
+ private ToolStripMenuItem openFileDialog;
+ private ToolStripMenuItem saveFileDialog;
+ private OpenFileDialog openFileDialog_;
+ private OpenFileDialog saveFileDialog_;
}
}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
index d5753a7..dab2844 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
@@ -208,6 +208,49 @@ namespace SelfPropelledArtilleryUnit
pictureBoxCollection.Image = obj.ShowSPAUs();
}
+ // …
+ ///
+ /// Обработка нажатия "Сохранение"
+ ///
+ ///
+ ///
+ 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)
+ {
+ if (openFileDialog_.ShowDialog() == DialogResult.OK)
+ {
+ if (_storage.LoadData(openFileDialog_.FileName))
+ {
+ MessageBox.Show("Загрузка прошлa успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ ReloadObjects();
+ }
+ else
+ {
+ MessageBox.Show("Не загрузилось", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.resx b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.resx
index af32865..375a32c 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.resx
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.resx
@@ -117,4 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 283, 23
+
+
+ 130, 23
+
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUGenericStorage.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUGenericStorage.cs
index 24fc8d0..4bd4244 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUGenericStorage.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUGenericStorage.cs
@@ -119,7 +119,7 @@ namespace SelfPropelledArtilleryUnit.Generics
}
using FileStream fs = new(filename, FileMode.Create);
byte[] info = new
- UTF8Encoding(true).GetBytes($"SpAUStorage{Environment.NewLine}{data}");
+ UTF8Encoding(true).GetBytes($"SPAUStorage{Environment.NewLine}{data}");
fs.Write(info, 0, info.Length);
return true;
}
@@ -144,13 +144,12 @@ namespace SelfPropelledArtilleryUnit.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("CarStorage"))
+ if (!strs[0].StartsWith("SPAUStorage"))
{
//если нет такой записи, то это не те данные
return false;
@@ -158,16 +157,14 @@ namespace SelfPropelledArtilleryUnit.Generics
_SPAUStorages.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;
}
SPAUGenericCollection
collection = new(_pictureWidth, _pictureHeight);
- string[] set = record[1].Split(_separatorRecords,
- StringSplitOptions.RemoveEmptyEntries);
+ string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
DrawningSPAU? sPAU =