1 // -------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -------------------------------------------------------------------
4 //From \\authoring\Sparkle\Source\1.0.1083.0\Common\Source\Framework\ValueEditors
5 namespace System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.ValueEditors
9 using System.Windows.Media;
11 internal sealed class RenderUtils
17 public static bool DrawInscribedRoundedRect(DrawingContext drawingContext, Brush fill, Pen stroke, Rect outerBounds, double cornerRadius)
19 Point spineLeftTop = new Point(outerBounds.Left, outerBounds.Top);
20 Point spineRightBottom = new Point(outerBounds.Right, outerBounds.Bottom);
21 bool drewSomething = false;
23 if (stroke != null && !Tolerances.NearZero(stroke.Thickness))
25 double halfThickness = stroke.Thickness / 2d;
26 spineLeftTop.X += halfThickness;
27 spineLeftTop.Y += halfThickness;
28 spineRightBottom.X -= halfThickness;
29 spineRightBottom.Y -= halfThickness;
32 Rect spineRect = new Rect(spineLeftTop, spineRightBottom);
33 if (!Tolerances.NearZero(spineRect.Width) && !Tolerances.NearZero(spineRect.Height))
35 drawingContext.DrawRoundedRectangle(fill, stroke, spineRect, cornerRadius, cornerRadius);
42 public static Rect CalculateInnerRect(Rect outerBounds, double strokeThickness)
44 if (!Tolerances.NearZero(strokeThickness))
46 return new Rect(new Point(outerBounds.Left + strokeThickness, outerBounds.Top + strokeThickness), new Point(outerBounds.Right - strokeThickness, outerBounds.Bottom - strokeThickness));