コード例 #1
0
        /// <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);
        }