// Animation Ellipse logic. private void UpdatePreviewIndicatorPosition(Point mousePos, FrameworkElement frameworkElement) { if (previewElement == null) { double positionX, positionY; bool isAdornment = false; // WPF_18250 DragDelta Event returns undesired delta value. // Here we have reset the prevDraggedValue when dragged segment is changed. int previousIndex = SegmentIndex; draggingSegment = null; SetScatterDraggingSegment(frameworkElement, ref isAdornment); if (draggingSegment == null) { return; } if (previousIndex != SegmentIndex) { prevDraggedXValue = 0; prevDraggedValue = 0; } XySegmentEnterEventArgs args = new XySegmentEnterEventArgs { XValue = GetActualXValue(SegmentIndex), YValue = draggingSegment.YData, SegmentIndex = SegmentIndex, CanDrag = true, }; RaiseDragEnter(args); if (!args.CanDrag) { return; } positionY = Area.ValueToLogPoint(ActualYAxis, draggingSegment.YData); positionX = Area.ValueToLogPoint(ActualXAxis, draggingSegment.XData); if (CustomTemplate != null) { AnimationElement = GetPreviewEllipse() as ContentControl; AnimateSegmentTemplate(positionX, positionY, draggingSegment); } else if (isAdornment) { if (AdornmentsInfo.Symbol.ToString() == "Custom") { AnimateAdornmentSymbolTemplate(positionX, positionY); } else { AddAnimationEllipse( ChartDictionaries.GenericSymbolDictionary["Animation" + AdornmentsInfo.Symbol.ToString() + "Template"] as ControlTemplate, AdornmentsInfo.SymbolHeight, AdornmentsInfo.SymbolWidth, positionX, positionY, Adornments[SegmentIndex], true); } } else { AddAnimationEllipse( ChartDictionaries.GenericSymbolDictionary["AnimationEllipseTemplate"] as ControlTemplate, ScatterHeight, ScatterWidth, positionX, positionY, Segments[SegmentIndex], false); } } }
private void UpdatePreviewIndicatorPosition(Point mousePos) { if (PreviewSeries == null && DraggingSegment == null && EnableSegmentDragging) { double x, y, stackedValue, positionY; FindNearestChartPoint(mousePos, out x, out y, out stackedValue); if (double.IsNaN(y)) { return; } // WPF_18250 DragDelta Event returns undesired delta value. // Here we have reset the prevDraggedValue when dragged segment is changed. int previousIndex = SegmentIndex; SegmentIndex = (int)(IsIndexed || ActualXValues is IList <string>?x : ((IList <double>)ActualXValues).IndexOf(x)); if (previousIndex != SegmentIndex) { prevDraggedValue = 0; } XySegmentEnterEventArgs args = new XySegmentEnterEventArgs { XValue = GetActualXValue(SegmentIndex), SegmentIndex = SegmentIndex, CanDrag = true, YValue = YValues[SegmentIndex] }; RaiseDragEnter(args); if (!args.CanDrag) { return; } positionY = Area.ValueToLogPoint(ActualYAxis, y); var positionX = Area.ValueToLogPoint(ActualXAxis, x); if (AdornmentsInfo == null) { if (DraggingPointIndicator == null) { AddSegmentIndicator(); } if (this.IsActualTransposed) { Canvas.SetTop(DraggingPointIndicator, positionX - DraggingPointIndicator.Width / 2); Canvas.SetLeft(DraggingPointIndicator, positionY - DraggingPointIndicator.Height / 2); } else { Canvas.SetLeft(DraggingPointIndicator, positionX - DraggingPointIndicator.Width / 2); Canvas.SetTop(DraggingPointIndicator, positionY - DraggingPointIndicator.Height / 2); } DraggingPointIndicator.Tag = Math.Abs(Segments.Count - SegmentIndex) > 0 ? Segments[(int)SegmentIndex] : Segments[(int)SegmentIndex - 1]; AddAnimationEllipse( ChartDictionaries.GenericSymbolDictionary["AnimationEllipseTemplate"] as ControlTemplate, DraggingPointIndicator.Height, DraggingPointIndicator.Width, positionX, positionY, null, false); } else if (AdornmentsInfo != null && AdornmentsInfo.Symbol != ChartSymbol.Custom) { AddAnimationEllipse( ChartDictionaries.GenericSymbolDictionary["Animation" + AdornmentsInfo.Symbol.ToString() + "Template"] as ControlTemplate, AdornmentsInfo.SymbolHeight, AdornmentsInfo.SymbolWidth, positionX, positionY, null, true); } } }