[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / FromExpression / Framework / ValueEditors / RenderUtils.cs
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
6 {
7     using System;
8     using System.Windows;
9     using System.Windows.Media;
10
11     internal sealed class RenderUtils
12     {
13         private RenderUtils()
14         {
15         }
16
17         public static bool DrawInscribedRoundedRect(DrawingContext drawingContext, Brush fill, Pen stroke, Rect outerBounds, double cornerRadius)
18         {
19             Point spineLeftTop = new Point(outerBounds.Left, outerBounds.Top);
20             Point spineRightBottom = new Point(outerBounds.Right, outerBounds.Bottom);
21             bool drewSomething = false;
22
23             if (stroke != null && !Tolerances.NearZero(stroke.Thickness))
24             {
25                 double halfThickness = stroke.Thickness / 2d;
26                 spineLeftTop.X += halfThickness;
27                 spineLeftTop.Y += halfThickness;
28                 spineRightBottom.X -= halfThickness;
29                 spineRightBottom.Y -= halfThickness;
30             }
31
32             Rect spineRect = new Rect(spineLeftTop, spineRightBottom);
33             if (!Tolerances.NearZero(spineRect.Width) && !Tolerances.NearZero(spineRect.Height))
34             {
35                 drawingContext.DrawRoundedRectangle(fill, stroke, spineRect, cornerRadius, cornerRadius);
36                 drewSomething = true;
37             }
38
39             return drewSomething;
40         }
41
42         public static Rect CalculateInnerRect(Rect outerBounds, double strokeThickness)
43         {
44             if (!Tolerances.NearZero(strokeThickness))
45             {
46                 return new Rect(new Point(outerBounds.Left + strokeThickness, outerBounds.Top + strokeThickness), new Point(outerBounds.Right - strokeThickness, outerBounds.Bottom - strokeThickness));
47             }
48             else
49             {
50                 return outerBounds;
51             }
52         }
53     }
54 }