/// <summary> /// Used to setup the ViewLineDiff view that shows only 2 lines over each other /// representing the currently active line from the left/right side views under /// each other. /// </summary> /// <param name="lineOneVM"></param> /// <param name="lineTwoVM"></param> /// <param name="spacesPerTab"></param> internal void SetData(IDiffLineViewModel lineOneVM, IDiffLineViewModel lineTwoVM, int spacesPerTab) { _spacesPerTab = spacesPerTab; var documentLineDiffs = new List <IDiffLineViewModel>(); string text = string.Empty; if (lineOneVM != null && lineOneVM.LineEditScriptSegmentsIsDirty == true) { lineOneVM.GetChangeEditScript(this.ChangeDiffOptions, spacesPerTab); } if (lineTwoVM != null && lineTwoVM.LineEditScriptSegmentsIsDirty == true) { lineTwoVM.GetChangeEditScript(this.ChangeDiffOptions, spacesPerTab); } if (lineOneVM != null && lineTwoVM != null) { documentLineDiffs.Add(lineOneVM); text += lineOneVM.Text + '\n'; documentLineDiffs.Add(lineTwoVM); text += lineTwoVM.Text + "\n"; } text = text.Replace("\t", " "); // Update LineInfo viewmodels _DocLineDiffs.Clear(); _DocLineDiffs.AddRange(documentLineDiffs, NotifyCollectionChangedAction.Reset); // Update text document Document = new TextDocument(text); NotifyPropertyChanged(() => DocLineDiffs); NotifyPropertyChanged(() => Document); }
/// <summary> /// Update the 2 line display (ViewLineDiff) that contains the display /// of the currently selected line in 2 rows rather than side by side. /// </summary> private void UpdateViewLineDiff(int spacesPerTab) { // Determine zero based current cursor position in line n int line = Math.Max(0, SynchronizedLine - 1); if (line == this.currentDiffLine) { return; } this.currentDiffLine = line; IDiffLineViewModel lineOneVM = null; IDiffLineViewModel lineTwoVM = null; lineOneVM = (this.ViewA as DiffSideViewModel).GetLine(line); lineTwoVM = (this.ViewB as DiffSideViewModel).GetLine(line); if (lineOneVM != null && lineTwoVM != null) { this._ViewLineDiff.SetData(lineOneVM, lineTwoVM, spacesPerTab); } }