private void OnPreviewMouseWheel(IInputElement originalSource, MouseWheelInputEventArgs ie)
        {
            // Update wheel motion info
            var info = ie.Wheel.PreTransmit(ie.Timestamp, ie.Delta);

            // 1. Tunneling event
            // Clients and behaviors use this tunneling event to update the wheel transfer
            // case by dynamically creating / retrieving motion shafts.
            ie.RoutedEvent = PreviewMouseWheelInputEvent;
            originalSource.RaiseEvent(ie);

            // In cooperation with clients and behaviors, if inputEventArgs.Handled is set to true,
            // the controller lets the underlying mouse wheel tunneling event continue its route.
            if (ie.Handled)
            {
                return;
            }

            // Fill motion reservoir
            ie.Wheel.Transmit(info, ie.Delta, null);

            // 2. Bubbling event
            // Clients consume the motion here
            ie.RoutedEvent = MouseWheelInputEvent;
            originalSource.RaiseEvent(ie);

            // 3. Remaining motion is processed here
            ie.EndCommand();
        }
        private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var originalSource = this.GetOriginalSource(e);
            var ie             = new MouseWheelInputEventArgs(this, e.MouseDevice.GetWheel(), e.Timestamp, e.Delta, Orientation.Vertical);

            this.OnPreviewMouseWheel(originalSource, ie);

            e.Handled = true;
        }
        private void OnPreviewInput(object sender, MouseWheelInputEventArgs e)
        {
            Debug.Assert(sender == this.Element);
            var client = this._clients.FirstOrDefault(c => c.IsActive(e));

            if (client != null)
            {
                client.OnPreviewInput(sender, e);
            }
        }
        private void OnInput(object sender, MouseWheelInputEventArgs e)
        {
            Debug.Assert(sender == this.Element);
            e.Controller = this;
            var client = this._clients.FirstOrDefault(c => c.IsActive(e));

            if (client != null)
            {
                this._exitElement = client.ExitElement;
                client.OnInput(sender, e);
            }
        }
        protected bool TransferMotion(MouseWheelInputEventArgs e)
        {
            var shaft = this.GetMotionShaft(e.Wheel);

            if (shaft.Transfer(this.MotionInput, e))
            {
                return(true); // client can still move - stop event propagation
            }
            if (this.NestedMotionEnabled)
            {
                return(false); // let the mouse wheel event propagate up the visual tree
            }
            // empty the shaft transfer staging area and stop event propagation
            return(shaft.Transfer(NativeMotionTarget.Terminal, e));
        }
        private IntPtr MouseHorizontalWheelHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
            case WM_MOUSEHWHEEL:
            {
                var timestamp      = Environment.TickCount;
                var originalSource = Mouse.DirectlyOver;
                var delta          = wParam.ToInt32() >> 16;
                var ie             = new MouseWheelInputEventArgs(this, MouseWheel.Current, timestamp, -delta, Orientation.Horizontal);
                this.OnPreviewMouseWheel(originalSource, ie);
                break;
            }
            }

            return(IntPtr.Zero);
        }
 public virtual void OnInput(object sender, MouseWheelInputEventArgs e)
 {
     e.Handled = this.TransferMotion(e);
 }
 public virtual void OnPreviewInput(object sender, MouseWheelInputEventArgs e)
 {
     e.Handled = this.GetMotionShaft(e.Wheel) == null;
 }
 protected bool TransferMotionNative(MouseWheelInputEventArgs e)
 {
     return(this.GetMotionShaft(e.Wheel).Transfer(this, e));
 }
 public override bool IsActive(MouseWheelInputEventArgs e)
 {
     return(e.Orientation == Orientation.Vertical && base.IsActive(e));
 }