private static void DrawContentDiff(DiffTextEditorHelper.PerLineDrawArgs args)
        {
            if (args.DiffLine.ContentDiffs == null)
                return;

            var brush = args.DiffLine.LineType == DiffLine.LineTypes.Add
                ? Constants.HighlightAddBackground
                : Constants.HighlightRemoveBackground;

            args.DiffLine.ContentDiffs.SelectMany(d =>
                BackgroundGeometryBuilder.GetRectsFromVisualSegment(
                    args.TextView,
                    args.VisualLine,
                    d.StartIndex,
                    d.EndIndex)
                )
                .ForEach(r =>
                {
                    using(new GuidelineSetBlock(args.DrawingContext, r))
                        args.DrawingContext.DrawRectangle(brush, null, r);
                });
        }
Exemplo n.º 2
0
 private static void DrawForegroundLeft(DiffTextEditorHelper.PerLineDrawArgs args)
 {
     if (args.Index == 0)
         DrawIndex(args.DrawingContext, args.Rect, args.DiffLine);
 }
Exemplo n.º 3
0
        private static void DrawForeground(DiffTextEditorHelper.PerLineDrawArgs args)
        {
            if (_gridPen == null)
            {
                var presentationSource = PresentationSource.FromVisual(args.TextView);
                if (presentationSource?.CompositionTarget != null)
                {
                    var m = presentationSource.CompositionTarget.TransformToDevice;
                    _gridPen = new Pen(Constants.FrameBrush, 1 / m.M11);   // 物理ピクセルで1
                    _gridPen.Freeze();
                }

                Debug.Assert(_gridPen != null);
            }

            var halfPenWidth = _gridPen.Thickness * 0.5;

            using (new GuidelineSetBlock(
                args.DrawingContext,
                xGuides: new[]
                {
                    NewIndexOffset + halfPenWidth,
                    LineTypeIndexOffset + halfPenWidth
                }))
            {
                args.DrawingContext.DrawLine(
                    _gridPen,
                    new Point(NewIndexOffset, args.Rect.Top - 1),
                    new Point(NewIndexOffset, args.Rect.Bottom + 1));

                args.DrawingContext.DrawLine(
                    _gridPen,
                    new Point(LineTypeIndexOffset, args.Rect.Top - 1),
                    new Point(LineTypeIndexOffset, args.Rect.Bottom + 1));
            }

            if (args.Index == 0)
                DrawFileTypeMark(args.DrawingContext, args.Rect, args.DiffLine);
        }