/// <summary>
 /// Fires the event to any listeners.
 /// </summary>
 /// <param name="args">Arguments to send.</param>
 private void RaiseEvent(MouseChangeEventArgs args)
 {
     if (!object.ReferenceEquals(null, MouseChangeEvent))
     {
         MouseChangeEvent.Invoke(this, args);
     }
 }
        /// <summary>
        /// Parses event and builds event args.
        /// </summary>
        /// <param name="wParam">Type of event.</param>
        /// <param name="mouse">Mouse event properties.</param>
        /// <returns>Strongly typed event info.</returns>
        private MouseChangeEventArgs BuildEventArgs(WindowsMessages wParam, MouseLowLevelHookStruct mouse)
        {
            var args = new MouseChangeEventArgs()
            {
                Button          = ButtonSource.Unknown,
                ButtonDirection = ButtonChangeDirection.Unknown,
                DeltaPosition   = WindowsPoint.Invalid,
                EventType       = MouseEventType.Unknown,
                NewPosition     = WindowsPoint.Invalid,
                Scroll          = ScrollSource.Unknown,
                ScrollDirection = ScrollChangeDirection.Unknown,
            };

            if (wParam == WindowsMessages.MOUSEWHEEL)
            {
                args.EventType = MouseEventType.Scroll;
                args.Scroll    = ScrollSource.VerticalScrollWheel;
                if (mouse.mouseData > 0)
                {
                    args.ScrollDirection = ScrollChangeDirection.Up;
                }
                else
                {
                    args.ScrollDirection = ScrollChangeDirection.Down;
                }
            }
            else if (wParam == WindowsMessages.MOUSEHWHEEL)
            {
                args.EventType = MouseEventType.Scroll;
                args.Scroll    = ScrollSource.HorizontalScrollWheel;
                if (mouse.mouseData > 0)
                {
                    args.ScrollDirection = ScrollChangeDirection.Up;
                }
                else
                {
                    args.ScrollDirection = ScrollChangeDirection.Down;
                }
            }
            else if (wParam == WindowsMessages.MOUSEMOVE)
            {
                args.EventType     = MouseEventType.Move;
                args.DeltaPosition = _previousePosition.Delta(mouse.pt);
                _previousePosition = mouse.pt;
                args.NewPosition   = new WindowsPoint(mouse.pt.X, mouse.pt.Y);
            }
            else if (wParam == WindowsMessages.LBUTTONDOWN)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.LeftButton;
                args.ButtonDirection = ButtonChangeDirection.Down;
            }
            else if (wParam == WindowsMessages.LBUTTONUP)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.LeftButton;
                args.ButtonDirection = ButtonChangeDirection.Up;
            }
            else if (wParam == WindowsMessages.RBUTTONDOWN)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.RightButton;
                args.ButtonDirection = ButtonChangeDirection.Down;
            }
            else if (wParam == WindowsMessages.RBUTTONUP)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.RightButton;
                args.ButtonDirection = ButtonChangeDirection.Up;
            }
            else if (wParam == WindowsMessages.MBUTTONDOWN)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.MiddleButton;
                args.ButtonDirection = ButtonChangeDirection.Down;
            }
            else if (wParam == WindowsMessages.MBUTTONUP)
            {
                args.EventType       = MouseEventType.Button;
                args.Button          = ButtonSource.MiddleButton;
                args.ButtonDirection = ButtonChangeDirection.Up;
            }
            else if (wParam == WindowsMessages.XBUTTONDOWN)
            {
                args.EventType       = MouseEventType.Button;
                args.ButtonDirection = ButtonChangeDirection.Down;

                if ((mouse.flags & 0x01) > 0 && (mouse.mouseData & 0x10000) > 0)
                {
                    args.Button = ButtonSource.Mouse4;
                }
                else if ((mouse.flags & 0x01) > 0 && (mouse.mouseData & 0x20000) > 0)
                {
                    args.Button = ButtonSource.Mouse5;
                }
            }
            else if (wParam == WindowsMessages.XBUTTONUP)
            {
                args.EventType       = MouseEventType.Button;
                args.ButtonDirection = ButtonChangeDirection.Up;

                if ((mouse.flags & 0x01) > 0 && (mouse.mouseData & 0x10000) > 0)
                {
                    args.Button = ButtonSource.Mouse4;
                }
                else if ((mouse.flags & 0x01) > 0 && (mouse.mouseData & 0x20000) > 0)
                {
                    args.Button = ButtonSource.Mouse5;
                }
            }

            return(args);
        }