diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.Designer.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.Designer.cs
index c3c2388..5242822 100644
--- a/Locomotive/Locomotive/FormMapWithSetLocomotives.Designer.cs
+++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.Designer.cs
@@ -45,9 +45,16 @@
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonAddLocomotive = new System.Windows.Forms.Button();
this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.loadFileDialog = new System.Windows.Forms.OpenFileDialog();
+ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.groupBoxTools.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// groupBoxTools
@@ -63,9 +70,9 @@
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxTools.Controls.Add(this.buttonAddLocomotive);
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
- this.groupBoxTools.Location = new System.Drawing.Point(580, 0);
+ this.groupBoxTools.Location = new System.Drawing.Point(580, 28);
this.groupBoxTools.Name = "groupBoxTools";
- this.groupBoxTools.Size = new System.Drawing.Size(220, 546);
+ this.groupBoxTools.Size = new System.Drawing.Size(220, 540);
this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Tools";
@@ -228,19 +235,62 @@
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBox.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox.Location = new System.Drawing.Point(0, 28);
this.pictureBox.Name = "pictureBox";
- this.pictureBox.Size = new System.Drawing.Size(580, 546);
+ this.pictureBox.Size = new System.Drawing.Size(580, 540);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
//
+ // menuStrip
+ //
+ this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.fileToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new System.Drawing.Size(800, 28);
+ this.menuStrip.TabIndex = 2;
+ //
+ // fileToolStripMenuItem
+ //
+ this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.saveToolStripMenuItem,
+ this.loadToolStripMenuItem});
+ this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+ this.fileToolStripMenuItem.Size = new System.Drawing.Size(46, 24);
+ this.fileToolStripMenuItem.Text = "File";
+ //
+ // saveToolStripMenuItem
+ //
+ this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ this.saveToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.saveToolStripMenuItem.Text = "Save";
+ 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 = "Load";
+ this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click);
+ //
+ // loadFileDialog
+ //
+ this.loadFileDialog.Filter = "txt file | *.txt";
+ //
+ // saveFileDialog
+ //
+ this.saveFileDialog.Filter = "txt file | *.txt";
+ //
// FormMapWithSetLocomotives
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 546);
+ this.ClientSize = new System.Drawing.Size(800, 568);
this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxTools);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
this.Name = "FormMapWithSetLocomotives";
this.Text = "FormMapWithSetLocomotives";
this.groupBoxTools.ResumeLayout(false);
@@ -248,7 +298,10 @@
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -271,5 +324,11 @@
private Button buttonAddMap;
private Button buttonDeleteMap;
private ListBox listBoxMaps;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem fileToolStripMenuItem;
+ private ToolStripMenuItem saveToolStripMenuItem;
+ private ToolStripMenuItem loadToolStripMenuItem;
+ private OpenFileDialog loadFileDialog;
+ private SaveFileDialog saveFileDialog;
}
}
\ No newline at end of file
diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
index 4c9a0ad..69b44ff 100644
--- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
+++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs
@@ -186,5 +186,36 @@ namespace Locomotive
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
}
+ private void saveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_mapsCollection.SaveData(saveFileDialog.FileName))
+ {
+ MessageBox.Show("Saved successfully", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Saving failed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void loadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (loadFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_mapsCollection.LoadData(loadFileDialog.FileName))
+ {
+ MessageBox.Show("Loaded successfully", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Loading failed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ ReloadMaps();
+ pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
+ }
+ }
}
}
diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.resx b/Locomotive/Locomotive/FormMapWithSetLocomotives.resx
index f298a7b..a0c7756 100644
--- a/Locomotive/Locomotive/FormMapWithSetLocomotives.resx
+++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.resx
@@ -57,4 +57,16 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 144, 17
+
+
+ 311, 17
+
+
+ 33
+
\ No newline at end of file