diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs b/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs index 78f7a2d..dd852d1 100644 --- a/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs +++ b/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs @@ -29,7 +29,6 @@ private void InitializeComponent() { this.groupBoxTools = new System.Windows.Forms.GroupBox(); - this.buttonSaveSelectedMap = new System.Windows.Forms.Button(); this.buttonShowLastRemovedObject = new System.Windows.Forms.Button(); this.groupBoxMaps = new System.Windows.Forms.GroupBox(); this.buttonDeleteMap = new System.Windows.Forms.Button(); @@ -51,9 +50,10 @@ this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveSelectedMapToolstripmenu = new System.Windows.Forms.ToolStripMenuItem(); + this.loadMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.buttonLoadMap = new System.Windows.Forms.Button(); this.groupBoxTools.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotives)).BeginInit(); @@ -62,8 +62,6 @@ // // groupBoxTools // - this.groupBoxTools.Controls.Add(this.buttonLoadMap); - this.groupBoxTools.Controls.Add(this.buttonSaveSelectedMap); this.groupBoxTools.Controls.Add(this.buttonShowLastRemovedObject); this.groupBoxTools.Controls.Add(this.groupBoxMaps); this.groupBoxTools.Controls.Add(this.buttonUp); @@ -83,16 +81,6 @@ this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; // - // buttonSaveSelectedMap - // - this.buttonSaveSelectedMap.Location = new System.Drawing.Point(31, 588); - this.buttonSaveSelectedMap.Name = "buttonSaveSelectedMap"; - this.buttonSaveSelectedMap.Size = new System.Drawing.Size(164, 38); - this.buttonSaveSelectedMap.TabIndex = 13; - this.buttonSaveSelectedMap.Text = "Сохранить выбранную карту"; - this.buttonSaveSelectedMap.UseVisualStyleBackColor = true; - this.buttonSaveSelectedMap.Click += new System.EventHandler(this.ButtonSaveSelectedMap_Click); - // // buttonShowLastRemovedObject // this.buttonShowLastRemovedObject.Location = new System.Drawing.Point(31, 517); @@ -287,7 +275,9 @@ // this.FileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.SaveToolStripMenuItem, - this.LoadToolStripMenuItem}); + this.LoadToolStripMenuItem, + this.saveSelectedMapToolstripmenu, + this.loadMapToolStripMenuItem}); this.FileToolStripMenuItem.Name = "FileToolStripMenuItem"; this.FileToolStripMenuItem.Size = new System.Drawing.Size(48, 20); this.FileToolStripMenuItem.Text = "Файл"; @@ -295,17 +285,31 @@ // SaveToolStripMenuItem // this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - this.SaveToolStripMenuItem.Size = new System.Drawing.Size(141, 22); + 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(141, 22); + this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.LoadToolStripMenuItem.Text = "Загрузка"; this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); // + // saveSelectedMapToolstripmenu + // + this.saveSelectedMapToolstripmenu.Name = "saveSelectedMapToolstripmenu"; + this.saveSelectedMapToolstripmenu.Size = new System.Drawing.Size(180, 22); + this.saveSelectedMapToolstripmenu.Text = "Сохранить карту"; + this.saveSelectedMapToolstripmenu.Click += new System.EventHandler(this.SaveSelectedMapToolStripMenu_Click); + // + // loadMapToolStripMenuItem + // + this.loadMapToolStripMenuItem.Name = "loadMapToolStripMenuItem"; + this.loadMapToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.loadMapToolStripMenuItem.Text = "Загрузить карту"; + this.loadMapToolStripMenuItem.Click += new System.EventHandler(this.LoadMapToolStripMenu_Click); + // // saveFileDialog // this.saveFileDialog.Filter = "txt file|*.txt"; @@ -314,16 +318,6 @@ // this.openFileDialog.Filter = "txt file|*.txt"; // - // buttonLoadMap - // - this.buttonLoadMap.Location = new System.Drawing.Point(31, 632); - this.buttonLoadMap.Name = "buttonLoadMap"; - this.buttonLoadMap.Size = new System.Drawing.Size(164, 38); - this.buttonLoadMap.TabIndex = 14; - this.buttonLoadMap.Text = "Загрузить карту"; - this.buttonLoadMap.UseVisualStyleBackColor = true; - this.buttonLoadMap.Click += new System.EventHandler(this.ButtonLoadMap_Click); - // // FormMapWithSetLocomotives // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -372,7 +366,7 @@ private ToolStripMenuItem LoadToolStripMenuItem; private SaveFileDialog saveFileDialog; private OpenFileDialog openFileDialog; - private Button buttonSaveSelectedMap; - private Button buttonLoadMap; + private ToolStripMenuItem saveSelectedMapToolstripmenu; + private ToolStripMenuItem loadMapToolStripMenuItem; } } \ No newline at end of file diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.cs b/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.cs index 82d5da6..e750c56 100644 --- a/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.cs +++ b/LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.cs @@ -283,7 +283,7 @@ /// /// /// - private void ButtonSaveSelectedMap_Click(object sender, EventArgs e) + private void SaveSelectedMapToolStripMenu_Click(object sender, EventArgs e) { if (saveFileDialog.ShowDialog() == DialogResult.OK) { @@ -304,7 +304,7 @@ /// /// /// - private void ButtonLoadMap_Click(object sender, EventArgs e) + private void LoadMapToolStripMenu_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/MapWithSetLocomotivesGeneric.cs b/LocomotivesAdvanced/LocomotivesAdvanced/MapWithSetLocomotivesGeneric.cs index a9ecc68..2a4cf40 100644 --- a/LocomotivesAdvanced/LocomotivesAdvanced/MapWithSetLocomotivesGeneric.cs +++ b/LocomotivesAdvanced/LocomotivesAdvanced/MapWithSetLocomotivesGeneric.cs @@ -205,5 +205,12 @@ _setLocomotives.Insert(DrawningObjectLocomotive.Create(record) as T, 0); } } + /// + /// Очистка содержимого карты + /// + public void ClearObjectCollection() + { + _setLocomotives.ClearLocomotives(); + } } } diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/MapsCollection.cs b/LocomotivesAdvanced/LocomotivesAdvanced/MapsCollection.cs index 6ea6147..4f16402 100644 --- a/LocomotivesAdvanced/LocomotivesAdvanced/MapsCollection.cs +++ b/LocomotivesAdvanced/LocomotivesAdvanced/MapsCollection.cs @@ -99,9 +99,12 @@ } if (_mapStorages.ContainsKey(mapName)) { - _mapStorages.Remove(mapName); + _mapStorages[mapName].ClearObjectCollection(); + } + else + { + _mapStorages.Add(mapName, new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, newMap)); } - _mapStorages.Add(mapName, new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, newMap)); _mapStorages[mapName].LoadData(info[1].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } return true; diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/SetLocomotivesGeneric.cs b/LocomotivesAdvanced/LocomotivesAdvanced/SetLocomotivesGeneric.cs index 96751a6..56d6144 100644 --- a/LocomotivesAdvanced/LocomotivesAdvanced/SetLocomotivesGeneric.cs +++ b/LocomotivesAdvanced/LocomotivesAdvanced/SetLocomotivesGeneric.cs @@ -97,5 +97,12 @@ } } } + /// + /// Очистка списка объектов + /// + public void ClearLocomotives() + { + _places.Clear(); + } } }