[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / SearchToolTipAdorner.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation.View
6 {
7     using System.Activities.Presentation;
8     using System.Windows;
9     using System.Windows.Controls;
10     using System.Windows.Documents;
11     using System.Windows.Media;
12     using System.Windows.Media.Effects;
13
14     class SearchToolTipAdorner : Adorner
15     {
16         Border tooltip;
17         double scrollViewerToScreenDistance;
18         public SearchToolTipAdorner(UIElement adornedElement, DesignerView designerView, string text)
19             : base(adornedElement)
20         {
21             this.scrollViewerToScreenDistance = designerView.ScrollViewer.PointToScreen(new Point(0, 0)).Y;;
22             tooltip = new Border
23             {
24                 Background = new SolidColorBrush(WorkflowDesignerColors.DesignerViewBackgroundColor),
25                 BorderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBorderColor),
26                 BorderThickness = new Thickness(1),
27                 CornerRadius = new CornerRadius(4),
28                 Margin = new Thickness(10),
29                 Child = new TextBlock
30                 {
31                     Foreground = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor),
32                     Margin = new Thickness(4, 0, 4, 0),
33                     MaxWidth = 300,
34                     Text = text,
35                     TextWrapping = TextWrapping.Wrap,
36                     TextTrimming = TextTrimming.CharacterEllipsis
37                 },
38                 Effect = new DropShadowEffect
39                 {
40                     Color = Colors.Black,
41                     BlurRadius = 4,
42                     Opacity = 0.5
43                 },
44             };
45             tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
46         }
47
48         protected override void OnRender(DrawingContext drawingContext)
49         {
50             VisualBrush brush = new VisualBrush()
51             {
52                 Visual = tooltip
53             };
54
55             double adornerElementToVisibleScrollViewDistance =
56                 this.AdornedElement.PointToScreen(new Point(0, 0)).Y - this.scrollViewerToScreenDistance;
57             double Y = adornerElementToVisibleScrollViewDistance < tooltip.DesiredSize.Height ?
58                 tooltip.DesiredSize.Height :
59                 -tooltip.DesiredSize.Height;
60             Rect tooltipRect = new Rect(new Point(0, Y), tooltip.DesiredSize);
61             
62             Pen renderPen = new Pen();
63             drawingContext.DrawRectangle(brush, renderPen, tooltipRect);
64         }
65     }
66 }