From 112adcda3a5ca4675650287dc92d02459747fd36 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 5 Nov 2022 19:41:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5:=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=BA=D0=BD=D0=B0=20=D0=B8=20=D0=BC=D0=B5=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMapWithSetArmoredCars.Designer.cs | 75 +++++++++++++++++-- .../ArmoredCar/FormMapWithSetArmoredCars.cs | 45 +++++++++++ .../ArmoredCar/FormMapWithSetArmoredCars.resx | 3 + 3 files changed, 115 insertions(+), 8 deletions(-) diff --git a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs index ba49d7a..2a51009 100644 --- a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs +++ b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs @@ -47,9 +47,16 @@ namespace ArmoredCar this.buttonShowOnMap = new System.Windows.Forms.Button(); this.buttonAddCar = new System.Windows.Forms.Button(); this.pictureBox = new System.Windows.Forms.PictureBox(); + this.menuStrip1 = 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.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.groupBoxTools.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // groupBoxTools @@ -65,9 +72,9 @@ namespace ArmoredCar this.groupBoxTools.Controls.Add(this.buttonShowOnMap); this.groupBoxTools.Controls.Add(this.buttonAddCar); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(811, 0); + this.groupBoxTools.Location = new System.Drawing.Point(811, 24); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(204, 632); + this.groupBoxTools.Size = new System.Drawing.Size(204, 608); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; @@ -168,7 +175,7 @@ namespace ArmoredCar this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::ArmoredCar.Properties.Resources.Down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(91, 582); + this.buttonDown.Location = new System.Drawing.Point(91, 558); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 10; @@ -180,7 +187,7 @@ namespace ArmoredCar this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::ArmoredCar.Properties.Resources.Right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(127, 582); + this.buttonRight.Location = new System.Drawing.Point(127, 558); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 9; @@ -192,7 +199,7 @@ namespace ArmoredCar this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::ArmoredCar.Properties.Resources.Left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(55, 582); + this.buttonLeft.Location = new System.Drawing.Point(55, 558); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 8; @@ -204,7 +211,7 @@ namespace ArmoredCar this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::ArmoredCar.Properties.Resources.Up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(91, 546); + this.buttonUp.Location = new System.Drawing.Point(91, 522); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 7; @@ -234,12 +241,53 @@ namespace ArmoredCar // 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, 24); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(811, 632); + this.pictureBox.Size = new System.Drawing.Size(811, 608); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.FileToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(1015, 24); + this.menuStrip1.TabIndex = 2; + this.menuStrip1.Text = "menuStrip1"; + // + // 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(48, 20); + this.FileToolStripMenuItem.Text = "Файл"; + // + // SaveToolStripMenuItem + // + this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.SaveToolStripMenuItem.Text = "Сохранение"; + this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); + // + // LoadToolStripMenuItem + // + this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.LoadToolStripMenuItem.Text = "Загрузка"; + this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); + // + // openFileDialog + // + this.openFileDialog.Filter = "txt file | *.txt"; + // + // saveFileDialog + // + this.saveFileDialog.Filter = "txt file | *.txt"; + // // FormMapWithSetArmoredCars // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -247,6 +295,8 @@ namespace ArmoredCar this.ClientSize = new System.Drawing.Size(1015, 632); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; this.Name = "FormMapWithSetArmoredCars"; this.Text = "Карта с набором объектов"; this.groupBoxTools.ResumeLayout(false); @@ -254,7 +304,10 @@ namespace ArmoredCar this.groupBoxMaps.ResumeLayout(false); this.groupBoxMaps.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -277,5 +330,11 @@ namespace ArmoredCar private ListBox listBoxMaps; private TextBox textBoxNewMapName; private Button buttonAddMap; + private MenuStrip menuStrip1; + private ToolStripMenuItem FileToolStripMenuItem; + private ToolStripMenuItem SaveToolStripMenuItem; + private ToolStripMenuItem LoadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs index 89f0d00..3b9fd7e 100644 --- a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs +++ b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs @@ -220,5 +220,50 @@ namespace ArmoredCar } 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("Сохранение прошло успешно", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не сохранилось", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + /// + /// Обработка нажатия "Загрузка" + /// + /// + /// + private void LoadToolStripMenuItem_Click(object sender, EventArgs e) + { + // TODO продумать логику + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Загрузка прошла успешно", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Information); + ReloadMaps(); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } } \ No newline at end of file diff --git a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.resx b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.resx index f298a7b..938108a 100644 --- a/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.resx +++ b/ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.resx @@ -57,4 +57,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file