protected override async void OnCurrentNodeChanged(GameTreeNode newNode) { ITabInfo tabInfo = Mvx.Resolve <ITabProvider>().GetTabForViewModel(this); // This method is invoked by an event coming from Controller // If we are in the analyze mode, we want to change current node manually. if (IsAnalyzeModeEnabled) { // Notify Timeline VM that the game timeline has changed GameTreeViewModel.RaiseGameTreeChanged(); await PlaySoundIfAppropriate(newNode); tabInfo.IsBlinking = true; return; } // TODO (future work) Martin validate this hotfix // With handicap this method is fired much sooned and the ViewModel is not yet set, returning null. // Check for this case. if (newNode != null && tabInfo != null) { if (!IsTimelineInPast) { RefreshBoard(Game.Controller.GameTree.LastNode); // TODO (future work) Vita, Aniko: This will not work well with neither timeline nor analyze mode, I think } UpdateTimeline(); RefreshInstructionCaption(); // It is ABSOLUTELY necessary for this to be the last statement in this method, // because we need the UpdateTimeline calls to be in order. await PlaySoundIfAppropriate(newNode); tabInfo.IsBlinking = true; } }
/// <summary> /// Activates a given tab /// </summary> /// <param name="tab">Tab to activate</param> /// <returns>Was activation successful?</returns> public bool SwitchToTab(ITabInfo tab) { if (Tabs.Contains(tab)) { ActiveTab = (Tab)tab; return(true); } return(false); }
public void CloseTab(ITabInfo tab) => GetTabManager().CloseTab(tab);
public bool SwitchToTab(ITabInfo tab) => GetTabManager().SwitchToTab(tab);
/// <summary> /// Switches to a given tab /// </summary> /// <param name="tab">Tab to switch to</param> /// <returns>Was the switch successful?</returns> public bool SwitchToTab(ITabInfo tab) => _tabProvider.SwitchToTab(tab);
/// <summary> /// Closes a given tab /// </summary> /// <param name="tab">Tab to be closed</param> /// <returns>Was closing successful?</returns> public async void CloseTab(ITabInfo tab) { if (tab == null) { throw new ArgumentNullException(nameof(tab)); } if (!Tabs.Contains(tab)) { return; } var closedTab = (Tab)tab; if (closedTab == null) { throw new ArgumentException(nameof(tab)); } //if the tab prevents closing, do not do anything if (!await tab.CurrentViewModel.CanCloseViewModelAsync()) { return; } //the closed tab is the only tab opened if (Tabs.Count == 1) { if (closedTab.CurrentViewModel.GetType() == typeof(MainMenuViewModel)) { //shut down the app if (!await RequestAppCloseAsync()) { return; } } else { //create new main menu tab ProcessViewModelRequest( new MvxViewModelRequest(typeof(MainMenuViewModel), new MvxBundle(), new MvxBundle(), MvxRequestedBy.Unknown), TabNavigationType.NewForegroundTab ); } } else { //is the closed tab active? if (closedTab == ActiveTab) { //activate a different tab var closedTabIndex = Tabs.IndexOf(closedTab); if ((Tabs.Count - 1) > closedTabIndex) { //activate next tab ActiveTab = Tabs[closedTabIndex + 1]; } else { ActiveTab = Tabs[closedTabIndex - 1]; } } } Tabs.Remove(closedTab); //inform the view that its tab has been closed (closedTab.Frame.Content as ViewBase)?.TabClosed(); }
public GoBackPresentationHint(ITabInfo tab) { Tab = tab; }