/// <summary> /// Sets the entire control enablement etc /// </summary> private void SetQuickFinderCore(DetailsCommand command) { if (!command.SubLayout) { switch (command.UnderlyingDisplay) { case DetailsDisplayEnum.Village: SelectedVillage.Village = command.Village; break; case DetailsDisplayEnum.Player: SelectedVillage.Player = command.Player; break; case DetailsDisplayEnum.Tribe: SelectedVillage.Tribe = command.Tribe; break; default: SelectedVillage.PlayerTribeSelector.Clear(); break; } } SetLayout(command); _current = command; }
/// <summary> /// Create a new command with the same underlying display /// </summary> /// <param name="previous">The previous command</param> /// <param name="display">The new display</param> public DetailsCommand(DetailsCommand previous, DetailsDisplayEnum display) { Tooltip = previous.Tooltip; Village = previous.Village; Player = previous.Player; Tribe = previous.Tribe; UnderlyingDisplay = display; Display = display; Tool = VillageTools.SelectVillage; SubLayout = true; }
/// <summary> /// Create a new command with the same underlying display /// </summary> /// <param name="previous">The previous command</param> /// <param name="display">The new display</param> public DetailsCommand(DetailsCommand previous, DetailsDisplayEnum display) { Tooltip = previous.Tooltip; Village = previous.Village; Player = previous.Player; Tribe = previous.Tribe; UnderlyingDisplay = display; Display = display; Tool = VillageTools.SelectVillage; SubLayout = true; }
/// <summary> /// Prepares the user control for viewing /// </summary> /// <param name="command">Encapsulates a view in the DetailsControl</param> private void SetQuickFinder(DetailsCommand command) { if (command.Tool == VillageTools.PinPoint) { _redo = new Stack <DetailsCommand>(); RedoButton.Enabled = false; _undo.Push(_current); UndoButton.Enabled = true; UndoButton.ToolTipText = _current.Tooltip; } SetQuickFinderCore(command); }
/// <summary> /// Undo or Redo /// </summary> private void UndoRedo(Stack <DetailsCommand> pop, ToolStripButton popButton, Stack <DetailsCommand> push, ToolStripButton pushButton) { if (pop.Count > 0) { DetailsCommand command = pop.Pop(); push.Push(_current); pushButton.Enabled = true; pushButton.ToolTipText = _current.Tooltip; SetQuickFinderCore(command); } // can we undo/redo more if (pop.Count == 0) { popButton.Enabled = false; } else { popButton.ToolTipText = pop.Peek().Tooltip; } World.Default.Map.EventPublisher.SelectVillages(this, _current.Village, VillageTools.PinPoint); }
/// <summary> /// Changes the display without changing the /// current selected village, player or tribe /// </summary> private void SetLayout(DetailsCommand command) { ViewVillageDetails.Enabled = command.Village != null; ViewTribeDetails.Enabled = command.Tribe != null; ViewPlayerDetails.Enabled = command.Player != null; switch (command.Display) { case DetailsDisplayEnum.Player: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = true; MarkPlayerOrTribe.SetMarker(command.Player); ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = true; ViewTribeDetails.Checked = false; //SpecialVillage.Visible = false; Table.Visible = true; CommentsLabel.Visible = false; Comments.Visible = false; CommentsPanel.Visible = false; if (command.Display != _current.Display || command.Player != _current.Player) { Table.DisplayVillages(command.Player); DetailsGrid.SelectedObject = new ExtendedPlayerDescriptor(command.Player); } if (command.Village != null) { World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); } else { World.Default.Map.EventPublisher.SelectVillages(null, command.Player, VillageTools.Notes); } break; case DetailsDisplayEnum.Tribe: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = true; MarkPlayerOrTribe.SetMarker(command.Tribe); ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = true; //SpecialVillage.Visible = false; Table.Visible = true; CommentsLabel.Visible = false; Comments.Visible = false; CommentsPanel.Visible = false; if (command.Display != _current.Display || command.Tribe != _current.Tribe) { Table.DisplayPlayers(command.Tribe.Players); DetailsGrid.SelectedObject = new ExtendedTribeDescriptor(command.Tribe); } if (command.Village != null) { World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); } else if (command.Player != null) { World.Default.Map.EventPublisher.SelectVillages(null, command.Player, VillageTools.Notes); } else { World.Default.Map.EventPublisher.SelectVillages(null, command.Tribe, VillageTools.Notes); } break; case DetailsDisplayEnum.Village: ContextStrip.Visible = true; MarkPlayerOrTribe.Visible = false; ViewVillageDetails.Checked = true; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = false; //SpecialVillage.Visible = true; Table.Visible = false; CommentsLabel.Visible = true; Comments.Visible = true; CommentsPanel.Visible = true; CommentsLabel.Text = string.Format(FormRes.DetailsControl_CustomCommentsForVillage, command.Village.LocationString); //SpecialVillage.SetReport(command.Village.Reports.CurrentSituation); DetailsGrid.SelectedObject = new ExtendedVillageDescriptor(command.Village); Table.DisplayReports(command.Village, command.Village.Reports); SetButtons(command.Village.Type); _current = command; // HACK: The textchanged eventhandler of comments would overwrite the old village comment with the new one Comments.Text = command.Village.Comments; World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); break; default: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = false; ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = false; DetailsGrid.SelectedObject = null; Table.Clear(); break; } }
/// <summary> /// Sets the entire control enablement etc /// </summary> private void SetQuickFinderCore(DetailsCommand command) { if (!command.SubLayout) { switch (command.UnderlyingDisplay) { case DetailsDisplayEnum.Village: SelectedVillage.Village = command.Village; break; case DetailsDisplayEnum.Player: SelectedVillage.Player = command.Player; break; case DetailsDisplayEnum.Tribe: SelectedVillage.Tribe = command.Tribe; break; default: SelectedVillage.PlayerTribeSelector.Clear(); break; } } SetLayout(command); _current = command; }
/// <summary> /// Prepares the user control for viewing /// </summary> /// <param name="command">Encapsulates a view in the DetailsControl</param> private void SetQuickFinder(DetailsCommand command) { if (command.Tool == VillageTools.PinPoint) { _redo = new Stack<DetailsCommand>(); RedoButton.Enabled = false; _undo.Push(_current); UndoButton.Enabled = true; UndoButton.ToolTipText = _current.Tooltip; } SetQuickFinderCore(command); }
/// <summary> /// Changes the display without changing the /// current selected village, player or tribe /// </summary> private void SetLayout(DetailsCommand command) { ViewVillageDetails.Enabled = command.Village != null; ViewTribeDetails.Enabled = command.Tribe != null; ViewPlayerDetails.Enabled = command.Player != null; switch (command.Display) { case DetailsDisplayEnum.Player: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = true; MarkPlayerOrTribe.SetMarker(command.Player); ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = true; ViewTribeDetails.Checked = false; //SpecialVillage.Visible = false; Table.Visible = true; CommentsLabel.Visible = false; Comments.Visible = false; CommentsPanel.Visible = false; if (command.Display != _current.Display || command.Player != _current.Player) { Table.DisplayVillages(command.Player); DetailsGrid.SelectedObject = new ExtendedPlayerDescriptor(command.Player); } if (command.Village != null) World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); else World.Default.Map.EventPublisher.SelectVillages(null, command.Player, VillageTools.Notes); break; case DetailsDisplayEnum.Tribe: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = true; MarkPlayerOrTribe.SetMarker(command.Tribe); ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = true; //SpecialVillage.Visible = false; Table.Visible = true; CommentsLabel.Visible = false; Comments.Visible = false; CommentsPanel.Visible = false; if (command.Display != _current.Display || command.Tribe != _current.Tribe) { Table.DisplayPlayers(command.Tribe.Players); DetailsGrid.SelectedObject = new ExtendedTribeDescriptor(command.Tribe); } if (command.Village != null) World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); else if (command.Player != null) World.Default.Map.EventPublisher.SelectVillages(null, command.Player, VillageTools.Notes); else World.Default.Map.EventPublisher.SelectVillages(null, command.Tribe, VillageTools.Notes); break; case DetailsDisplayEnum.Village: ContextStrip.Visible = true; MarkPlayerOrTribe.Visible = false; ViewVillageDetails.Checked = true; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = false; //SpecialVillage.Visible = true; Table.Visible = false; CommentsLabel.Visible = true; Comments.Visible = true; CommentsPanel.Visible = true; CommentsLabel.Text = "Custom comments for " + command.Village.LocationString; //SpecialVillage.SetReport(command.Village.Reports.CurrentSituation); DetailsGrid.SelectedObject = new ExtendedVillageDescriptor(command.Village); Table.DisplayReports(command.Village, command.Village.Reports); SetButtons(command.Village.Type); _current = command; // HACK: The textchanged eventhandler of comments would overwrite the old village comment with the new one Comments.Text = command.Village.Comments; World.Default.Map.EventPublisher.SelectVillages(null, command.Village, VillageTools.Notes); break; default: ContextStrip.Visible = false; MarkPlayerOrTribe.Visible = false; ViewVillageDetails.Checked = false; ViewPlayerDetails.Checked = false; ViewTribeDetails.Checked = false; DetailsGrid.SelectedObject = null; Table.Clear(); break; } }