/// <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)); } } } }
// 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>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); }