Esempio n. 1
0
        /// <summary>
        /// ScrollBar supports 'Move-To-Point' by pre-processes Shift+MouseLeftButton Click.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            _thumbOffset = new Vector();
            if ((Track != null) &&
                (Track.IsMouseOver) &&
                ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift))
            {
                // Move Thumb to the Mouse location
                Point  pt       = e.MouseDevice.GetPosition((IInputElement)Track);
                double newValue = Track.ValueFromPoint(pt);
                if (System.Windows.Shapes.Shape.IsDoubleFinite(newValue))
                {
                    ChangeValue(newValue, false /* defer */);
                }

                if (Track.Thumb != null && Track.Thumb.IsMouseOver)
                {
                    Point thumbPoint = e.MouseDevice.GetPosition((IInputElement)Track.Thumb);
                    _thumbOffset = thumbPoint - new Point(Track.Thumb.ActualWidth * 0.5, Track.Thumb.ActualHeight * 0.5);
                }
                else
                {
                    e.Handled = true;
                }
            }

            base.OnPreviewMouseLeftButtonDown(e);
        }
Esempio n. 2
0
        /// <summary>
        /// Scroll to the position where ContextMenu was invoked.
        /// </summary>
        internal void ScrollToLastMousePoint()
        {
            Point pt = new Point(-1, -1);

            if ((Track != null) && (_latestRightButtonClickPoint != pt))
            {
                double newValue = Track.ValueFromPoint(_latestRightButtonClickPoint);
                if (System.Windows.Shapes.Shape.IsDoubleFinite(newValue))
                {
                    ChangeValue(newValue, false /* defer */);
                    _latestRightButtonClickPoint = pt;
                    RaiseScrollEvent(ScrollEventType.ThumbPosition);
                }
            }
        }