Ejemplo n.º 1
0
        void RepositionTip(PointerBorder pointer)
        {
            DataValue data = pointer.Data;

            double availableHeight = this.ActualHeight;
            double value           = data.Y;
            Point  scaled          = scaleTransform.Transform(new Point(data.X, data.Y));

            scaled = zoomTransform.Transform(scaled);
            double offset       = Canvas.GetLeft(Graph);
            double x            = scaled.X + offset;
            double y            = availableHeight - scaled.Y;
            double tipPositionX = x;

            if (tipPositionX + PointerBorder.ActualWidth > this.ActualWidth)
            {
                tipPositionX = this.ActualWidth - PointerBorder.ActualWidth;
            }
            double tipPositionY = y - PointerLabel.ActualHeight - 4;

            if (tipPositionY < 0)
            {
                tipPositionY = 0;
            }
            pointer.Margin = new Thickness(tipPositionX, tipPositionY, 0, 0);

            pointer.Pointer.RenderTransform = new TranslateTransform(x, y);
        }
Ejemplo n.º 2
0
        void ShowTip(string label, Point pos, DataValue data = null)
        {
            PointerLabel.Text = label;
            PointerBorder.UpdateLayout();

            double offset       = Canvas.GetLeft(Graph);
            double tipPositionX = pos.X;// + offset;

            if (tipPositionX + PointerBorder.ActualWidth > this.ActualWidth)
            {
                tipPositionX = this.ActualWidth - PointerBorder.ActualWidth;
            }
            double tipPositionY = pos.Y - PointerLabel.ActualHeight - 4;

            if (tipPositionY < 0)
            {
                tipPositionY = 0;
            }
            PointerBorder.Margin     = new Thickness(tipPositionX, tipPositionY, 0, 0);
            PointerBorder.Visibility = System.Windows.Visibility.Visible;
            PointerBorder.Data       = data;

            Point pointerPosition = pos;

            Pointer.RenderTransform = new TranslateTransform(pointerPosition.X, pointerPosition.Y);
            Pointer.Visibility      = System.Windows.Visibility.Visible;

            LockTooltipMenuItem.IsEnabled = true;
        }
Ejemplo n.º 3
0
 private void RepositionTips()
 {
     foreach (UIElement child in AdornerCanvas.Children)
     {
         PointerBorder pointer = child as PointerBorder;
         if (pointer != null)
         {
             RepositionTip(pointer);
         }
     }
 }
Ejemplo n.º 4
0
        void ShowTip(string label, Point pos, DataValue data = null)
        {
            PointerLabel.Text = label;
            PointerBorder.UpdateLayout();

            double tipPositionX = pos.X;

            if (tipPositionX + PointerBorder.ActualWidth > this.ActualWidth)
            {
                tipPositionX = this.ActualWidth - PointerBorder.ActualWidth;
            }
            double tipPositionY = pos.Y - PointerLabel.ActualHeight - 4;

            if (tipPositionY < 0)
            {
                tipPositionY = 0;
            }

            Size closeBoxSize = CloseBox.DesiredSize;

            if (tipPositionX == this.ActualWidth - PointerBorder.ActualWidth && tipPositionY < closeBoxSize.Height)
            {
                tipPositionX -= closeBoxSize.Width;
            }

            PointerBorder.Margin     = new Thickness(tipPositionX, tipPositionY, 0, 0);
            PointerBorder.Visibility = System.Windows.Visibility.Visible;
            PointerBorder.Data       = data;

            Point pointerPosition = pos;

            Pointer.RenderTransform = new TranslateTransform(pointerPosition.X, pointerPosition.Y);
            Pointer.Visibility      = System.Windows.Visibility.Visible;

            LockTooltipMenuItem.IsEnabled = true;

            if (PointerMoved != null)
            {
                PointerMoved(this, data);
            }
        }
Ejemplo n.º 5
0
        private void OnLockTooltip(object sender, RoutedEventArgs e)
        {
            // we lock the tooltip by cloning the existing tooltip objects.

            /*
             * <Path x:Name="Pointer" Fill="{StaticResource TooltipForeground}" Data="M0,-5 L 5,0 0,5 -5 0z" Visibility="Collapsed"/>
             * <Border x:Name="PointerBorder"  Visibility="Collapsed" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1"
             *      CornerRadius="3" BorderBrush="{StaticResource TooltipForeground}" Background="#80303030">
             *  <TextBlock x:Name="PointerLabel" Foreground="{StaticResource TooltipForeground}"/>
             * </Border>
             */
            Path ptr = new Path()
            {
                Fill            = Pointer.Fill,
                Data            = Pointer.Data.Clone(),
                RenderTransform = Pointer.RenderTransform.Clone()
            };

            AdornerCanvas.Children.Add(ptr);

            PointerBorder ptrBorder = new PointerBorder()
            {
                Padding             = PointerBorder.Padding,
                HorizontalAlignment = PointerBorder.HorizontalAlignment,
                VerticalAlignment   = PointerBorder.VerticalAlignment,
                BorderThickness     = PointerBorder.BorderThickness,
                CornerRadius        = PointerBorder.CornerRadius,
                BorderBrush         = PointerBorder.BorderBrush,
                Background          = PointerBorder.Background,
                Margin  = PointerBorder.Margin,
                Data    = PointerBorder.Data,
                Pointer = ptr,
            };

            ptrBorder.Child = new TextBlock()
            {
                Foreground = PointerLabel.Foreground, Text = PointerLabel.Text
            };
            AdornerCanvas.Children.Add(ptrBorder);
        }
Ejemplo n.º 6
0
        void RepositionTip(PointerBorder pointer)
        {
            DataValue data         = pointer.Data;
            Point     pt           = GetScaledValue(data);
            double    offset       = Canvas.GetLeft(Graph);
            double    x            = pt.X + offset;
            double    y            = pt.Y;
            double    tipPositionX = x;

            if (tipPositionX + PointerBorder.ActualWidth > this.ActualWidth)
            {
                tipPositionX = this.ActualWidth - PointerBorder.ActualWidth;
            }
            double tipPositionY = y - PointerLabel.ActualHeight - 4;

            if (tipPositionY < 0)
            {
                tipPositionY = 0;
            }
            pointer.Margin = new Thickness(tipPositionX, tipPositionY, 0, 0);

            pointer.Pointer.RenderTransform = new TranslateTransform(x, y);
        }