Example #1
0
        /// <summary>
        /// 从<see cref="SystemInput.MouseButtonState"/>转换至<see cref="Canvas.Input.MouseButtonState"/>
        /// </summary>
        /// <param name="sysMouseButtonState"></param>
        /// <returns></returns>
        public static Canvas.Input.MouseButtonState ConvertToMouseButtonState(this SystemInput.MouseButtonState sysMouseButtonState)
        {
            switch (sysMouseButtonState)
            {
            case SystemInput.MouseButtonState.Released:
                return(Canvas.Input.MouseButtonState.Released);

            case SystemInput.MouseButtonState.Pressed:
                return(Canvas.Input.MouseButtonState.Pressed);

            default:
                break;
            }

            return(Canvas.Input.MouseButtonState.Released);
        }
Example #2
0
        public static MouseButtons GetEtoButtons(this swi.MouseButtonEventArgs e, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed)
        {
            var buttons = MouseButtons.None;

            if (e.ChangedButton == swi.MouseButton.Left && e.LeftButton == buttonState)
            {
                buttons |= MouseButtons.Primary;
            }
            if (e.ChangedButton == swi.MouseButton.Right && e.RightButton == buttonState)
            {
                buttons |= MouseButtons.Alternate;
            }
            if (e.ChangedButton == swi.MouseButton.Middle && e.MiddleButton == buttonState)
            {
                buttons |= MouseButtons.Middle;
            }
            return(buttons);
        }
Example #3
0
        public static MouseEventArgs ToEto(this swi.MouseWheelEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed)
        {
            var buttons = MouseButtons.None;

            if (e.LeftButton == buttonState)
            {
                buttons |= MouseButtons.Primary;
            }
            if (e.RightButton == buttonState)
            {
                buttons |= MouseButtons.Alternate;
            }
            if (e.MiddleButton == buttonState)
            {
                buttons |= MouseButtons.Middle;
            }
            var modifiers = KeyMap.Convert(swi.Key.None, swi.Keyboard.Modifiers);
            var location  = e.GetPosition(control).ToEto();
            var delta     = new SizeF(0, (float)e.Delta / WheelDelta);

            return(new MouseEventArgs(buttons, modifiers, location, delta));
        }
Example #4
0
        public static MouseEventArgs ToEto(this swi.MouseButtonEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed)
        {
            var buttons = MouseButtons.None;

            if (e.ChangedButton == swi.MouseButton.Left && e.LeftButton == buttonState)
            {
                buttons |= MouseButtons.Primary;
            }
            if (e.ChangedButton == swi.MouseButton.Right && e.RightButton == buttonState)
            {
                buttons |= MouseButtons.Alternate;
            }
            if (e.ChangedButton == swi.MouseButton.Middle && e.MiddleButton == buttonState)
            {
                buttons |= MouseButtons.Middle;
            }
            var modifiers = KeyMap.Convert(swi.Key.None, swi.Keyboard.Modifiers);
            var location  = e.GetPosition(control).ToEto();

            return(new MouseEventArgs(buttons, modifiers, location));
        }
Example #5
0
        public static MouseEventArgs ToEto(this swi.MouseButtonEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed)
        {
            var buttons   = e.GetEtoButtons(buttonState);
            var modifiers = swi.Keyboard.Modifiers.ToEto();
            var location  = e.GetPosition(control).ToEto();

            return(new MouseEventArgs(buttons, modifiers, location));
        }