1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.View
7 using System.Activities.Presentation;
9 using System.Windows.Controls;
10 using System.Windows.Documents;
11 using System.Windows.Media;
12 using System.Windows.Media.Effects;
14 class SearchToolTipAdorner : Adorner
17 double scrollViewerToScreenDistance;
18 public SearchToolTipAdorner(UIElement adornedElement, DesignerView designerView, string text)
19 : base(adornedElement)
21 this.scrollViewerToScreenDistance = designerView.ScrollViewer.PointToScreen(new Point(0, 0)).Y;;
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),
31 Foreground = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor),
32 Margin = new Thickness(4, 0, 4, 0),
35 TextWrapping = TextWrapping.Wrap,
36 TextTrimming = TextTrimming.CharacterEllipsis
38 Effect = new DropShadowEffect
45 tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
48 protected override void OnRender(DrawingContext drawingContext)
50 VisualBrush brush = new VisualBrush()
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);
62 Pen renderPen = new Pen();
63 drawingContext.DrawRectangle(brush, renderPen, tooltipRect);