Beispiel #1
0
        public PointerPointProperties(RawInputModifiers modifiers, PointerUpdateKind kind)
        {
            PointerUpdateKind     = kind;
            IsLeftButtonPressed   = modifiers.HasFlag(RawInputModifiers.LeftMouseButton);
            IsMiddleButtonPressed = modifiers.HasFlag(RawInputModifiers.MiddleMouseButton);
            IsRightButtonPressed  = modifiers.HasFlag(RawInputModifiers.RightMouseButton);

            // The underlying input source might be reporting the previous state,
            // so make sure that we reflect the current state

            if (kind == PointerUpdateKind.LeftButtonPressed)
            {
                IsLeftButtonPressed = true;
            }
            if (kind == PointerUpdateKind.LeftButtonReleased)
            {
                IsLeftButtonPressed = false;
            }
            if (kind == PointerUpdateKind.MiddleButtonPressed)
            {
                IsMiddleButtonPressed = true;
            }
            if (kind == PointerUpdateKind.MiddleButtonReleased)
            {
                IsMiddleButtonPressed = false;
            }
            if (kind == PointerUpdateKind.RightButtonPressed)
            {
                IsRightButtonPressed = true;
            }
            if (kind == PointerUpdateKind.RightButtonReleased)
            {
                IsRightButtonPressed = false;
            }
        }
Beispiel #2
0
        public static MouseButtons ToMouseButtons(this RawInputModifiers modifiers)
        {
            var buttons = MouseButtons.None;

            if (modifiers.HasFlag(RawInputModifiers.LeftMouseButton))
            {
                buttons |= MouseButtons.Left;
            }
            if (modifiers.HasFlag(RawInputModifiers.RightMouseButton))
            {
                buttons |= MouseButtons.Right;
            }
            if (modifiers.HasFlag(RawInputModifiers.MiddleMouseButton))
            {
                buttons |= MouseButtons.Middle;
            }
            if (modifiers.HasFlag(RawInputModifiers.XButton1MouseButton))
            {
                buttons |= MouseButtons.XButton1;
            }
            if (modifiers.HasFlag(RawInputModifiers.XButton2MouseButton))
            {
                buttons |= MouseButtons.XButton2;
            }

            return(buttons);
        }
 private DragDropEffects GetPreferredEffect(DragDropEffects effect, RawInputModifiers modifiers)
 {
     if (effect == DragDropEffects.Copy || effect == DragDropEffects.Move || effect == DragDropEffects.Link || effect == DragDropEffects.None)
     {
         return(effect); // No need to check for the modifiers.
     }
     if (effect.HasFlag(DragDropEffects.Link) && modifiers.HasFlag(RawInputModifiers.Alt))
     {
         return(DragDropEffects.Link);
     }
     if (effect.HasFlag(DragDropEffects.Copy) && modifiers.HasFlag(RawInputModifiers.Control))
     {
         return(DragDropEffects.Copy);
     }
     return(DragDropEffects.Move);
 }
Beispiel #4
0
        public static Keys AddModifiers(Keys keys, RawInputModifiers modifiers)
        {
            if (modifiers.HasFlag(RawInputModifiers.Alt))
            {
                keys |= Modern.Forms.Keys.Alt;
            }
            if (modifiers.HasFlag(RawInputModifiers.Control))
            {
                keys |= Modern.Forms.Keys.Control;
            }
            if (modifiers.HasFlag(RawInputModifiers.Shift))
            {
                keys |= Modern.Forms.Keys.Shift;
            }

            return(keys);
        }