private void OnDeleteAllEditorTabsRequested(object sender, DeleteAllEditorTabsRequestedArg arg) { MessageBoxResult result = GherkinSettings.SaveAllFilesWithRequesting(arg.ExcludedEditorViewModel); if (result == MessageBoxResult.Cancel) { return; } SelectedTabIndex = TabPanels.Count - 1; // Note: Select last tab to force to notify SelectedTabIndex property changed event if (arg.ExcludedEditorViewModel == null) { for (int i = TabPanels.Count - 1; i > 0; i--) { EventAggregator <EditorClosedArg> .Instance.Publish(this, new EditorClosedArg(TabPanels[i].EditorTabContentViewModel.CurrentFilePath)); TabPanels.RemoveAt(i); } TabPanels[0].EditorTabContentViewModel.ChangeToEmptyFile(); } else { for (int i = TabPanels.Count - 1; i >= 0; i--) { if (TabPanels[i].EditorTabContentViewModel != arg.ExcludedEditorViewModel) { EventAggregator <EditorClosedArg> .Instance.Publish(this, new EditorClosedArg(TabPanels[i].EditorTabContentViewModel.CurrentFilePath)); TabPanels.RemoveAt(i); } } } SelectedTabIndex = 0; }
private bool ConfirmSaveFeatureFile() { if (CurrentFilePath == "") { if (GherkinSettings.SaveCurrentFileWithRequesting(CurrentEditor) == MessageBoxResult.Cancel) { return(false); } } if (CurrentFilePath == "") { MessageBox.Show(Properties.Resources.Message_SaveFileBeforeGenCode, Properties.Resources.Message_SaveFileBeforeGenCodeTitle, MessageBoxButton.OK, MessageBoxImage.Error); return(false); } return(true); }
private void OnDeleteEditorTab(object sender, DeleteEditorTabRequestedArg arg) { EditorTabContentViewModel editorViewModel = arg.EditorViewModel; MessageBoxResult result = GherkinSettings.SaveCurrentFileWithRequesting(editorViewModel); if (result == MessageBoxResult.Cancel) { return; } EventAggregator <EditorClosedArg> .Instance.Publish(this, new EditorClosedArg(editorViewModel.CurrentFilePath)); if (TabPanels.Count == 1) { CurrentEditor?.ChangeToEmptyFile(); NotifyCurrentFilePathChanged(); base.OnPropertyChanged(nameof(IsShowScenarioIndexEnabled)); } else { EditorTabItem editorTab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel == editorViewModel); int index = TabPanels.IndexOf(editorTab); bool isDeletingCurrentTab = (index == SelectedTabIndex); if (isDeletingCurrentTab) { // Force select a tab before removing tab. // Note: property changed notification would not be raised if index is same as SelectedTabIndex. // Therefore we select another tab at first and then select agian the indexed tab if index == SelectedTabIndex int other_index = (index + 1) % TabPanels.Count; SelectedTabIndex = other_index; } TabPanels.Remove(editorTab); if (isDeletingCurrentTab) { SelectedTabIndex = Math.Min(index, TabPanels.Count - 1); } } }
public MessageBoxResult SaveAllFilesWithRequesting() { return(GherkinSettings.SaveAllFilesWithRequesting(excluded: null)); }