private void OpenGreppedFile(MultiFileOpener multiFilesOpener, string grepLine) { m_MultiFilesOpener = multiFilesOpener; Tuple <string, int> fileNameAndLineNo = TryGetFileNameAndLineNo(grepLine); GreppedLineNo = fileNameAndLineNo.Item2; if (!File.Exists(fileNameAndLineNo.Item1)) { return; } var tab = m_MultiFilesOpener.OpenEditorTab(fileNameAndLineNo.Item1); m_GreppedFileEditorViewModel = tab.Item2.EditorTabContentViewModel; if (tab.Item1) { // new editor created so that we need to wait EditorLoadeded event to finish work EventAggregator <EditorLoadedArg> .Instance.Event += OnGrepEditorLoaded; } else { // directly move cursor because the text editor has been loaded ScrollCursorToLine(GreppedLineNo); } }
private void OnSave() { if (EditorTabContentViewModel.IsModified) { EditorTabContentViewModel.SaveFile(saveAs: false); } }
public EditorTabHeaderViewModel(EditorTabContentViewModel editorTabContentViewModel, ICanCloseAllDocumentsChecker canCloseAllDocumentsChecker) { EditorTabContentViewModel = editorTabContentViewModel; m_FilePath = editorTabContentViewModel.CurrentFilePath; CanCloseAllDocumentsChecker = canCloseAllDocumentsChecker; EditorTabContentViewModel.TextEditorLoadedEvent += OnTextEditorLoaded; EditorTabContentViewModel.FileNameChangedEvent += OnFileNameChanged; EditorTabContentViewModel.DocumentSavedEvent += OnDocumentSaved; }
public MessageBoxResult SaveAllFilesWithRequesting(EditorTabContentViewModel excluded) { if (IsChangingLanguage) { return(MessageBoxResult.Yes); } foreach (EditorTabItem tab in TabPanels) { if (tab.EditorTabContentViewModel != excluded) { MessageBoxResult result = SaveCurrentFileWithRequesting(tab.EditorTabContentViewModel); if (result == MessageBoxResult.Cancel) { return(result); } } } return(MessageBoxResult.Yes); }
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 SaveAsDocumentRequestedArg(EditorTabContentViewModel tabContentViewModel) { SourceTabContentViewModel = tabContentViewModel; }
public DeleteAllEditorTabsRequestedArg(EditorTabContentViewModel excludedEditorViewModel) { ExcludedEditorViewModel = excludedEditorViewModel; }
public EditorLoadedArg(EditorTabContentViewModel viewModel) { m_ViewModel = viewModel; }
public MessageBoxResult SaveCurrentFileWithRequesting(EditorTabContentViewModel editor) { return(editor.SaveCurrentFileWithRequesting()); }
public DeleteEditorTabRequestedArg(EditorTabContentViewModel editorViewModel) { EditorViewModel = editorViewModel; }
private bool CanClearSearchHighlighting() { return(EditorTabContentViewModel.HasSearchHighlightingTransformer()); }
private void OnClearSearchHighlighting() { EditorTabContentViewModel.ClearSearchHighlighting(); }
private void SaveFile(EditorTabContentViewModel editor, bool saveAs) { editor.SaveFile(saveAs); NotifyCurrentFilePathChanged(); }