Ejemplo n.º 1
0
        /// <summary>
        /// Maps the co-ordinates values to points.
        /// </summary>
        private void MapPixelToActualValue()
        {
            double x1Value, x2Value, y1Value, y2Value;

            if (isSwapX)
            {
                x1Value = isAxis ? SfChart.PointToAnnotationValue(XAxis, isRotated ? new Point(0, x2) : new Point(x2, 0)) : x2;
                x2Value = isAxis ? SfChart.PointToAnnotationValue(XAxis, isRotated ? new Point(0, x1) : new Point(x1, 0)) : x1;
            }
            else
            {
                x1Value = isAxis ? SfChart.PointToAnnotationValue(XAxis, isRotated ? new Point(0, x1) : new Point(x1, 0)) : x1;
                x2Value = isAxis ? SfChart.PointToAnnotationValue(XAxis, isRotated ? new Point(0, x2) : new Point(x2, 0)) : x2;
            }

            if (isSwapY)
            {
                y2Value = isAxis ? SfChart.PointToAnnotationValue(YAxis, isRotated ? new Point(y1, 0) : new Point(0, y1)) : y1;
                y1Value = isAxis ? SfChart.PointToAnnotationValue(YAxis, isRotated ? new Point(y2, 0) : new Point(0, y2)) : y2;
            }
            else
            {
                y2Value = isAxis ? SfChart.PointToAnnotationValue(YAxis, isRotated ? new Point(y2, 0) : new Point(0, y2)) : y2;
                y1Value = isAxis ? SfChart.PointToAnnotationValue(YAxis, isRotated ? new Point(y1, 0) : new Point(0, y1)) : y1;
            }

            AnnotationManager annotationManager = chart.AnnotationManager;

            ShapeAnnotation annotation = annotationManager.CurrentAnnotation as ShapeAnnotation;

            AnnotationManager.SetPosition(
                annotationManager.PreviousPoints,
                annotation.X1,
                annotation.X2,
                annotation.Y1,
                annotation.Y2);

            AnnotationManager.SetPosition(annotationManager.CurrentPoints, x1Value, x2Value, y1Value, y2Value);
            annotationManager.RaiseDragStarted(); // Raise the DragStarted event
            annotationManager.RaiseDragDelta();   // Raise the DragDelta event

            if (!annotationManager.DragDeltaArgs.Cancel)
            {
                ActualX1 = x1Value;
                ActualY1 = y1Value;
                ActualX2 = x2Value;
                ActualY2 = y2Value;
            }
        }
Ejemplo n.º 2
0
        private void OnNearThumbDragDelta(object sender, DragDeltaEventArgs e)
        {
            this.IsResizing   = true;
            annotationManager = Chart.AnnotationManager;
            double x2 = 0, y2 = 0;

            isRotated        = (XAxis != null && XAxis.Orientation == Orientation.Vertical && IsAxis);
            HorizontalChange = isRotated ? e.VerticalChange : e.HorizontalChange;
            VerticalChange   = isRotated ? e.HorizontalChange : e.VerticalChange;

            ShapeAnnotation annotation = annotationManager.CurrentAnnotation as ShapeAnnotation;

            AnnotationManager.SetPosition(
                annotationManager.PreviousPoints,
                annotation.X1,
                annotation.X2,
                annotation.Y1,
                annotation.Y2);

            if (!isRotated)
            {
                if (IsHorizontal)
                {
                    x2 = IsAxis ? SfChart.PointToAnnotationValue(XAxis, new Point(ActualX2 + HorizontalChange, 0)) : ActualX2 + HorizontalChange;

                    AnnotationManager.SetPosition(
                        annotationManager.CurrentPoints,
                        annotation.X1,
                        x2,
                        annotation.Y1,
                        annotation.Y2);
                }

                if (IsVertical)
                {
                    y2 = IsAxis ? SfChart.PointToAnnotationValue(YAxis, new Point(0, ActualY2 + VerticalChange)) : ActualY2 + VerticalChange;

                    AnnotationManager.SetPosition(
                        annotationManager.CurrentPoints,
                        annotation.X1,
                        annotation.X2,
                        annotation.Y1,
                        y2);
                }
            }
            else
            {
                if (IsVertical)
                {
                    x2 = IsAxis ? SfChart.PointToAnnotationValue(XAxis, new Point(0, ActualX2 + HorizontalChange)) : ActualX2 + HorizontalChange;

                    AnnotationManager.SetPosition(
                        annotationManager.CurrentPoints,
                        annotation.X1,
                        x2,
                        annotation.Y1,
                        annotation.Y2);
                }

                if (IsHorizontal)
                {
                    y2 = IsAxis ? SfChart.PointToAnnotationValue(YAxis, new Point(ActualY2 + VerticalChange, 0)) : ActualY2 + VerticalChange;

                    AnnotationManager.SetPosition(
                        annotationManager.CurrentPoints,
                        annotation.X1,
                        annotation.X2,
                        annotation.Y1,
                        y2);
                }
            }

            annotationManager.RaiseDragStarted(); // Raise the DragStarted event
            annotationManager.RaiseDragDelta();   // Raise the DragDelta event

            if (!annotationManager.DragDeltaArgs.Cancel)
            {
                if ((!isRotated && IsHorizontal) || (isRotated && IsVertical))
                {
                    ActualX2 = x2;
                }
                if ((!isRotated && IsVertical) || (isRotated && IsHorizontal))
                {
                    ActualY2 = y2;
                }
            }
        }