示例#1
0
        internal void OnAnnotationSelected()
        {
            if ((SelectedAnnotation is SolidShapeAnnotation && (SelectedAnnotation as ShapeAnnotation).CanResize))
            {
                AnnotationResizer                = new AnnotationResizer();
                AnnotationResizer.X1             = SelectedAnnotation.X1;
                AnnotationResizer.Y1             = SelectedAnnotation.Y1;
                AnnotationResizer.X2             = (SelectedAnnotation as ShapeAnnotation).X2;
                AnnotationResizer.Y2             = (SelectedAnnotation as ShapeAnnotation).Y2;
                AnnotationResizer.XAxisName      = SelectedAnnotation.XAxisName;
                AnnotationResizer.YAxisName      = SelectedAnnotation.YAxisName;
                AnnotationResizer.XAxis          = selectedAnnotation.XAxis;
                AnnotationResizer.YAxis          = selectedAnnotation.YAxis;
                AnnotationResizer.CoordinateUnit = SelectedAnnotation.CoordinateUnit;
                AnnotationResizer.Angle          = (SelectedAnnotation as SolidShapeAnnotation).Angle;
                AnnotationResizer.InternalHorizontalAlignment = SelectedAnnotation.InternalHorizontalAlignment;
                AnnotationResizer.InternalVerticalAlignment   = SelectedAnnotation.InternalVerticalAlignment;

                if (SelectedAnnotation is SolidShapeAnnotation)
                {
                    AnnotationResizer.ResizingMode = (SelectedAnnotation as SolidShapeAnnotation).ResizingMode;
                }
                AddOrRemoveAnnotationResizer(AnnotationResizer, false);
            }
            else if ((SelectedAnnotation is LineAnnotation && (SelectedAnnotation as LineAnnotation).CanResize))
            {
                if ((SelectedAnnotation as LineAnnotation).nearThumb == null)
                {
                    (selectedAnnotation as LineAnnotation).AddThumb();
                }
                (SelectedAnnotation as LineAnnotation).nearThumb.Visibility = Visibility.Visible;
                (SelectedAnnotation as LineAnnotation).farThumb.Visibility  = Visibility.Visible;
                (SelectedAnnotation as LineAnnotation).UpdateAnnotation();
            }
        }
示例#2
0
        private void UpdateResizingPath(AxisMode path)
        {
            AnnotationResizer annotationResizer = Chart.AnnotationManager.AnnotationResizer;

            if (annotationResizer != null)
            {
                if (annotationResizer.ResizingMode != path)
                {
                    annotationResizer.ResizingMode = path;
                    annotationResizer.ResizerControl.ChangeView();
                }
            }
        }
示例#3
0
        private void OnAxisBoundsChanged(object sender, ChartAxisBoundsEventArgs e)
        {
            foreach (Annotation annotation in this.Annotations)
            {
                if (annotation.XAxis == sender || annotation.YAxis == sender)
                {
                    annotation.UpdateAnnotation();
                }
            }

            if (AnnotationResizer != null && (AnnotationResizer.XAxis == sender || AnnotationResizer.YAxis == sender))
            {
                AnnotationResizer.UpdateAnnotation();
                AnnotationResizer.MapActualValueToPixels();
            }
        }
示例#4
0
        private void AnnotationDrag(double xTranslate, double yTranslate)
        {
            ShapeAnnotation selectedAnnotation = (SelectedAnnotation as ShapeAnnotation);
            var             lineAnnotation     = selectedAnnotation as LineAnnotation;
            bool            isDraggable        = (selectedAnnotation.CanResize && AnnotationResizer != null) ?
                                                 !AnnotationResizer.IsResizing :
                                                 (lineAnnotation != null) ?
                                                 !lineAnnotation.IsResizing :
                                                 true;
            object x1, x2, y1, y2;

            if (selectedAnnotation.CanDrag && isDraggable)
            {
                selectedAnnotation.IsDragging = true;
                bool isXAxis = selectedAnnotation.DraggingMode == AxisMode.Horizontal;
                bool isYAxis = selectedAnnotation.DraggingMode == AxisMode.Vertical;
                bool isAll   = selectedAnnotation.DraggingMode == AxisMode.All;
                if (selectedAnnotation.CoordinateUnit == CoordinateUnit.Pixel)
                {
                    x1 = (isAll || isXAxis) ? Convert.ToDouble(selectedAnnotation.X1) + xTranslate : selectedAnnotation.X1;
                    x2 = (isAll || isXAxis) ? Convert.ToDouble(selectedAnnotation.X2) + xTranslate : selectedAnnotation.X2;
                    y1 = (isAll || isYAxis) ? Convert.ToDouble(selectedAnnotation.Y1) + yTranslate : selectedAnnotation.Y1;
                    y2 = (isAll || isYAxis) ? Convert.ToDouble(selectedAnnotation.Y2) + yTranslate : selectedAnnotation.Y2;
                }
                else
                {
                    xTranslate = selectedAnnotation.XAxis.IsInversed ? -xTranslate : xTranslate;
                    yTranslate = selectedAnnotation.YAxis.IsInversed ? -yTranslate : yTranslate;
                    double xAxisChange = selectedAnnotation.XAxis.PixelToCoefficientValue(xTranslate);
                    double yAxisChange = selectedAnnotation.YAxis.PixelToCoefficientValue(yTranslate);

                    x2 = (isAll || isXAxis) ? Annotation.ConvertToObject(CalculatePointValue(selectedAnnotation.X2, xAxisChange, true, false), selectedAnnotation.XAxis) : selectedAnnotation.X2;
                    x1 = (isAll || isXAxis) ? Annotation.ConvertToObject(CalculatePointValue(selectedAnnotation.X1, xAxisChange, true, false), selectedAnnotation.XAxis) : selectedAnnotation.X1;
                    y2 = (isAll || isYAxis) ? Annotation.ConvertToObject(CalculatePointValue(selectedAnnotation.Y2, yAxisChange, false, false), selectedAnnotation.YAxis) : selectedAnnotation.Y2;
                    y1 = (isAll || isYAxis) ? Annotation.ConvertToObject(CalculatePointValue(selectedAnnotation.Y1, yAxisChange, false, false), selectedAnnotation.YAxis) : selectedAnnotation.Y1;
                }

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

                AnnotationManager.SetPosition(CurrentPoints, x1, x2, y1, y2);
                RaiseDragStarted(); // Raise DragStarted event
                RaiseDragDelta();   // Raise the DragDelta event

                if (!DragDeltaArgs.Cancel)
                {
                    if (AnnotationResizer != null && !AnnotationResizer.IsResizing)
                    {
                        selectedAnnotation.X1 = AnnotationResizer.X1 = x1;
                        selectedAnnotation.X2 = AnnotationResizer.X2 = x2;
                        selectedAnnotation.Y1 = AnnotationResizer.Y1 = y1;
                        selectedAnnotation.Y2 = AnnotationResizer.Y2 = y2;
                    }
                    else
                    {
                        selectedAnnotation.X1 = x1;
                        selectedAnnotation.X2 = x2;
                        selectedAnnotation.Y1 = y1;
                        selectedAnnotation.Y2 = y2;
                    }

                    var axisMarker = selectedAnnotation as AxisMarker;
                    if (axisMarker != null)
                    {
                        if (axisMarker.ParentAnnotation is VerticalLineAnnotation)
                        {
                            if (axisMarker.ParentAnnotation.XAxis.Orientation == Orientation.Horizontal)
                            {
                                axisMarker.ParentAnnotation.X1 = selectedAnnotation.X1;
                            }
                            else
                            {
                                axisMarker.ParentAnnotation.Y1 = selectedAnnotation.Y1;
                            }
                        }
                        else
                        {
                            if (axisMarker.ParentAnnotation.XAxis.Orientation == Orientation.Vertical)
                            {
                                axisMarker.ParentAnnotation.X1 = selectedAnnotation.X1;
                            }
                            else
                            {
                                axisMarker.ParentAnnotation.Y1 = selectedAnnotation.Y1;
                            }
                        }
                    }

                    if (AnnotationResizer != null)
                    {
                        AnnotationResizer.MapActualValueToPixels();
                    }
                }

                selectedAnnotation.IsDragging = false;
            }
        }