private void UpdateOutlineChanges(ICanvasResourceCreator canvas, ITextModel leftControl, ITextModel rightControl, double controlHeight) { if (leftControl == null || rightControl == null) { return; } int lineCountOrg = leftControl.ValidLineCount; int lineCountCur = rightControl.ValidLineCount; int maxLineCount = Math.Max(lineCountOrg, lineCountCur); int singleOrgLineHeight = (int)(controlHeight / lineCountOrg); int singleCurLineHeight = (int)(controlHeight / lineCountCur); var removedGeo = new List <CanvasGeometry>(); var addedGeo = new List <CanvasGeometry>(); // Draw removals int lineNo = 0; for (int i = 0; i < leftControl.LineCount; i++) { var textLine = leftControl.GetLine(i); if (textLine is DiffTextLine diffLine) { if (diffLine.ChangeType != DiffLineType.Empty) { lineNo++; } if (diffLine.ChangeType == DiffLineType.Remove) { int ypos = (int)((double)lineNo / maxLineCount * controlHeight); removedGeo.Add(CanvasGeometry.CreateRectangle(canvas, new Rect(12.0, ypos + (int)_leftFileTop, 16.0, singleOrgLineHeight + 1))); } } } lineNo = 0; for (int i = 0; i < rightControl.LineCount; i++) { var textLine = rightControl.GetLine(i); if (textLine is DiffTextLine diffLine) { if (diffLine.ChangeType != DiffLineType.Empty) { lineNo++; } if (diffLine.ChangeType == DiffLineType.Insert) { int ypos = (int)((double)lineNo / maxLineCount * controlHeight); addedGeo.Add(CanvasGeometry.CreateRectangle(canvas, new Rect(40.0, ypos + (int)_rightFileTop, 16.0, singleCurLineHeight + 1))); } } } // Save the results into a cached geo var groupedRemovedGeo = CanvasGeometry.CreateGroup(canvas, removedGeo.ToArray()); var groupedAddedGeo = CanvasGeometry.CreateGroup(canvas, addedGeo.ToArray()); _outlineChangesRemoved = CanvasCachedGeometry.CreateFill(groupedRemovedGeo); _outlineChangesAdded = CanvasCachedGeometry.CreateFill(groupedAddedGeo); }