Example #1
0
 private void HandleMouseInput(object sender, SharpDX.RawInput.MouseInputEventArgs e)
 {
     if (MouseInputEvent != null)
     {
         MouseInputEvent(sender, new MouseEventArgs(e));
     }
 }
Example #2
0
 public MouseEventArgs(SharpDX.RawInput.MouseInputEventArgs e)
 {
     ButtonFlags      = (ButtonFlags)e.ButtonFlags;
     ExtraInformation = e.ExtraInformation;
     WheelDelta       = e.WheelDelta;
     X = e.X;
     Y = e.Y;
 }
Example #3
0
        /// <summary>
        /// Handler for the ScrollWheel.
        /// </summary>
        private void InputEvents_Scroll(object sender, SharpDX.RawInput.MouseInputEventArgs e)
        {
            if (Properties.EnableScroll && Properties.Sequence.keys.Count > 1)
            {
                // If there's no active key or the ks doesn't contain it (e.g. the sequence was just changed), make the first one active.
                if (activeKey == DeviceKeys.NONE || !Properties.Sequence.keys.Contains(activeKey))
                {
                    activeKey = Properties.Sequence.keys[0];
                }

                // If there's an active key make scroll move up/down
                else
                {
                    // Target index is the current index +/- 1 depending on the scroll value
                    int idx = Properties.Sequence.keys.IndexOf(activeKey) + (e.WheelDelta > 0 ? -1 : 1);

                    // If scroll loop is enabled, allow the index to wrap around from start to end or end to start.
                    if (Properties.ScrollLoop)
                    {
                        if (idx < 0) // If index is now negative (if first item selected and scrolling down), add the length to loop back
                        {
                            idx += Properties.Sequence.keys.Count;
                        }
                        idx = idx % Properties.Sequence.keys.Count;

                        // If scroll loop isn't enabled, cap the index so that it stops at either end
                    }
                    else
                    {
                        idx = Math.Max(Math.Min(idx, Properties.Sequence.keys.Count - 1), 0);
                    }

                    activeKey = Properties.Sequence.keys[idx];
                }
            }
        }