示例#1
0
        internal static Size ComputeScaleFactor(Size availableSize, Size contentSize, Stretch stretch, StretchDirection stretchDirection)
        {
            double num   = 1.0;
            double num2  = 1.0;
            bool   flag  = !double.IsPositiveInfinity(availableSize.Width);
            bool   flag2 = !double.IsPositiveInfinity(availableSize.Height);

            if ((stretch == Stretch.Uniform || stretch == Stretch.UniformToFill || stretch == Stretch.Fill) && (flag | flag2))
            {
                num  = (DoubleUtil.IsZero(contentSize.Width) ? 0.0 : (availableSize.Width / contentSize.Width));
                num2 = (DoubleUtil.IsZero(contentSize.Height) ? 0.0 : (availableSize.Height / contentSize.Height));
                if (!flag)
                {
                    num = num2;
                }
                else if (!flag2)
                {
                    num2 = num;
                }
                else
                {
                    switch (stretch)
                    {
                    case Stretch.Uniform:
                        num2 = (num = ((num < num2) ? num : num2));
                        break;

                    case Stretch.UniformToFill:
                        num2 = (num = ((num > num2) ? num : num2));
                        break;
                    }
                }
                switch (stretchDirection)
                {
                case StretchDirection.UpOnly:
                    if (num < 1.0)
                    {
                        num = 1.0;
                    }
                    if (num2 < 1.0)
                    {
                        num2 = 1.0;
                    }
                    break;

                case StretchDirection.DownOnly:
                    if (num > 1.0)
                    {
                        num = 1.0;
                    }
                    if (num2 > 1.0)
                    {
                        num2 = 1.0;
                    }
                    break;
                }
            }
            return(new Size(num, num2));
        }
示例#2
0
文件: Border.cs 项目: beda2280/wpf-1
            internal Radii(CornerRadius radii, Thickness borders, bool outer)
            {
                double left   = 0.5 * borders.Left;
                double top    = 0.5 * borders.Top;
                double right  = 0.5 * borders.Right;
                double bottom = 0.5 * borders.Bottom;

                if (outer)
                {
                    if (DoubleUtil.IsZero(radii.TopLeft))
                    {
                        LeftTop = TopLeft = 0.0;
                    }
                    else
                    {
                        LeftTop = radii.TopLeft + left;
                        TopLeft = radii.TopLeft + top;
                    }
                    if (DoubleUtil.IsZero(radii.TopRight))
                    {
                        TopRight = RightTop = 0.0;
                    }
                    else
                    {
                        TopRight = radii.TopRight + top;
                        RightTop = radii.TopRight + right;
                    }
                    if (DoubleUtil.IsZero(radii.BottomRight))
                    {
                        RightBottom = BottomRight = 0.0;
                    }
                    else
                    {
                        RightBottom = radii.BottomRight + right;
                        BottomRight = radii.BottomRight + bottom;
                    }
                    if (DoubleUtil.IsZero(radii.BottomLeft))
                    {
                        BottomLeft = LeftBottom = 0.0;
                    }
                    else
                    {
                        BottomLeft = radii.BottomLeft + bottom;
                        LeftBottom = radii.BottomLeft + left;
                    }
                }
                else
                {
                    LeftTop     = Math.Max(0.0, radii.TopLeft - left);
                    TopLeft     = Math.Max(0.0, radii.TopLeft - top);
                    TopRight    = Math.Max(0.0, radii.TopRight - top);
                    RightTop    = Math.Max(0.0, radii.TopRight - right);
                    RightBottom = Math.Max(0.0, radii.BottomRight - right);
                    BottomRight = Math.Max(0.0, radii.BottomRight - bottom);
                    BottomLeft  = Math.Max(0.0, radii.BottomLeft - bottom);
                    LeftBottom  = Math.Max(0.0, radii.BottomLeft - left);
                }
            }
            // Token: 0x06008725 RID: 34597 RVA: 0x0024EDC4 File Offset: 0x0024CFC4
            internal Radii(CornerRadius radii, Thickness borders, bool outer)
            {
                double num  = 0.5 * borders.Left;
                double num2 = 0.5 * borders.Top;
                double num3 = 0.5 * borders.Right;
                double num4 = 0.5 * borders.Bottom;

                if (!outer)
                {
                    this.LeftTop     = Math.Max(0.0, radii.TopLeft - num);
                    this.TopLeft     = Math.Max(0.0, radii.TopLeft - num2);
                    this.TopRight    = Math.Max(0.0, radii.TopRight - num2);
                    this.RightTop    = Math.Max(0.0, radii.TopRight - num3);
                    this.RightBottom = Math.Max(0.0, radii.BottomRight - num3);
                    this.BottomRight = Math.Max(0.0, radii.BottomRight - num4);
                    this.BottomLeft  = Math.Max(0.0, radii.BottomLeft - num4);
                    this.LeftBottom  = Math.Max(0.0, radii.BottomLeft - num);
                    return;
                }
                if (DoubleUtil.IsZero(radii.TopLeft))
                {
                    this.LeftTop = (this.TopLeft = 0.0);
                }
                else
                {
                    this.LeftTop = radii.TopLeft + num;
                    this.TopLeft = radii.TopLeft + num2;
                }
                if (DoubleUtil.IsZero(radii.TopRight))
                {
                    this.TopRight = (this.RightTop = 0.0);
                }
                else
                {
                    this.TopRight = radii.TopRight + num2;
                    this.RightTop = radii.TopRight + num3;
                }
                if (DoubleUtil.IsZero(radii.BottomRight))
                {
                    this.RightBottom = (this.BottomRight = 0.0);
                }
                else
                {
                    this.RightBottom = radii.BottomRight + num3;
                    this.BottomRight = radii.BottomRight + num4;
                }
                if (DoubleUtil.IsZero(radii.BottomLeft))
                {
                    this.BottomLeft = (this.LeftBottom = 0.0);
                    return;
                }
                this.BottomLeft = radii.BottomLeft + num4;
                this.LeftBottom = radii.BottomLeft + num;
            }
 // Token: 0x06004D52 RID: 19794 RVA: 0x0015C1D8 File Offset: 0x0015A3D8
 private void UpdateGripperCursor()
 {
     if (this._headerGripper != null && !this._headerGripper.IsDragging)
     {
         Cursor cursor;
         if (DoubleUtil.IsZero(base.ActualWidth))
         {
             cursor = this.SplitOpenCursor;
         }
         else
         {
             cursor = this.SplitCursor;
         }
         if (cursor != null)
         {
             this._headerGripper.Cursor = cursor;
         }
     }
 }
示例#5
0
        private void UpdateGripperCursor()
        {
            if (_headerGripper != null && !_headerGripper.IsDragging)
            {
                Cursor gripperCursor;

                if (DoubleUtil.IsZero(ActualWidth))
                {
                    gripperCursor = SplitOpenCursor;
                }
                else
                {
                    gripperCursor = SplitCursor;
                }

                Debug.Assert(gripperCursor != null, "gripper cursor is null");
                if (gripperCursor != null)
                {
                    _headerGripper.Cursor = gripperCursor;
                }
            }
        }
示例#6
0
文件: ViewBox.cs 项目: beda2280/wpf-1
        /// <summary>
        /// This is a helper function that computes scale factors depending on a target size and a content size
        /// </summary>
        /// <param name="availableSize">Size into which the content is being fitted.</param>
        /// <param name="contentSize">Size of the content, measured natively (unconstrained).</param>
        /// <param name="stretch">Value of the Stretch property on the element.</param>
        /// <param name="stretchDirection">Value of the StretchDirection property on the element.</param>
        internal static Size ComputeScaleFactor(Size availableSize,
                                                Size contentSize,
                                                Stretch stretch,
                                                StretchDirection stretchDirection)
        {
            // Compute scaling factors to use for axes
            double scaleX = 1.0;
            double scaleY = 1.0;

            bool isConstrainedWidth  = !Double.IsPositiveInfinity(availableSize.Width);
            bool isConstrainedHeight = !Double.IsPositiveInfinity(availableSize.Height);

            if ((stretch == Stretch.Uniform || stretch == Stretch.UniformToFill || stretch == Stretch.Fill) &&
                (isConstrainedWidth || isConstrainedHeight))
            {
                // Compute scaling factors for both axes
                scaleX = (DoubleUtil.IsZero(contentSize.Width)) ? 0.0 : availableSize.Width / contentSize.Width;
                scaleY = (DoubleUtil.IsZero(contentSize.Height)) ? 0.0 : availableSize.Height / contentSize.Height;

                if (!isConstrainedWidth)
                {
                    scaleX = scaleY;
                }
                else if (!isConstrainedHeight)
                {
                    scaleY = scaleX;
                }
                else
                {
                    // If not preserving aspect ratio, then just apply transform to fit
                    switch (stretch)
                    {
                    case Stretch.Uniform:           //Find minimum scale that we use for both axes
                        double minscale = scaleX < scaleY ? scaleX : scaleY;
                        scaleX = scaleY = minscale;
                        break;

                    case Stretch.UniformToFill:     //Find maximum scale that we use for both axes
                        double maxscale = scaleX > scaleY ? scaleX : scaleY;
                        scaleX = scaleY = maxscale;
                        break;

                    case Stretch.Fill:              //We already computed the fill scale factors above, so just use them
                        break;
                    }
                }

                //Apply stretch direction by bounding scales.
                //In the uniform case, scaleX=scaleY, so this sort of clamping will maintain aspect ratio
                //In the uniform fill case, we have the same result too.
                //In the fill case, note that we change aspect ratio, but that is okay
                switch (stretchDirection)
                {
                case StretchDirection.UpOnly:
                    if (scaleX < 1.0)
                    {
                        scaleX = 1.0;
                    }
                    if (scaleY < 1.0)
                    {
                        scaleY = 1.0;
                    }
                    break;

                case StretchDirection.DownOnly:
                    if (scaleX > 1.0)
                    {
                        scaleX = 1.0;
                    }
                    if (scaleY > 1.0)
                    {
                        scaleY = 1.0;
                    }
                    break;

                case StretchDirection.Both:
                    break;

                default:
                    break;
                }
            }
            //Return this as a size now
            return(new Size(scaleX, scaleY));
        }
示例#7
0
文件: Border.cs 项目: beda2280/wpf-1
        /// <summary>
        ///     Generates a StreamGeometry.
        /// </summary>
        /// <param name="ctx">An already opened StreamGeometryContext.</param>
        /// <param name="rect">Rectangle for geomentry conversion.</param>
        /// <param name="radii">Corner radii.</param>
        /// <returns>Result geometry.</returns>
        private static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, Radii radii)
        {
            //
            //  compute the coordinates of the key points
            //

            Point topLeft     = new Point(radii.LeftTop, 0);
            Point topRight    = new Point(rect.Width - radii.RightTop, 0);
            Point rightTop    = new Point(rect.Width, radii.TopRight);
            Point rightBottom = new Point(rect.Width, rect.Height - radii.BottomRight);
            Point bottomRight = new Point(rect.Width - radii.RightBottom, rect.Height);
            Point bottomLeft  = new Point(radii.LeftBottom, rect.Height);
            Point leftBottom  = new Point(0, rect.Height - radii.BottomLeft);
            Point leftTop     = new Point(0, radii.TopLeft);

            //
            //  check keypoints for overlap and resolve by partitioning radii according to
            //  the percentage of each one.
            //

            //  top edge is handled here
            if (topLeft.X > topRight.X)
            {
                double v = (radii.LeftTop) / (radii.LeftTop + radii.RightTop) * rect.Width;
                topLeft.X  = v;
                topRight.X = v;
            }

            //  right edge
            if (rightTop.Y > rightBottom.Y)
            {
                double v = (radii.TopRight) / (radii.TopRight + radii.BottomRight) * rect.Height;
                rightTop.Y    = v;
                rightBottom.Y = v;
            }

            //  bottom edge
            if (bottomRight.X < bottomLeft.X)
            {
                double v = (radii.LeftBottom) / (radii.LeftBottom + radii.RightBottom) * rect.Width;
                bottomRight.X = v;
                bottomLeft.X  = v;
            }

            // left edge
            if (leftBottom.Y < leftTop.Y)
            {
                double v = (radii.TopLeft) / (radii.TopLeft + radii.BottomLeft) * rect.Height;
                leftBottom.Y = v;
                leftTop.Y    = v;
            }

            //
            //  add on offsets
            //

            Vector offset = new Vector(rect.TopLeft.X, rect.TopLeft.Y);

            topLeft     += offset;
            topRight    += offset;
            rightTop    += offset;
            rightBottom += offset;
            bottomRight += offset;
            bottomLeft  += offset;
            leftBottom  += offset;
            leftTop     += offset;

            //
            //  create the border geometry
            //
            ctx.BeginFigure(topLeft, true /* is filled */, true /* is closed */);

            // Top line
            ctx.LineTo(topRight, true /* is stroked */, false /* is smooth join */);

            // Upper-right corner
            double radiusX = rect.TopRight.X - topRight.X;
            double radiusY = rightTop.Y - rect.TopRight.Y;

            if (!DoubleUtil.IsZero(radiusX) ||
                !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(rightTop, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Right line
            ctx.LineTo(rightBottom, true /* is stroked */, false /* is smooth join */);

            // Lower-right corner
            radiusX = rect.BottomRight.X - bottomRight.X;
            radiusY = rect.BottomRight.Y - rightBottom.Y;
            if (!DoubleUtil.IsZero(radiusX) ||
                !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(bottomRight, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Bottom line
            ctx.LineTo(bottomLeft, true /* is stroked */, false /* is smooth join */);

            // Lower-left corner
            radiusX = bottomLeft.X - rect.BottomLeft.X;
            radiusY = rect.BottomLeft.Y - leftBottom.Y;
            if (!DoubleUtil.IsZero(radiusX) ||
                !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(leftBottom, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Left line
            ctx.LineTo(leftTop, true /* is stroked */, false /* is smooth join */);

            // Upper-left corner
            radiusX = topLeft.X - rect.TopLeft.X;
            radiusY = leftTop.Y - rect.TopLeft.Y;
            if (!DoubleUtil.IsZero(radiusX) ||
                !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(topLeft, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }
        }
示例#8
0
文件: Border.cs 项目: beda2280/wpf-1
        /// <summary>
        /// In addition to the child, Border renders a background + border.  The background is drawn inside the border.
        /// </summary>
        protected override void OnRender(DrawingContext dc)
        {
            bool     useLayoutRounding = this.UseLayoutRounding;
            DpiScale dpi = GetDpi();

            if (_useComplexRenderCodePath)
            {
                Brush          brush;
                StreamGeometry borderGeometry = BorderGeometryCache;
                if (borderGeometry != null &&
                    (brush = BorderBrush) != null)
                {
                    dc.DrawGeometry(brush, null, borderGeometry);
                }

                StreamGeometry backgroundGeometry = BackgroundGeometryCache;
                if (backgroundGeometry != null &&
                    (brush = Background) != null)
                {
                    dc.DrawGeometry(brush, null, backgroundGeometry);
                }
            }
            else
            {
                Thickness border = BorderThickness;
                Brush     borderBrush;

                CornerRadius cornerRadius      = CornerRadius;
                double       outerCornerRadius = cornerRadius.TopLeft; // Already validated that all corners have the same radius
                bool         roundedCorners    = !DoubleUtil.IsZero(outerCornerRadius);

                // If we have a brush with which to draw the border, do so.
                // NB: We double draw corners right now.  Corner handling is tricky (bevelling, &c...) and
                //     we need a firm spec before doing "the right thing."  (greglett, ffortes)
                if (!border.IsZero &&
                    (borderBrush = BorderBrush) != null)
                {
                    // Initialize the first pen.  Note that each pen is created via new()
                    // and frozen if possible.  Doing this avoids the pen
                    // being copied when used in the DrawLine methods.
                    Pen pen = LeftPenCache;
                    if (pen == null)
                    {
                        pen       = new Pen();
                        pen.Brush = borderBrush;

                        if (useLayoutRounding)
                        {
                            pen.Thickness = UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX);
                        }
                        else
                        {
                            pen.Thickness = border.Left;
                        }
                        if (borderBrush.IsFrozen)
                        {
                            pen.Freeze();
                        }

                        LeftPenCache = pen;
                    }

                    double halfThickness;
                    if (border.IsUniform)
                    {
                        halfThickness = pen.Thickness * 0.5;


                        // Create rect w/ border thickness, and round if applying layout rounding.
                        Rect rect = new Rect(new Point(halfThickness, halfThickness),
                                             new Point(RenderSize.Width - halfThickness, RenderSize.Height - halfThickness));

                        if (roundedCorners)
                        {
                            dc.DrawRoundedRectangle(
                                null,
                                pen,
                                rect,
                                outerCornerRadius,
                                outerCornerRadius);
                        }
                        else
                        {
                            dc.DrawRectangle(
                                null,
                                pen,
                                rect);
                        }
                    }
                    else
                    {
                        // Nonuniform border; stroke each edge.
                        if (DoubleUtil.GreaterThan(border.Left, 0))
                        {
                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(halfThickness, 0),
                                new Point(halfThickness, RenderSize.Height));
                        }

                        if (DoubleUtil.GreaterThan(border.Right, 0))
                        {
                            pen = RightPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;

                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX);
                                }
                                else
                                {
                                    pen.Thickness = border.Right;
                                }

                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                RightPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(RenderSize.Width - halfThickness, 0),
                                new Point(RenderSize.Width - halfThickness, RenderSize.Height));
                        }

                        if (DoubleUtil.GreaterThan(border.Top, 0))
                        {
                            pen = TopPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = border.Top;
                                }

                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                TopPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(0, halfThickness),
                                new Point(RenderSize.Width, halfThickness));
                        }

                        if (DoubleUtil.GreaterThan(border.Bottom, 0))
                        {
                            pen = BottomPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = border.Bottom;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                BottomPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(0, RenderSize.Height - halfThickness),
                                new Point(RenderSize.Width, RenderSize.Height - halfThickness));
                        }
                    }
                }

                // Draw background in rectangle inside border.
                Brush background = Background;
                if (background != null)
                {
                    // Intialize background
                    Point ptTL, ptBR;

                    if (useLayoutRounding)
                    {
                        ptTL = new Point(UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX),
                                         UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY));

                        if (FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
                        {
                            ptBR = new Point(UIElement.RoundLayoutValue(RenderSize.Width - border.Right, dpi.DpiScaleX),
                                             UIElement.RoundLayoutValue(RenderSize.Height - border.Bottom, dpi.DpiScaleY));
                        }
                        else
                        {
                            ptBR = new Point(RenderSize.Width - UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX),
                                             RenderSize.Height - UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY));
                        }
                    }
                    else
                    {
                        ptTL = new Point(border.Left, border.Top);
                        ptBR = new Point(RenderSize.Width - border.Right, RenderSize.Height - border.Bottom);
                    }

                    // Do not draw background if the borders are so large that they overlap.
                    if (ptBR.X > ptTL.X && ptBR.Y > ptTL.Y)
                    {
                        if (roundedCorners)
                        {
                            Radii  innerRadii        = new Radii(cornerRadius, border, false); // Determine the inner edge radius
                            double innerCornerRadius = innerRadii.TopLeft;                     // Already validated that all corners have the same radius
                            dc.DrawRoundedRectangle(background, null, new Rect(ptTL, ptBR), innerCornerRadius, innerCornerRadius);
                        }
                        else
                        {
                            dc.DrawRectangle(background, null, new Rect(ptTL, ptBR));
                        }
                    }
                }
            }
        }
示例#9
0
文件: Border.cs 项目: beda2280/wpf-1
        /// <summary>
        /// Border computes the position of its single child and applies its child's alignments to the child.
        ///
        /// </summary>
        /// <param name="finalSize">The size reserved for this element by the parent</param>
        /// <returns>The actual ink area of the element, typically the same as finalSize</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            Thickness borders = BorderThickness;

            if (this.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
            {
                DpiScale dpi = GetDpi();
                borders = new Thickness(UIElement.RoundLayoutValue(borders.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Top, dpi.DpiScaleY),
                                        UIElement.RoundLayoutValue(borders.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Bottom, dpi.DpiScaleY));
            }
            Rect boundRect = new Rect(finalSize);
            Rect innerRect = HelperDeflateRect(boundRect, borders);

            //  arrange child
            UIElement child = Child;

            if (child != null)
            {
                Rect childRect = HelperDeflateRect(innerRect, Padding);
                child.Arrange(childRect);
            }

            CornerRadius radii          = CornerRadius;
            Brush        borderBrush    = BorderBrush;
            bool         uniformCorners = AreUniformCorners(radii);

            //  decide which code path to execute. complex (geometry path based) rendering
            //  is used if one of the following is true:

            //  1. there are non-uniform rounded corners
            _useComplexRenderCodePath = !uniformCorners;

            if (!_useComplexRenderCodePath &&
                borderBrush != null)
            {
                SolidColorBrush originIndependentBrush = borderBrush as SolidColorBrush;

                bool uniformBorders = borders.IsUniform;

                _useComplexRenderCodePath =
                    //  2. the border brush is origin dependent (the only origin independent brush is a solid color brush)
                    (originIndependentBrush == null)
                    //  3. the border brush is semi-transtarent solid color brush AND border thickness is not uniform
                    //     (for uniform semi-transparent border Border.OnRender draws rectangle outline - so it works fine)
                    || ((originIndependentBrush.Color.A < 0xff) && !uniformBorders)
                    //  4. there are rounded corners AND the border thickness is not uniform
                    || (!DoubleUtil.IsZero(radii.TopLeft) && !uniformBorders);
            }

            if (_useComplexRenderCodePath)
            {
                Radii innerRadii = new Radii(radii, borders, false);

                StreamGeometry backgroundGeometry = null;

                //  calculate border / background rendering geometry
                if (!DoubleUtil.IsZero(innerRect.Width) && !DoubleUtil.IsZero(innerRect.Height))
                {
                    backgroundGeometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = backgroundGeometry.Open())
                    {
                        GenerateGeometry(ctx, innerRect, innerRadii);
                    }

                    backgroundGeometry.Freeze();
                    BackgroundGeometryCache = backgroundGeometry;
                }
                else
                {
                    BackgroundGeometryCache = null;
                }

                if (!DoubleUtil.IsZero(boundRect.Width) && !DoubleUtil.IsZero(boundRect.Height))
                {
                    Radii          outerRadii     = new Radii(radii, borders, true);
                    StreamGeometry borderGeometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = borderGeometry.Open())
                    {
                        GenerateGeometry(ctx, boundRect, outerRadii);

                        if (backgroundGeometry != null)
                        {
                            GenerateGeometry(ctx, innerRect, innerRadii);
                        }
                    }

                    borderGeometry.Freeze();
                    BorderGeometryCache = borderGeometry;
                }
                else
                {
                    BorderGeometryCache = null;
                }
            }
            else
            {
                BackgroundGeometryCache = null;
                BorderGeometryCache     = null;
            }

            return(finalSize);
        }
        // Token: 0x0600426A RID: 17002 RVA: 0x001302AC File Offset: 0x0012E4AC
        private static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, Border.Radii radii)
        {
            Point point  = new Point(radii.LeftTop, 0.0);
            Point point2 = new Point(rect.Width - radii.RightTop, 0.0);
            Point point3 = new Point(rect.Width, radii.TopRight);
            Point point4 = new Point(rect.Width, rect.Height - radii.BottomRight);
            Point point5 = new Point(rect.Width - radii.RightBottom, rect.Height);
            Point point6 = new Point(radii.LeftBottom, rect.Height);
            Point point7 = new Point(0.0, rect.Height - radii.BottomLeft);
            Point point8 = new Point(0.0, radii.TopLeft);

            if (point.X > point2.X)
            {
                double x = radii.LeftTop / (radii.LeftTop + radii.RightTop) * rect.Width;
                point.X  = x;
                point2.X = x;
            }
            if (point3.Y > point4.Y)
            {
                double y = radii.TopRight / (radii.TopRight + radii.BottomRight) * rect.Height;
                point3.Y = y;
                point4.Y = y;
            }
            if (point5.X < point6.X)
            {
                double x2 = radii.LeftBottom / (radii.LeftBottom + radii.RightBottom) * rect.Width;
                point5.X = x2;
                point6.X = x2;
            }
            if (point7.Y < point8.Y)
            {
                double y2 = radii.TopLeft / (radii.TopLeft + radii.BottomLeft) * rect.Height;
                point7.Y = y2;
                point8.Y = y2;
            }
            Vector vector = new Vector(rect.TopLeft.X, rect.TopLeft.Y);

            point  += vector;
            point2 += vector;
            point3 += vector;
            point4 += vector;
            point5 += vector;
            point6 += vector;
            point7 += vector;
            point8 += vector;
            ctx.BeginFigure(point, true, true);
            ctx.LineTo(point2, true, false);
            double num  = rect.TopRight.X - point2.X;
            double num2 = point3.Y - rect.TopRight.Y;

            if (!DoubleUtil.IsZero(num) || !DoubleUtil.IsZero(num2))
            {
                ctx.ArcTo(point3, new Size(num, num2), 0.0, false, SweepDirection.Clockwise, true, false);
            }
            ctx.LineTo(point4, true, false);
            num  = rect.BottomRight.X - point5.X;
            num2 = rect.BottomRight.Y - point4.Y;
            if (!DoubleUtil.IsZero(num) || !DoubleUtil.IsZero(num2))
            {
                ctx.ArcTo(point5, new Size(num, num2), 0.0, false, SweepDirection.Clockwise, true, false);
            }
            ctx.LineTo(point6, true, false);
            num  = point6.X - rect.BottomLeft.X;
            num2 = rect.BottomLeft.Y - point7.Y;
            if (!DoubleUtil.IsZero(num) || !DoubleUtil.IsZero(num2))
            {
                ctx.ArcTo(point7, new Size(num, num2), 0.0, false, SweepDirection.Clockwise, true, false);
            }
            ctx.LineTo(point8, true, false);
            num  = point.X - rect.TopLeft.X;
            num2 = point8.Y - rect.TopLeft.Y;
            if (!DoubleUtil.IsZero(num) || !DoubleUtil.IsZero(num2))
            {
                ctx.ArcTo(point, new Size(num, num2), 0.0, false, SweepDirection.Clockwise, true, false);
            }
        }
        /// <summary>Draws the contents of a <see cref="T:System.Windows.Media.DrawingContext" /> object during the render pass of a <see cref="T:System.Windows.Controls.Border" />. </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext" /> that defines the object to be drawn.</param>
        // Token: 0x06004266 RID: 16998 RVA: 0x0012FBE0 File Offset: 0x0012DDE0
        protected override void OnRender(DrawingContext dc)
        {
            bool     useLayoutRounding = base.UseLayoutRounding;
            DpiScale dpi = base.GetDpi();

            if (this._useComplexRenderCodePath)
            {
                StreamGeometry borderGeometryCache = this.BorderGeometryCache;
                Brush          brush;
                if (borderGeometryCache != null && (brush = this.BorderBrush) != null)
                {
                    dc.DrawGeometry(brush, null, borderGeometryCache);
                }
                StreamGeometry backgroundGeometryCache = this.BackgroundGeometryCache;
                if (backgroundGeometryCache != null && (brush = this.Background) != null)
                {
                    dc.DrawGeometry(brush, null, backgroundGeometryCache);
                    return;
                }
            }
            else
            {
                Thickness    borderThickness = this.BorderThickness;
                CornerRadius cornerRadius    = this.CornerRadius;
                double       topLeft         = cornerRadius.TopLeft;
                bool         flag            = !DoubleUtil.IsZero(topLeft);
                Brush        borderBrush;
                if (!borderThickness.IsZero && (borderBrush = this.BorderBrush) != null)
                {
                    Pen pen = this.LeftPenCache;
                    if (pen == null)
                    {
                        pen       = new Pen();
                        pen.Brush = borderBrush;
                        if (useLayoutRounding)
                        {
                            pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX);
                        }
                        else
                        {
                            pen.Thickness = borderThickness.Left;
                        }
                        if (borderBrush.IsFrozen)
                        {
                            pen.Freeze();
                        }
                        this.LeftPenCache = pen;
                    }
                    if (borderThickness.IsUniform)
                    {
                        double num       = pen.Thickness * 0.5;
                        Rect   rectangle = new Rect(new Point(num, num), new Point(base.RenderSize.Width - num, base.RenderSize.Height - num));
                        if (flag)
                        {
                            dc.DrawRoundedRectangle(null, pen, rectangle, topLeft, topLeft);
                        }
                        else
                        {
                            dc.DrawRectangle(null, pen, rectangle);
                        }
                    }
                    else
                    {
                        if (DoubleUtil.GreaterThan(borderThickness.Left, 0.0))
                        {
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(num, 0.0), new Point(num, base.RenderSize.Height));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Right, 0.0))
                        {
                            pen = this.RightPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Right;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.RightPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(base.RenderSize.Width - num, 0.0), new Point(base.RenderSize.Width - num, base.RenderSize.Height));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Top, 0.0))
                        {
                            pen = this.TopPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Top;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.TopPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(0.0, num), new Point(base.RenderSize.Width, num));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Bottom, 0.0))
                        {
                            pen = this.BottomPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Bottom;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.BottomPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(0.0, base.RenderSize.Height - num), new Point(base.RenderSize.Width, base.RenderSize.Height - num));
                        }
                    }
                }
                Brush background = this.Background;
                if (background != null)
                {
                    Point point;
                    Point point2;
                    if (useLayoutRounding)
                    {
                        point = new Point(UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY));
                        if (FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
                        {
                            point2 = new Point(UIElement.RoundLayoutValue(base.RenderSize.Width - borderThickness.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(base.RenderSize.Height - borderThickness.Bottom, dpi.DpiScaleY));
                        }
                        else
                        {
                            point2 = new Point(base.RenderSize.Width - UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX), base.RenderSize.Height - UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY));
                        }
                    }
                    else
                    {
                        point  = new Point(borderThickness.Left, borderThickness.Top);
                        point2 = new Point(base.RenderSize.Width - borderThickness.Right, base.RenderSize.Height - borderThickness.Bottom);
                    }
                    if (point2.X > point.X && point2.Y > point.Y)
                    {
                        if (flag)
                        {
                            Border.Radii radii    = new Border.Radii(cornerRadius, borderThickness, false);
                            double       topLeft2 = radii.TopLeft;
                            dc.DrawRoundedRectangle(background, null, new Rect(point, point2), topLeft2, topLeft2);
                            return;
                        }
                        dc.DrawRectangle(background, null, new Rect(point, point2));
                    }
                }
            }
        }
        /// <summary>Arranges the contents of a <see cref="T:System.Windows.Controls.Border" /> element.</summary>
        /// <param name="finalSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child element.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Border" /> element and its child element.</returns>
        // Token: 0x06004265 RID: 16997 RVA: 0x0012F998 File Offset: 0x0012DB98
        protected override Size ArrangeOverride(Size finalSize)
        {
            Thickness borderThickness = this.BorderThickness;

            if (base.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
            {
                DpiScale dpi = base.GetDpi();
                borderThickness = new Thickness(UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY), UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY));
            }
            Rect      rect  = new Rect(finalSize);
            Rect      rect2 = Border.HelperDeflateRect(rect, borderThickness);
            UIElement child = this.Child;

            if (child != null)
            {
                Rect finalRect = Border.HelperDeflateRect(rect2, this.Padding);
                child.Arrange(finalRect);
            }
            CornerRadius cornerRadius = this.CornerRadius;
            Brush        borderBrush  = this.BorderBrush;
            bool         flag         = Border.AreUniformCorners(cornerRadius);

            this._useComplexRenderCodePath = !flag;
            if (!this._useComplexRenderCodePath && borderBrush != null)
            {
                SolidColorBrush solidColorBrush = borderBrush as SolidColorBrush;
                bool            isUniform       = borderThickness.IsUniform;
                this._useComplexRenderCodePath = (solidColorBrush == null || (solidColorBrush.Color.A < byte.MaxValue && !isUniform) || (!DoubleUtil.IsZero(cornerRadius.TopLeft) && !isUniform));
            }
            if (this._useComplexRenderCodePath)
            {
                Border.Radii   radii          = new Border.Radii(cornerRadius, borderThickness, false);
                StreamGeometry streamGeometry = null;
                if (!DoubleUtil.IsZero(rect2.Width) && !DoubleUtil.IsZero(rect2.Height))
                {
                    streamGeometry = new StreamGeometry();
                    using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
                    {
                        Border.GenerateGeometry(streamGeometryContext, rect2, radii);
                    }
                    streamGeometry.Freeze();
                    this.BackgroundGeometryCache = streamGeometry;
                }
                else
                {
                    this.BackgroundGeometryCache = null;
                }
                if (!DoubleUtil.IsZero(rect.Width) && !DoubleUtil.IsZero(rect.Height))
                {
                    Border.Radii   radii2          = new Border.Radii(cornerRadius, borderThickness, true);
                    StreamGeometry streamGeometry2 = new StreamGeometry();
                    using (StreamGeometryContext streamGeometryContext2 = streamGeometry2.Open())
                    {
                        Border.GenerateGeometry(streamGeometryContext2, rect, radii2);
                        if (streamGeometry != null)
                        {
                            Border.GenerateGeometry(streamGeometryContext2, rect2, radii);
                        }
                    }
                    streamGeometry2.Freeze();
                    this.BorderGeometryCache = streamGeometry2;
                }
                else
                {
                    this.BorderGeometryCache = null;
                }
            }
            else
            {
                this.BackgroundGeometryCache = null;
                this.BorderGeometryCache     = null;
            }
            return(finalSize);
        }