From 88dcfeef927e69c04b82d691a0c6e9f5f087cf8d Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Mon, 7 Nov 2022 23:23:09 +0400 Subject: [PATCH] commit 2 --- ProjectPlane/ProjectPlane/DrawingObject.cs | 6 ++ ProjectPlane/ProjectPlane/ExtentionPlane.cs | 2 +- .../FormMapWithSetPlanes.Designer.cs | 72 ++++++++++++++++--- .../ProjectPlane/FormMapWithSetPlanes.cs | 32 +++++++++ .../ProjectPlane/FormMapWithSetPlanes.resx | 9 +++ ProjectPlane/ProjectPlane/FormPlaneConfig.cs | 2 + ProjectPlane/ProjectPlane/IDrawingObject.cs | 7 ++ 7 files changed, 121 insertions(+), 9 deletions(-) diff --git a/ProjectPlane/ProjectPlane/DrawingObject.cs b/ProjectPlane/ProjectPlane/DrawingObject.cs index 18e6766..d228a40 100644 --- a/ProjectPlane/ProjectPlane/DrawingObject.cs +++ b/ProjectPlane/ProjectPlane/DrawingObject.cs @@ -36,5 +36,11 @@ namespace ProjectPlane { _plane.DrawTransport(g); } + + public string GetInfo() => _plane?.GetDataForSave(); + public static IDrawingObject Create(string data) => new DrawingObject(data.CreateDrawingPlane()); + } + } + diff --git a/ProjectPlane/ProjectPlane/ExtentionPlane.cs b/ProjectPlane/ProjectPlane/ExtentionPlane.cs index 22720af..dc6260c 100644 --- a/ProjectPlane/ProjectPlane/ExtentionPlane.cs +++ b/ProjectPlane/ProjectPlane/ExtentionPlane.cs @@ -18,7 +18,7 @@ namespace ProjectPlane /// /// /// - public static DrawingPlane CreateDrawingplane(this string info) + public static DrawingPlane CreateDrawingPlane(this string info) { string[] strs = info.Split(_separatorForObject); if (strs.Length == 3) diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs index 239d1ca..7a40ffc 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs @@ -46,9 +46,16 @@ this.ButtonAddMap = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); 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.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.menuStrip.SuspendLayout(); this.SuspendLayout(); // // groupBoxTools @@ -64,9 +71,9 @@ this.groupBoxTools.Controls.Add(this.buttonAddPlane); this.groupBoxTools.Controls.Add(this.groupBoxMaps); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(680, 0); + this.groupBoxTools.Location = new System.Drawing.Point(680, 24); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(204, 590); + this.groupBoxTools.Size = new System.Drawing.Size(204, 566); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Tools"; @@ -76,7 +83,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::ProjectPlane.Properties.Resources.right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(133, 529); + this.buttonRight.Location = new System.Drawing.Point(133, 505); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(50, 49); this.buttonRight.TabIndex = 14; @@ -88,7 +95,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::ProjectPlane.Properties.Resources.down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(77, 529); + this.buttonDown.Location = new System.Drawing.Point(77, 505); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(50, 49); this.buttonDown.TabIndex = 13; @@ -100,7 +107,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::ProjectPlane.Properties.Resources.left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(21, 529); + this.buttonLeft.Location = new System.Drawing.Point(21, 505); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(50, 49); this.buttonLeft.TabIndex = 12; @@ -112,7 +119,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::ProjectPlane.Properties.Resources.up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(77, 472); + this.buttonUp.Location = new System.Drawing.Point(77, 448); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(50, 49); this.buttonUp.TabIndex = 11; @@ -234,12 +241,50 @@ // 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(680, 590); + this.pictureBox.Size = new System.Drawing.Size(680, 566); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // menuStrip + // + 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(884, 24); + this.menuStrip.TabIndex = 2; + this.menuStrip.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(37, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + 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(180, 22); + this.loadToolStripMenuItem.Text = "Load"; + this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click); + // + // openFileDialog + // + this.openFileDialog.FileName = "openFileDialog1"; + this.openFileDialog.Filter = "text file | *.txt"; + // // FormMapWithSetPlanes // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -247,6 +292,8 @@ this.ClientSize = new System.Drawing.Size(884, 590); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Name = "FormMapWithSetPlanes"; this.Text = "Map with object sets"; this.groupBoxTools.ResumeLayout(false); @@ -254,7 +301,10 @@ this.groupBoxMaps.ResumeLayout(false); this.groupBoxMaps.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -277,5 +327,11 @@ private Button buttonDown; private Button buttonLeft; private Button buttonUp; + private MenuStrip menuStrip; + private ToolStripMenuItem fileToolStripMenuItem; + private ToolStripMenuItem saveToolStripMenuItem; + private ToolStripMenuItem loadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs index 619fb67..aa927a9 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs @@ -231,5 +231,37 @@ namespace ProjectPlane } } + private void loadToolStripMenuItem_Click(object sender, EventArgs e) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Succesfull loading", "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(); + } + } + + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.SaveData(saveFileDialog.FileName)) + { + MessageBox.Show("Succesfull saving", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Savingfailed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + } } } diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx index f298a7b..1d824c7 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 125, 17 + + + 258, 17 + \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormPlaneConfig.cs b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs index 72a7bce..71897fb 100644 --- a/ProjectPlane/ProjectPlane/FormPlaneConfig.cs +++ b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs @@ -23,6 +23,8 @@ namespace ProjectPlane /// /// Конструктор /// + + delegate void MessageHandler(string message); public FormPlaneConfig() { InitializeComponent(); diff --git a/ProjectPlane/ProjectPlane/IDrawingObject.cs b/ProjectPlane/ProjectPlane/IDrawingObject.cs index 7e27543..097c15a 100644 --- a/ProjectPlane/ProjectPlane/IDrawingObject.cs +++ b/ProjectPlane/ProjectPlane/IDrawingObject.cs @@ -36,5 +36,12 @@ namespace ProjectPlane /// /// (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + + /// + /// Получение информации по объекту + /// + /// + string GetInfo(); + } }