Skip to content

Commit

Permalink
change: change the room properties by removing warning about multiple…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
JasonLautzenheiser authored Mar 22, 2018
1 parent f25eb66 commit 807dedc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
9 changes: 6 additions & 3 deletions UI/Controls/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public Element SelectedElement

public bool HasSingleSelectedElement => SelectedElementCount == 1;

public bool HasSelectedRooms => mSelectedElements.OfType<Room>().Any();
public bool HasSingleSelectedRoom => mSelectedElements.OfType<Room>().Count() == 1;

public IList<Element> SelectedElements => mSelectedElements;

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions UI/RoomPropertiesDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions UI/RoomPropertiesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Room>().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<Room>().ToList().ForEach(p => p.IsEndRoom = false);
else
chkEndRoom.Checked = false;
}
}

private void m_subTitleTextTextBox_ButtonCustomClick(object sender, EventArgs e)
{
RoomSubtitleColor = Color.Transparent;
Expand Down

0 comments on commit 807dedc

Please sign in to comment.