From eb32a4c319121830dd57938f66289347c97313d6 Mon Sep 17 00:00:00 2001 From: Nikita Potapov <47923521+nikita-potapov@users.noreply.github.com> Date: Mon, 14 Nov 2022 22:47:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=A1?= =?UTF-8?q?=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D1=82=D1=8C=20=D0=B8=20?= =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Boats/Boats/FormMapWithSetBoats.Designer.cs | 71 +++++++++++++++++++-- Boats/Boats/FormMapWithSetBoats.cs | 40 ++++++++++++ Boats/Boats/FormMapWithSetBoats.resx | 9 +++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/Boats/Boats/FormMapWithSetBoats.Designer.cs b/Boats/Boats/FormMapWithSetBoats.Designer.cs index 0a0e537..332629c 100644 --- a/Boats/Boats/FormMapWithSetBoats.Designer.cs +++ b/Boats/Boats/FormMapWithSetBoats.Designer.cs @@ -45,9 +45,16 @@ this.listBoxMaps = new System.Windows.Forms.ListBox(); this.ButtonAddMap = new System.Windows.Forms.Button(); this.textBoxNewMapName = new System.Windows.Forms.TextBox(); + this.menuStrip = new System.Windows.Forms.MenuStrip(); + this.файлToolStripMenuItem = 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.groupBoxInstruments.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.groupBoxMaps.SuspendLayout(); + this.menuStrip.SuspendLayout(); this.SuspendLayout(); // // groupBoxInstruments @@ -62,9 +69,9 @@ this.groupBoxInstruments.Controls.Add(this.ButtonRemoveBoat); this.groupBoxInstruments.Controls.Add(this.ButtonAddBoat); this.groupBoxInstruments.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxInstruments.Location = new System.Drawing.Point(901, 0); + this.groupBoxInstruments.Location = new System.Drawing.Point(901, 28); this.groupBoxInstruments.Name = "groupBoxInstruments"; - this.groupBoxInstruments.Size = new System.Drawing.Size(250, 768); + this.groupBoxInstruments.Size = new System.Drawing.Size(250, 783); this.groupBoxInstruments.TabIndex = 0; this.groupBoxInstruments.TabStop = false; this.groupBoxInstruments.Text = "Инструменты"; @@ -182,9 +189,9 @@ // 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(901, 768); + this.pictureBox.Size = new System.Drawing.Size(901, 783); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // @@ -240,14 +247,59 @@ this.textBoxNewMapName.Size = new System.Drawing.Size(220, 27); this.textBoxNewMapName.TabIndex = 0; // + // menuStrip + // + this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.файлToolStripMenuItem}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(1151, 28); + this.menuStrip.TabIndex = 12; + this.menuStrip.Text = "menuStrip1"; + // + // файлToolStripMenuItem + // + this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.SaveToolStripMenuItem, + this.LoadToolStripMenuItem}); + this.файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + this.файлToolStripMenuItem.Size = new System.Drawing.Size(59, 24); + this.файлToolStripMenuItem.Text = "Файл"; + // + // SaveToolStripMenuItem + // + 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 + // + this.openFileDialog.FileName = "openFileDialog1"; + this.openFileDialog.Filter = " txt file | *.txt"; + // + // saveFileDialog + // + this.saveFileDialog.Filter = " txt file | *.txt"; + // // FormMapWithSetBoats // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1151, 768); + this.ClientSize = new System.Drawing.Size(1151, 811); this.Controls.Add(this.groupBoxMaps); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxInstruments); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Name = "FormMapWithSetBoats"; this.Text = "Карта с набором элементов"; this.groupBoxInstruments.ResumeLayout(false); @@ -255,7 +307,10 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.groupBoxMaps.ResumeLayout(false); this.groupBoxMaps.PerformLayout(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -278,5 +333,11 @@ private ListBox listBoxMaps; private Button ButtonAddMap; private TextBox textBoxNewMapName; + private MenuStrip menuStrip; + private ToolStripMenuItem файлToolStripMenuItem; + private ToolStripMenuItem SaveToolStripMenuItem; + private ToolStripMenuItem LoadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/Boats/Boats/FormMapWithSetBoats.cs b/Boats/Boats/FormMapWithSetBoats.cs index 2b13665..908f95c 100644 --- a/Boats/Boats/FormMapWithSetBoats.cs +++ b/Boats/Boats/FormMapWithSetBoats.cs @@ -261,5 +261,45 @@ namespace Boats MessageBox.Show("Не удалось добавить объект"); } } + /// + /// Обработка нажатия "Сохранить" + /// + /// + /// + 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) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.LoadData(openFileDialog.FileName)) + { + ReloadMaps(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + MessageBox.Show("Загрузка прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/Boats/Boats/FormMapWithSetBoats.resx b/Boats/Boats/FormMapWithSetBoats.resx index f298a7b..f8766b9 100644 --- a/Boats/Boats/FormMapWithSetBoats.resx +++ b/Boats/Boats/FormMapWithSetBoats.resx @@ -57,4 +57,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