diff --git a/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs b/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs
index ee04ab0..c51a72a 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs
@@ -18,7 +18,7 @@ namespace ProjectStormtrooper
{
return new DrawingPlane(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
}
- if (strs.Length == 7)
+ if (strs.Length == 6)
{
return new DrawingStormtrooper(
Convert.ToInt32(strs[0]),
diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs
index ef86dd2..1a511d4 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs
@@ -39,9 +39,16 @@
buttonRemovePlane = new Button();
buttonAddPlane = new Button();
pictureBoxCollection = new PictureBox();
+ menuStrip = new MenuStrip();
+ файлToolStripMenuItem = new ToolStripMenuItem();
+ сохранитьToolStripMenuItem = new ToolStripMenuItem();
+ загрузитьToolStripMenuItem = new ToolStripMenuItem();
+ openFileDialog = new OpenFileDialog();
+ saveFileDialog = new SaveFileDialog();
groupBoxTools.SuspendLayout();
groupBoxStorages.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
+ menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@@ -52,9 +59,9 @@
groupBoxTools.Controls.Add(buttonRemovePlane);
groupBoxTools.Controls.Add(buttonAddPlane);
groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(787, 0);
+ groupBoxTools.Location = new Point(787, 28);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(230, 538);
+ groupBoxTools.Size = new Size(230, 510);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@@ -152,12 +159,52 @@
// pictureBoxCollection
//
pictureBoxCollection.Dock = DockStyle.Fill;
- pictureBoxCollection.Location = new Point(0, 0);
+ pictureBoxCollection.Location = new Point(0, 28);
pictureBoxCollection.Name = "pictureBoxCollection";
- pictureBoxCollection.Size = new Size(787, 538);
+ pictureBoxCollection.Size = new Size(787, 510);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(1017, 28);
+ menuStrip.TabIndex = 2;
+ menuStrip.Text = "menuStrip1";
+ //
+ // файлToolStripMenuItem
+ //
+ файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сохранитьToolStripMenuItem, загрузитьToolStripMenuItem });
+ файлToolStripMenuItem.Name = "файлToolStripMenuItem";
+ файлToolStripMenuItem.Size = new Size(59, 24);
+ файлToolStripMenuItem.Text = "Файл";
+ //
+ // сохранитьToolStripMenuItem
+ //
+ сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem";
+ сохранитьToolStripMenuItem.Size = new Size(166, 26);
+ сохранитьToolStripMenuItem.Text = "Сохранить";
+ сохранитьToolStripMenuItem.Click += saveToFileToolStripMenuItem_Click;
+ //
+ // загрузитьToolStripMenuItem
+ //
+ загрузитьToolStripMenuItem.Name = "загрузитьToolStripMenuItem";
+ загрузитьToolStripMenuItem.Size = new Size(166, 26);
+ загрузитьToolStripMenuItem.Text = "Загрузить";
+ загрузитьToolStripMenuItem.Click += loadFromFileToolStripMenuItem_Click;
+ //
+ // openFileDialog
+ //
+ openFileDialog.FileName = "openFileDialog1";
+ openFileDialog.Filter = "txt file | *.txt";
+ //
+ // saveFileDialog
+ //
+ saveFileDialog.Filter = "txt file | *.txt";
+ //
// FormPlaneCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
@@ -165,6 +212,8 @@
ClientSize = new Size(1017, 538);
Controls.Add(pictureBoxCollection);
Controls.Add(groupBoxTools);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
Name = "FormPlaneCollection";
Text = "Набор самолетов";
groupBoxTools.ResumeLayout(false);
@@ -172,7 +221,10 @@
groupBoxStorages.ResumeLayout(false);
groupBoxStorages.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -188,5 +240,11 @@
private ListBox listBoxStorages;
private Button buttonAddStorage;
private TextBox textBoxStorageName;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem файлToolStripMenuItem;
+ private ToolStripMenuItem сохранитьToolStripMenuItem;
+ private ToolStripMenuItem загрузитьToolStripMenuItem;
+ private OpenFileDialog openFileDialog;
+ private SaveFileDialog saveFileDialog;
}
}
\ No newline at end of file
diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs
index c2fc639..9abec9a 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs
@@ -159,6 +159,10 @@ namespace ProjectStormtrooper
///
///
private void buttonRefreshCollection_Click(object sender, EventArgs e)
+ {
+ RefreshCollection();
+ }
+ private void RefreshCollection()
{
if (listBoxStorages.SelectedIndex == -1)
{
@@ -171,5 +175,37 @@ namespace ProjectStormtrooper
}
pictureBoxCollection.Image = obj.ShowPlanes();
}
+
+ private void saveToFileToolStripMenuItem_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 loadFromFileToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storage.LoadData(openFileDialog.FileName))
+ {
+ ReloadObjects();
+ RefreshCollection();
+ MessageBox.Show("Загрузка прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
}
diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx
index a395bff..ad03251 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx
+++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx
@@ -117,4 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 152, 17
+
+
+ 319, 17
+
\ No newline at end of file