/// <summary> /// Closes tab /// </summary> private void OnCloseTab() { this.TabViewModels.Remove(this.SelectedTab); if (this.TabViewModels.Count > 0) { this.SelectedTab = this.TabViewModels.Last(); } else { this.SelectedTab = null; ActionTracker.ClearCommands(); } }
/// <summary> /// Attempts to close active tab /// </summary> /// <returns>False if tab closing was cancelled by user, true otherwise</returns> private bool OnCloseTab() { if (this.SelectedTab.IsDirty) { if (this.SelectedTab is TemplateViewModel) { MessageBoxResult dialogResult = DialogManager.ShowConfirmDirtyClosingDialog( "This template has unsaved changes. Do you want to save them?"); if (dialogResult == MessageBoxResult.Cancel) { // cancel closing return(false); } else if (dialogResult == MessageBoxResult.Yes) { // save this.OnSaveTemplate(); } } else if (this.SelectedTab is ResultsViewModel) { } } if (this.SelectedTab is TemplateViewModel) { ActionTracker.ClearCommands(); } this.TabViewModels.Remove(this.SelectedTab); if (this.TabViewModels.Count > 0) { this.SelectedTab = this.TabViewModels.Last(); } else { this.SelectedTab = null; } return(true); }