Example #1
0
        private void CurrentLineOnDragDelta(object sender, AnnotationDragDeltaEventArgs e)
        {
            if (LinkedChartSurface == null)
            {
                return;
            }

            if (sender is LineAnnotation line && line.Tag != null && ((string)line.Tag).StartsWith("Added"))
            {
                if (line == _currentLine || line == _currentLinkedLine)
                {
                    return;
                }

                var otherLine = ParentSurface.Annotations.OfType <LineAnnotation>().FirstOrDefault(x => x.Tag != null && x.Tag.Equals(line.Tag));

                if (otherLine == line)
                {
                    otherLine = LinkedChartSurface.Annotations.OfType <LineAnnotation>().FirstOrDefault(x => x.Tag != null && x.Tag.Equals(line.Tag));
                }

                if (otherLine != null)
                {
                    var categoryCoordCalc      = (ICategoryCoordinateCalculator)line.ParentSurface.XAxis.GetCurrentCoordinateCalculator();
                    var otherCategoryCoordCalc = (ICategoryCoordinateCalculator)otherLine.ParentSurface.XAxis.GetCurrentCoordinateCalculator();

                    if (line.X1 is DateTime time1)
                    {
                        otherLine.X1 = otherCategoryCoordCalc.TransformDataToIndex(time1);
                    }
                    else
                    {
                        otherLine.X1 = otherCategoryCoordCalc.TransformDataToIndex(categoryCoordCalc.TransformIndexToData((int)line.X1));
                    }

                    if (line.X2 is DateTime time2)
                    {
                        otherLine.X2 = otherCategoryCoordCalc.TransformDataToIndex(time2);
                    }
                    else
                    {
                        otherLine.X2 = otherCategoryCoordCalc.TransformDataToIndex(categoryCoordCalc.TransformIndexToData((int)line.X2));
                    }

                    otherLine.Y1 = line.Y1;
                    otherLine.Y2 = line.Y2;
                }

                _chartingService.RaiseChartLinesChanged();
            }
        }
Example #2
0
 private void VerticalChanged(object sender, AnnotationDragDeltaEventArgs e)
 {
     Update();
 }
Example #3
0
 private void HorizontalChanged(object sender, AnnotationDragDeltaEventArgs e)
 {
     Update();
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationManager"/> class.
 /// </summary>
 public AnnotationManager()
 {
     PreviousPoints = new Position();
     CurrentPoints  = new Position();
     DragDeltaArgs  = new AnnotationDragDeltaEventArgs();
 }