Пример #1
0
        /// <summary>
        /// Create and return visual node for the line.
        /// </summary>
        internal TextBoxLineDrawingVisual CreateVisual()
        {
            TextBoxLineDrawingVisual visual = new TextBoxLineDrawingVisual();

            // Calculate shift in line offset to render trailing spaces or avoid clipping text.
            double         delta = CalculateXOffsetShift();
            DrawingContext ctx   = visual.RenderOpen();

            _line.Draw(ctx, new Point(delta, 0), ((_lineProperties.FlowDirection == FlowDirection.RightToLeft) ? InvertAxes.Horizontal : InvertAxes.None));
            ctx.Close();

            return(visual);
        }
Пример #2
0
        /// <summary>
        /// Create and return visual node for the line.
        /// </summary>
        internal TextBoxLineDrawingVisual CreateVisual(Geometry selectionGeometry)
        {
            TextBoxLineDrawingVisual visual = new TextBoxLineDrawingVisual();

            // Calculate shift in line offset to render trailing spaces or avoid clipping text.
            double         delta = CalculateXOffsetShift();
            DrawingContext ctx   = visual.RenderOpen();

            if (selectionGeometry != null)
            {
                var uiScope = _owner?.Host?.TextContainer?.TextSelection?.TextEditor?.UiScope;

                if (uiScope != null)
                {
                    Brush selectionBrush = uiScope.GetValue(TextBoxBase.SelectionBrushProperty) as Brush;

                    if (selectionBrush != null)
                    {
                        double selectionBrushOpacity = (double)uiScope.GetValue(TextBoxBase.SelectionOpacityProperty);

                        ctx.PushOpacity(selectionBrushOpacity);

                        // We use a Pen created from the brush used for the selection with a default thickness.
                        // This fixes issues where the geometries for the independent selection do not overlap
                        // and gaps can be seen to the background of the control between selection geometries.
                        ctx.DrawGeometry(selectionBrush, new Pen()
                        {
                            Brush = selectionBrush
                        }, selectionGeometry);

                        ctx.Pop();
                    }
                }
            }

            _line.Draw(ctx, new Point(delta, 0), ((_lineProperties.FlowDirection == FlowDirection.RightToLeft) ? InvertAxes.Horizontal : InvertAxes.None));
            ctx.Close();

            return(visual);
        }
Пример #3
0
        /// <summary>
        /// Create and return visual node for the line. 
        /// </summary>
        internal TextBoxLineDrawingVisual CreateVisual()
        {
            TextBoxLineDrawingVisual visual = new TextBoxLineDrawingVisual();

            // Calculate shift in line offset to render trailing spaces or avoid clipping text.
            double delta = CalculateXOffsetShift();
            DrawingContext ctx = visual.RenderOpen();
            _line.Draw(ctx, new Point(delta, 0), ((_lineProperties.FlowDirection == FlowDirection.RightToLeft) ? InvertAxes.Horizontal : InvertAxes.None));
            ctx.Close();

            return visual;
        }
Пример #4
0
 // Adds a Visual to the line Visuals cache.
 private void SetLineVisual(int lineIndex, TextBoxLineDrawingVisual lineVisual)
 {
     if (_viewportLineVisuals != null)
     {
         _viewportLineVisuals[lineIndex - _viewportLineVisualsIndex] = lineVisual;
     }
 }
Пример #5
0
 // Adds a line visual to the visual tree.
 private void AttachVisualChild(TextBoxLineDrawingVisual lineVisual)
 {
     AddVisualChild(lineVisual);
     _visualChildren.Add(lineVisual);
 }
Пример #6
0
 // Adds a line visual to the visual tree.
 private void AttachVisualChild(TextBoxLineDrawingVisual lineVisual)
 {
     // Ideally we should add visual to a collection before calling AddVisualChild.
     // So that VisualDiagnostics.OnVisualChildChanged can get correct child index.
     // However it is not clear what can regress. We'll use _parentIndex.
     // Note that there is a comment in Visual.cs stating that _parentIndex should
     // be set to -1 in DEBUG builds when child is removed. We are not going to 
     // honor it. There is no _parentIndex == -1 validation is performed anywhere.
     lineVisual._parentIndex = _visualChildren.Count;
     AddVisualChild(lineVisual);
     _visualChildren.Add(lineVisual);
 }
        // Token: 0x06004135 RID: 16693 RVA: 0x0012A278 File Offset: 0x00128478
        internal TextBoxLineDrawingVisual CreateVisual(Geometry selectionGeometry)
        {
            TextBoxLineDrawingVisual textBoxLineDrawingVisual = new TextBoxLineDrawingVisual();
            double         x = this.CalculateXOffsetShift();
            DrawingContext drawingContext = textBoxLineDrawingVisual.RenderOpen();

            if (selectionGeometry != null)
            {
                TextBoxView      owner = this._owner;
                FrameworkElement frameworkElement;
                if (owner == null)
                {
                    frameworkElement = null;
                }
                else
                {
                    ITextBoxViewHost host = owner.Host;
                    if (host == null)
                    {
                        frameworkElement = null;
                    }
                    else
                    {
                        ITextContainer textContainer = host.TextContainer;
                        if (textContainer == null)
                        {
                            frameworkElement = null;
                        }
                        else
                        {
                            ITextSelection textSelection = textContainer.TextSelection;
                            if (textSelection == null)
                            {
                                frameworkElement = null;
                            }
                            else
                            {
                                TextEditor textEditor = textSelection.TextEditor;
                                frameworkElement = ((textEditor != null) ? textEditor.UiScope : null);
                            }
                        }
                    }
                }
                FrameworkElement frameworkElement2 = frameworkElement;
                if (frameworkElement2 != null)
                {
                    Brush brush = frameworkElement2.GetValue(TextBoxBase.SelectionBrushProperty) as Brush;
                    if (brush != null)
                    {
                        double opacity = (double)frameworkElement2.GetValue(TextBoxBase.SelectionOpacityProperty);
                        drawingContext.PushOpacity(opacity);
                        drawingContext.DrawGeometry(brush, new Pen
                        {
                            Brush = brush
                        }, selectionGeometry);
                        drawingContext.Pop();
                    }
                }
            }
            this._line.Draw(drawingContext, new Point(x, 0.0), (this._lineProperties.FlowDirection == FlowDirection.RightToLeft) ? InvertAxes.Horizontal : InvertAxes.None);
            drawingContext.Close();
            return(textBoxLineDrawingVisual);
        }