/// <summary>Gets the text file content (FilePath, Text, Encoding) for a view and returns it.</summary> /// <param name="currentDocumentView">The view to extract the text file content from.</param> /// <param name="filePath"></param> /// <returns>File content of the view.</returns> private FileContentInfo GetTextResult(IDiffSideTextViewModel currentDocumentView, string filePath) { var result = new FileContentInfo(filePath); result.TextEncoding = currentDocumentView.TextEncoding; result.IsDirty = currentDocumentView.IsDirty; switch (currentDocumentView.ViewMode) { case DisplayMode.Comparing: result.TextContent = currentDocumentView.OriginalText; break; case DisplayMode.Editing: result.TextContent = currentDocumentView.Document.Text; break; default: throw new NotSupportedException(currentDocumentView.ViewMode.ToString()); } return(result); }
/// <summary>Changes the view mode for <paramref name="lastView"/> and initializes a new comparison if /// modes of <paramref name="lastView"/> and <paramref name="lastViewOther"/> reach the /// corresponding <see cref="DisplayMode.Comparing"/> state.</summary> /// <param name="viewToSwitch">True: Comparing/editing mode for view A is switched, /// False: Comparing/editing mode for view B is switched.</param> /// <param name="newMode"></param> /// <param name="lastView"></param> /// <param name="lastViewOther"></param> /// <param name="fileA"></param> /// <param name="fileB"></param> /// <param name="copyEditor2Comparing">Copy current editor content into comparing viewer /// if we switch from editing to comparing while the other side is still editing</param> /// <returns></returns> private DisplayMode ViewModeChangeCommand_Executed(bool viewToSwitch, DisplayMode newMode , IDiffSideTextViewModel lastView, IDiffSideTextViewModel lastViewOther , FileContentInfo fileA, FileContentInfo fileB , bool copyEditor2Comparing) { var retMode = DiffCtrl.SwitchViewMode(viewToSwitch, newMode, copyEditor2Comparing); // Do a recompare based on in-memory stored/edited texts string filePathA, filePathB; object[] comParams = new object[] { this.FilePathA, this.FilePathB }; if (retMode == DisplayMode.Comparing && retMode == lastViewOther.ViewMode && retMode != lastView.ViewMode && lastView.ViewMode == DisplayMode.Editing && lastViewOther.ViewMode == DisplayMode.Comparing) { if (CompareTextFilesCommand_CanExecute(comParams, out filePathA, out filePathB) == true) { CompareTextFilesCommand_Executed(filePathA, filePathB, false, fileA, fileB); } } return(retMode); }