Ejemplo n.º 1
0
        // Token: 0x06002B52 RID: 11090 RVA: 0x000C5F74 File Offset: 0x000C4174
        internal void InvalidateAdorner()
        {
            for (int i = 0; i < this._attributeRanges.Count; i++)
            {
                CompositionAdorner.AttributeRange attributeRange = (CompositionAdorner.AttributeRange) this._attributeRanges[i];
                attributeRange.AddCompositionLines();
            }
            AdornerLayer adornerLayer = VisualTreeHelper.GetParent(this) as AdornerLayer;

            if (adornerLayer != null)
            {
                adornerLayer.Update(base.AdornedElement);
                adornerLayer.InvalidateArrange();
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06002B50 RID: 11088 RVA: 0x000C5AA8 File Offset: 0x000C3CA8
        protected override void OnRender(DrawingContext drawingContext)
        {
            Visual visual = VisualTreeHelper.GetParent(base.AdornedElement) as Visual;

            if (visual == null)
            {
                return;
            }
            GeneralTransform generalTransform = base.AdornedElement.TransformToAncestor(visual);

            if (generalTransform == null)
            {
                return;
            }
            bool flag = "zh-CN".Equals(InputLanguageManager.Current.CurrentInputLanguage.IetfLanguageTag);

            for (int i = 0; i < this._attributeRanges.Count; i++)
            {
                CompositionAdorner.AttributeRange attributeRange = (CompositionAdorner.AttributeRange) this._attributeRanges[i];
                if (attributeRange.CompositionLines.Count != 0)
                {
                    bool   isBoldLine = attributeRange.TextServicesDisplayAttribute.IsBoldLine;
                    bool   flag2      = false;
                    bool   flag3      = (attributeRange.TextServicesDisplayAttribute.AttrInfo & UnsafeNativeMethods.TF_DA_ATTR_INFO.TF_ATTR_TARGET_CONVERTED) > UnsafeNativeMethods.TF_DA_ATTR_INFO.TF_ATTR_INPUT;
                    Brush  brush      = null;
                    double opacity    = -1.0;
                    Pen    pen        = null;
                    if (flag && flag3)
                    {
                        DependencyObject parent = this._textView.TextContainer.Parent;
                        brush   = (Brush)parent.GetValue(TextBoxBase.SelectionBrushProperty);
                        opacity = (double)parent.GetValue(TextBoxBase.SelectionOpacityProperty);
                    }
                    double height = attributeRange.Height;
                    double num    = height * (isBoldLine ? 0.08 : 0.06);
                    double num2   = height * 0.09;
                    Pen    pen2   = new Pen(new SolidColorBrush(Colors.Black), num);
                    switch (attributeRange.TextServicesDisplayAttribute.LineStyle)
                    {
                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID:
                        pen2.StartLineCap = PenLineCap.Round;
                        pen2.EndLineCap   = PenLineCap.Round;
                        break;

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DOT:
                        pen2.DashStyle = new DashStyle(new DoubleCollection
                        {
                            1.2,
                            1.2
                        }, 0.0);
                        pen2.DashCap      = PenLineCap.Round;
                        pen2.StartLineCap = PenLineCap.Round;
                        pen2.EndLineCap   = PenLineCap.Round;
                        num = height * (isBoldLine ? 0.1 : 0.08);
                        break;

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DASH:
                    {
                        double value  = height * (isBoldLine ? 0.39 : 0.27);
                        double value2 = height * (isBoldLine ? 0.06 : 0.04);
                        pen2.DashStyle = new DashStyle(new DoubleCollection
                            {
                                value,
                                value2
                            }, 0.0);
                        pen2.DashCap      = PenLineCap.Round;
                        pen2.StartLineCap = PenLineCap.Round;
                        pen2.EndLineCap   = PenLineCap.Round;
                        break;
                    }

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SQUIGGLE:
                        flag2 = true;
                        break;
                    }
                    double num3 = num / 2.0;
                    for (int j = 0; j < attributeRange.CompositionLines.Count; j++)
                    {
                        CompositionAdorner.CompositionLine compositionLine = (CompositionAdorner.CompositionLine)attributeRange.CompositionLines[j];
                        Point point  = new Point(compositionLine.StartPoint.X + num2, compositionLine.StartPoint.Y - num3);
                        Point point2 = new Point(compositionLine.EndPoint.X - num2, compositionLine.EndPoint.Y - num3);
                        pen2.Brush = new SolidColorBrush(compositionLine.LineColor);
                        generalTransform.TryTransform(point, out point);
                        generalTransform.TryTransform(point2, out point2);
                        if (flag && flag3)
                        {
                            Rect rect = Rect.Union(compositionLine.StartRect, compositionLine.EndRect);
                            rect = generalTransform.TransformBounds(rect);
                            drawingContext.PushOpacity(opacity);
                            drawingContext.DrawRectangle(brush, pen, rect);
                            drawingContext.Pop();
                        }
                        if (flag2)
                        {
                            Point      point3     = new Point(point.X, point.Y - num3);
                            double     num4       = num3;
                            PathFigure pathFigure = new PathFigure();
                            pathFigure.StartPoint = point3;
                            int num5 = 0;
                            while ((double)num5 < (point2.X - point.X) / num4)
                            {
                                if (num5 % 4 == 0 || num5 % 4 == 3)
                                {
                                    point3 = new Point(point3.X + num4, point3.Y + num3);
                                    pathFigure.Segments.Add(new LineSegment(point3, true));
                                }
                                else if (num5 % 4 == 1 || num5 % 4 == 2)
                                {
                                    point3 = new Point(point3.X + num4, point3.Y - num3);
                                    pathFigure.Segments.Add(new LineSegment(point3, true));
                                }
                                num5++;
                            }
                            drawingContext.DrawGeometry(null, pen2, new PathGeometry
                            {
                                Figures =
                                {
                                    pathFigure
                                }
                            });
                        }
                        else
                        {
                            drawingContext.DrawLine(pen2, point, point2);
                        }
                    }
                }
            }
        }