Пример #1
0
        private static void chart_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            RadCartesianChart chart        = (RadCartesianChart)sender;
            Point             fromPosition = e.GetPosition(chart);

            SetFromPosition(chart, fromPosition);
            SetToPosition(chart, fromPosition);
            var plotAreaClip = chart.PlotAreaClip;

            plotAreaClip.X += chart.PanOffset.X;
            plotAreaClip.Y += chart.PanOffset.Y;

            if (!plotAreaClip.Contains(fromPosition.X, fromPosition.Y))
            {
                return;
            }

            chart.CaptureMouse();

            Canvas           adorner            = Telerik.Windows.Controls.ChildrenOfTypeExtensions.ChildrenOfType <Canvas>(chart).First(c => c.Name == "adornerContainer");
            Style            style              = GetSelectionRectangleStyle(chart);
            FrameworkElement selectionRectangle = BuildSelectionRectangle(style);

            adorner.Children.Add(selectionRectangle);
            UpdateSelectionRectanglePositionAndSize(chart);
            SetIsSelectionRectangleShown(chart, true);
        }
        private static void Chart_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            RadCartesianChart chart      = (RadCartesianChart)sender;
            CameraInfo        cameraInfo = GetOrCreateCameraInfo(chart);

            object hOffsetResource = chart.TryFindResource("hOffset");
            object vOffsetResource = chart.TryFindResource("vOffset");
            double hOffset         = hOffsetResource is double?(double)hOffsetResource : 0.0;
            double vOffset         = vOffsetResource is double?(double)vOffsetResource : 0.0;

            cameraInfo.mouseDownPosition = e.GetPosition(chart);
            cameraInfo.mouseDownOffset   = new Point(hOffset, vOffset);
            cameraInfo.isMouseCaptured   = true;
            chart.CaptureMouse();
        }