Example #1
0
        private static System.Windows.Input.MouseButton WinFormToWPFMouseButton(System.Windows.Forms.MouseEventArgs e)
        {
            System.Windows.Input.MouseButton btn = System.Windows.Input.MouseButton.Left;
            switch (e.Button)
            {
            case System.Windows.Forms.MouseButtons.Left:
                btn = System.Windows.Input.MouseButton.Left;
                break;

            case System.Windows.Forms.MouseButtons.Middle:
                btn = System.Windows.Input.MouseButton.Middle;
                break;

            case System.Windows.Forms.MouseButtons.Right:
                btn = System.Windows.Input.MouseButton.Right;
                break;

            case System.Windows.Forms.MouseButtons.XButton1:
                btn = System.Windows.Input.MouseButton.XButton1;
                break;

            case System.Windows.Forms.MouseButtons.XButton2:
                btn = System.Windows.Input.MouseButton.XButton2;
                break;
            }

            return(btn);
        }
Example #2
0
        private CjcAwesomiumWrapper.MouseButton GetMouseButton(System.Windows.Input.MouseButton button)
        {
            switch (button)
            {
            case System.Windows.Input.MouseButton.Middle: return(CjcAwesomiumWrapper.MouseButton.Middle);

            case System.Windows.Input.MouseButton.Right: return(CjcAwesomiumWrapper.MouseButton.Right);

            default: return(CjcAwesomiumWrapper.MouseButton.Left);
            }
        }
        void WinFormsControl_MouseUp(object sender, swf.MouseEventArgs e)
        {
            Control.CaptureMouse();

            MouseEventArgs eto = e.ToEto(WinFormsControl);

            swi.MouseButton changed = eto.ToWpf().ChangedButton;
            var             args    = new swi.MouseButtonEventArgs(swi.InputManager.Current.PrimaryMouseDevice, Environment.TickCount, changed)
            {
                RoutedEvent = swi.Mouse.MouseUpEvent,
                Source      = Control
            };

            Control.ReleaseMouseCapture();

            Control.RaiseEvent(args);
        }
        /// <summary>
        /// Let a mouse button up
        /// </summary>
        /// <param name="button"></param>
        public static void MouseUp(System.Windows.Input.MouseButton button)
        {
            switch (button)
            {
            case System.Windows.Input.MouseButton.Left:
                MouseUp(MouseButton.Left);
                break;

            case System.Windows.Input.MouseButton.Middle:
                MouseUp(MouseButton.Middle);
                break;

            case System.Windows.Input.MouseButton.Right:
                MouseUp(MouseButton.Right);
                break;
            }
        }
Example #5
0
        public static swi.MouseButtonEventArgs ToWpf(this MouseEventArgs e)
        {
            swi.MouseButton button = 0;

            if (e.Buttons.HasFlag(MouseButtons.Primary))
            {
                button |= swi.MouseButton.Left;
            }
            if (e.Buttons.HasFlag(MouseButtons.Middle))
            {
                button |= swi.MouseButton.Middle;
            }
            if (e.Buttons.HasFlag(MouseButtons.Alternate))
            {
                button |= swi.MouseButton.Right;
            }

            return(new swi.MouseButtonEventArgs(swi.InputManager.Current.PrimaryMouseDevice, Environment.TickCount, button));
        }
        private static H1MouseButton ConvertMouseButton(System.Windows.Input.MouseButton mouseButton)
        {
            switch (mouseButton)
            {
            case System.Windows.Input.MouseButton.Left:
                return(H1MouseButton.Left);

            case System.Windows.Input.MouseButton.Right:
                return(H1MouseButton.Right);

            case System.Windows.Input.MouseButton.Middle:
                return(H1MouseButton.Middle);

            case System.Windows.Input.MouseButton.XButton1:
                return(H1MouseButton.Extended1);

            case System.Windows.Input.MouseButton.XButton2:
                return(H1MouseButton.Extended2);
            }
            return((H1MouseButton)(-1));
        }
Example #7
0
        public static MouseButtons ToEto(this swi.MouseButton wpfButton)
        {
            MouseButtons etoButton = MouseButtons.None;

            // The System.Windows.Input.MouseButton type isn't a Flags enum, so
            // etoButton doesn't benefit from appending with bitwise OR.
            if (wpfButton == swi.MouseButton.Left)
            {
                etoButton = MouseButtons.Primary;
            }
            else if (wpfButton == swi.MouseButton.Middle)
            {
                etoButton = MouseButtons.Middle;
            }
            else if (wpfButton == swi.MouseButton.Right)
            {
                etoButton = MouseButtons.Alternate;
            }

            return(etoButton);
        }
        private static PointerUpdateKind GetReleasedUpdateKind(System.Windows.Input.MouseButton changedButton)
        {
            switch (changedButton)
            {
            case System.Windows.Input.MouseButton.Left:
                return(PointerUpdateKind.LeftButtonReleased);

            case System.Windows.Input.MouseButton.Middle:
                return(PointerUpdateKind.MiddleButtonReleased);

            case System.Windows.Input.MouseButton.Right:
                return(PointerUpdateKind.RightButtonReleased);

            case System.Windows.Input.MouseButton.XButton1:
                return(PointerUpdateKind.XButton1Released);

            case System.Windows.Input.MouseButton.XButton2:
                return(PointerUpdateKind.XButton2Released);

            default:
                throw new ArgumentOutOfRangeException("changedButton");
            }
        }
        /// <summary>
        /// Translates the <see cref="System.Windows.Input.MouseButton"/> enum (WinForms specific) to platform-independent <see cref="MouseButton"/>.
        /// </summary>
        /// <param name="button">WinForms-specific <see cref="System.Windows.Input.MouseButton"/> value.</param>
        /// <returns>Platform-independent <see cref="MouseButton"/> value.</returns>
        private static MouseButton TranslateButton(System.Windows.Input.MouseButton button)
        {
            switch (button)
            {
            case System.Windows.Input.MouseButton.Left:
                return(MouseButton.Left);

            case System.Windows.Input.MouseButton.Middle:
                return(MouseButton.Middle);

            case System.Windows.Input.MouseButton.Right:
                return(MouseButton.Right);

            case System.Windows.Input.MouseButton.XButton1:
                return(MouseButton.XButton1);

            case System.Windows.Input.MouseButton.XButton2:
                return(MouseButton.XButton2);

            default:
                throw new ArgumentOutOfRangeException("button");
            }
        }
        void WinFormsControl_MouseDown(object sender, swf.MouseEventArgs e)
        {
            // Contrary to most WPF controls, the WindowsFormsHost class seems
            // to prevent correct mouse event data from being obtained (e.g.
            // which buttons were pressed, and at what location). The solution
            // is capturing the mouse long enough to build args...
            Control.CaptureMouse();

            MouseEventArgs eto = e.ToEto(WinFormsControl);

            swi.MouseButton changed = eto.ToWpf().ChangedButton;
            var             args    = new swi.MouseButtonEventArgs(swi.InputManager.Current.PrimaryMouseDevice, Environment.TickCount, changed)
            {
                RoutedEvent = swi.Mouse.MouseDownEvent,
                Source      = Control
            };

            // ...but releasing it before continuing, in case the mouse event in
            // question is one that shouldn't hold onto the mouse.
            Control.ReleaseMouseCapture();

            Control.RaiseEvent(args);
        }
Example #11
0
        /// <summary>
        /// 从<see cref="SystemInput.MouseButton"/>转换至<see cref="Canvas.Input.MouseButton"/>
        /// </summary>
        /// <param name="sysMouseButton"></param>
        /// <returns></returns>
        public static Canvas.Input.MouseButton ConvertToMouseButton(this SystemInput.MouseButton sysMouseButton)
        {
            switch (sysMouseButton)
            {
            case SystemInput.MouseButton.Left:
                return(Canvas.Input.MouseButton.Left);

            case SystemInput.MouseButton.Middle:
                return(Canvas.Input.MouseButton.Middle);

            case SystemInput.MouseButton.Right:
                return(Canvas.Input.MouseButton.Right);

            case SystemInput.MouseButton.XButton1:
                return(Canvas.Input.MouseButton.XButton1);

            case SystemInput.MouseButton.XButton2:
                return(Canvas.Input.MouseButton.XButton2);

            default:
                return(Canvas.Input.MouseButton.UnKnown);
            }
        }
 /// <summary>
 /// Initializes a new HwndMouseEventArgs.
 /// </summary>
 /// <param name="state">The state from which to initialize the properties.</param>
 /// <param name="doubleClickButton">The button that was double clicked.</param>
 public HwndMouseEventArgs(HwndMouseState state, System.Windows.Input.MouseButton doubleClickButton)
     : this(state)
 {
     DoubleClickButton = doubleClickButton;
 }
        /// <summary>
        /// Click a mouse button (down then up)
        /// </summary>
        /// <param name="button"></param>
        //public static void Click(System.Windows.Input.MouseButton button)
        //{
        //    switch (button)
        //    {
        //        case System.Windows.Input.MouseButton.Left:
        //            Click(System.Windows.Input.MouseButton.Left);
        //            break;
        //        case System.Windows.Input.MouseButton.Middle:
        //            Click(System.Windows.Input.MouseButton.Middle);
        //            break;
        //        case System.Windows.Input.MouseButton.Right:
        //            Click(System.Windows.Input.MouseButton.Right);
        //            break;
        //    }
        //}

        /// <summary>
        /// Double click a mouse button (down then up twice)
        /// </summary>
        /// <param name="button"></param>
        public static void DoubleClick(System.Windows.Input.MouseButton button)
        {
            Click(button);
            Click(button);
        }
 /// <summary>
 /// Click a mouse button (down then up)
 /// </summary>
 /// <param name="button"></param>
 public static void Click(System.Windows.Input.MouseButton button)
 {
     MouseDown(button);
     MouseUp(button);
 }