From 807dedc0ef96575d2db347b9de5c054a47d482e5 Mon Sep 17 00:00:00 2001 From: Jason Lautzenheiser Date: Wed, 21 Mar 2018 21:12:27 -0400 Subject: [PATCH] change: change the room properties by removing warning about multiple end rooms (#422) Also fixed the context menu where if you had multiple rooms selected the end room menu was disabled. There was no reason for that. --- UI/Controls/Canvas.cs | 9 ++++++--- UI/MainForm.cs | 4 ++-- UI/RoomPropertiesDialog.Designer.cs | 7 +++---- UI/RoomPropertiesDialog.cs | 15 --------------- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/UI/Controls/Canvas.cs b/UI/Controls/Canvas.cs index 60ba2ba2..08a80f67 100644 --- a/UI/Controls/Canvas.cs +++ b/UI/Controls/Canvas.cs @@ -179,6 +179,9 @@ public Element SelectedElement public bool HasSingleSelectedElement => SelectedElementCount == 1; + public bool HasSelectedRooms => mSelectedElements.OfType().Any(); + public bool HasSingleSelectedRoom => mSelectedElements.OfType().Count() == 1; + public IList SelectedElements => mSelectedElements; [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -3052,11 +3055,11 @@ private void ctxCanvasMenu_Opening(object sender, CancelEventArgs e) startRoomToolStripMenuItem.Visible = true; endRoomToolStripMenuItem.Visible = true; - startRoomToolStripMenuItem.Enabled = HasSingleSelectedElement; - endRoomToolStripMenuItem.Enabled = HasSingleSelectedElement; + startRoomToolStripMenuItem.Enabled = SelectedRooms.Count == 1; + endRoomToolStripMenuItem.Enabled = HasSelectedRooms; startRoomToolStripMenuItem.Checked = lastSelectedRoom.IsStartRoom && HasSingleSelectedElement; - endRoomToolStripMenuItem.Checked = lastSelectedRoom.IsEndRoom && HasSingleSelectedElement; + endRoomToolStripMenuItem.Checked = HasSelectedRooms && lastSelectedRoom.IsEndRoom; sendToBackToolStripMenuItem.Visible = true; bringToFrontToolStripMenuItem.Visible = true; diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 2e40b5f3..68061d7c 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -1100,8 +1100,8 @@ private void updateCommandUI() { startRoomToolStripMenuItem.Enabled = Canvas.HasSingleSelectedElement && Canvas.SelectedElement is Room; startRoomToolStripMenuItem.Checked = Canvas.HasSingleSelectedElement && Canvas.SelectedElement is Room && ((Room) Canvas.SelectedElement).IsStartRoom; - endRoomToolStripMenuItem.Enabled = Canvas.SelectedElement is Room; - endRoomToolStripMenuItem.Checked = Canvas.SelectedElement is Room && ((Room) Canvas.SelectedElement).IsEndRoom; + endRoomToolStripMenuItem.Enabled = Canvas.HasSelectedRooms; + endRoomToolStripMenuItem.Checked = Canvas.HasSelectedRooms && (Canvas.SelectedRooms.Any(p=>p.IsEndRoom)); roomsMustHaveUniqueNamesToolStripMenuItem.Checked = Project.Current.MustHaveUniqueNames; diff --git a/UI/RoomPropertiesDialog.Designer.cs b/UI/RoomPropertiesDialog.Designer.cs index bf64acdf..5b50c4d7 100644 --- a/UI/RoomPropertiesDialog.Designer.cs +++ b/UI/RoomPropertiesDialog.Designer.cs @@ -377,8 +377,8 @@ private void InitializeComponent() this.m_tabControl.ControlBox.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] { this.m_tabControl.ControlBox.MenuBox, this.m_tabControl.ControlBox.CloseBox}); - this.m_tabControl.Controls.Add(this.superTabControlPanel3); this.m_tabControl.Controls.Add(this.superTabControlPanel2); + this.m_tabControl.Controls.Add(this.superTabControlPanel3); this.m_tabControl.Controls.Add(this.superTabControlPanel1); this.m_tabControl.Controls.Add(this.superTabControlPanel5); this.m_tabControl.Controls.Add(this.superTabControlPanel4); @@ -423,9 +423,9 @@ private void InitializeComponent() this.superTabControlPanel3.Controls.Add(this.label3); this.superTabControlPanel3.Controls.Add(this.m_changeRoomTextButton); this.superTabControlPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.superTabControlPanel3.Location = new System.Drawing.Point(0, 26); + this.superTabControlPanel3.Location = new System.Drawing.Point(0, 0); this.superTabControlPanel3.Name = "superTabControlPanel3"; - this.superTabControlPanel3.Size = new System.Drawing.Size(477, 190); + this.superTabControlPanel3.Size = new System.Drawing.Size(477, 216); this.superTabControlPanel3.TabIndex = 0; this.superTabControlPanel3.TabItem = this.tabColors; // @@ -1188,7 +1188,6 @@ private void InitializeComponent() this.chkEndRoom.TabIndex = 12; this.chkEndRoom.Text = "End Room"; this.chkEndRoom.UseVisualStyleBackColor = true; - this.chkEndRoom.CheckedChanged += new System.EventHandler(this.chkEndRoom_CheckedChanged); // // cboReference // diff --git a/UI/RoomPropertiesDialog.cs b/UI/RoomPropertiesDialog.cs index cf7814cc..a6f338a2 100644 --- a/UI/RoomPropertiesDialog.cs +++ b/UI/RoomPropertiesDialog.cs @@ -901,21 +901,6 @@ private void toolTip_BeforeTooltipDisplay(object sender, DevComponents.DotNetBar e.TooltipInfo.BodyText = e.TooltipInfo.BodyText.Replace("{gridsize}", Settings.GridSize.ToString(CultureInfo.CurrentCulture)); } - private void chkEndRoom_CheckedChanged(object sender, EventArgs e) - { - if (chkEndRoom.Checked) - { - var list = Project.Current.Elements.OfType().Where(p => p.IsEndRoom && p.ID != roomID).ToList(); - - if (list.Count <= 0) return; - - if (MessageBox.Show($"The room '{list.First().Name}' is set as the ending room. Do you want to change it to this room?", "Change Ending Room", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - Project.Current.Elements.OfType().ToList().ForEach(p => p.IsEndRoom = false); - else - chkEndRoom.Checked = false; - } - } - private void m_subTitleTextTextBox_ButtonCustomClick(object sender, EventArgs e) { RoomSubtitleColor = Color.Transparent;