private void AddIndicator(SerialGraph graph) { var indicator = new Indicator(); var fillBinding = new Binding("Brush") { Source = graph }; indicator.SetBinding(Indicator.FillProperty, fillBinding); var strokeBinding = new Binding("PlotAreaBackground") { Source = this }; indicator.SetBinding(Indicator.StrokeProperty, strokeBinding); indicator.MouseEnter += OnIndicatorMouseEnter; indicator.MouseLeave += OnIndicatorMouseLeave; _indicators.Add(graph, indicator); AddIndicatorToCanvas(indicator); }
private void DisplayBalloon(Indicator indicator) { _balloon.Text = indicator.Text; _balloon.Visibility = Visibility.Visible; _balloon.Measure(new Size(_graphCanvasDecorator.ActualWidth, _graphCanvasDecorator.ActualHeight)); var balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty) - _balloon.DesiredSize.Width / 2 + indicator.ActualWidth / 2; if (balloonLeft < 0) { balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty); } else if (balloonLeft + _balloon.DesiredSize.Width > _graphCanvasDecorator.ActualWidth) { balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty) - _balloon.DesiredSize.Width; } var balloonTop = (double)indicator.GetValue(Canvas.TopProperty) - _balloon.DesiredSize.Height - 5; if (balloonTop < 0) { balloonTop = (double)indicator.GetValue(Canvas.TopProperty) + 17; } _balloon.SetValue(Canvas.LeftProperty, balloonLeft); _balloon.SetValue(Canvas.TopProperty, balloonTop); }
private void AddIndicatorToCanvas(Indicator indicator) { _graphCanvas?.Children.Add(indicator); }
private void AddIndicatorToCanvas(Indicator indicator) { _graphCanvas?.Children.Add(indicator); }