Ejemplo n.º 1
0
        /// <summary>
        /// Called when a Mouse Button is pressed on the parent <see cref="SciChartSurface"/>
        /// </summary>
        /// <param name="e">Arguments detailing the mouse button operation</param>
        /// <remarks></remarks>
        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            base.OnModifierMouseDown(e);

            if (_isDragging || !MatchesExecuteOn(e.MouseButtons, ExecuteOn))
            {
                return;
            }

            // Exit if the mouse down was outside the bounds of the ModifierSurface
            if (e.IsMaster && !ModifierSurface.GetBoundsRelativeTo(ModifierSurface).Contains(e.MousePoint))
            {
                return;
            }

            e.Handled = true;

            ModifierSurface.CaptureMouse();

            // Translate the mouse point (which is in RootGrid coordiantes) relative to the ModifierSurface
            // This accounts for any offset due to left Y-Axis
            Point ptTrans = RootGrid.TranslatePoint(e.MousePoint, ModifierSurface);

            _startPoint = ptTrans;
            _rectangle  = new Rect();

            SetPosition(_startPoint, _startPoint);

            _isDragging = true;
        }
        /// <summary>
        /// Called when a Mouse Button is pressed on the parent <see cref="SciChartSurface" />
        /// </summary>
        /// <param name="e">Arguments detailing the mouse button operation</param>
        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            base.OnModifierMouseDown(e);

            // Check the ExecuteOn property and if we are already dragging. If so, exit
            if (_isDragging || !MatchesExecuteOn(e.MouseButtons, ExecuteOn))
            {
                return;
            }

            // Check the mouse point was inside the ModifierSurface (the central chart area). If not, exit
            var modifierSurfaceBounds = ModifierSurface.GetBoundsRelativeTo(RootGrid);

            if (!modifierSurfaceBounds.Contains(e.MousePoint))
            {
                return;
            }

            // Capture the mouse, so if mouse goes out of bounds, we retain mouse events
            if (e.IsMaster)
            {
                ModifierSurface.CaptureMouse();
            }

            // Translate the mouse point (which is in RootGrid coordiantes) relative to the ModifierSurface
            // This accounts for any offset due to left Y-Axis
            var ptTrans = GetPointRelativeTo(e.MousePoint, ModifierSurface);

            _startPoint = ptTrans;
            _rectangle  = new Rectangle
            {
                Style = SelectionPolygonStyle,
            };

            // Update the zoom recticule position
            SetReticulePosition(_rectangle, _startPoint, _startPoint, e.IsMaster);

            // Add the zoom reticule to the ModifierSurface - a canvas over the chart
            ModifierSurface.Children.Add(_rectangle);

            // Set flag that a drag has begun
            _isDragging = true;
        }