当前位置: 首页>>代码示例>>C#>>正文


C# MouseButtons.ToString方法代码示例

本文整理汇总了C#中MouseButtons.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MouseButtons.ToString方法的具体用法?C# MouseButtons.ToString怎么用?C# MouseButtons.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MouseButtons的用法示例。


在下文中一共展示了MouseButtons.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimulateClick

        // TODO:
        //public void SimulateScroll(int x, int y, int screenWidth, int screenHeight, scrollAmount)
        //public void SimulateScroll(scrollAmount)
        // TODO: Simulation which strips the ABSOLUTE factor from the mouse events, making the mouse NOT MOVE, for the click click.
        //public static void SimulateClick(MouseButtons mouseButton, int holdClickTime = 10)
        /// <summary>Simulates a mouse click at the specified location.</summary>
        /// <param name="x">The horizontal pixel coordinate to place the mouse cursor at.</param>
        /// <param name="y">The vertical pixel coordinate to place the mouse cursor at.</param>
        /// <param name="screenWidth">The current screen width (needed to scale the mouse cursor into position).</param>
        /// <param name="screenHeight">The current screen height (needed to scale the mouse cursor into position).</param>
        /// <param name="mouseButton">Which mouse button to simulate a click for.</param>
        /// <param name="holdClickTime">How long to simulate holding the mouse button down, in milliseconds.</param>
        /// <remarks>Basically this is just a pair of simulated mouse "down" and mouse "up" simulations in sequence.</remarks>
        public static void SimulateClick(int x, int y, int screenWidth, int screenHeight, MouseButtons mouseButton, int holdClickTime = 10)
        {
            VirtualMouseAction mouseDownOption, mouseUpOption;
            switch (mouseButton)
            {
                case MouseButtons.Left:
                    mouseDownOption = VirtualMouseAction.LeftButtonDown;
                    mouseUpOption = VirtualMouseAction.LeftButtonUp;
                    break;
                case MouseButtons.Middle:
                    mouseDownOption = VirtualMouseAction.MiddleButtonDown;
                    mouseUpOption = VirtualMouseAction.MiddleButtonUp;
                    break;
                case MouseButtons.Right:
                    mouseDownOption = VirtualMouseAction.RightButtonDown;
                    mouseUpOption = VirtualMouseAction.RightButtonUp;
                    break;
                default:
                    // TODO: Implement and test XButton1 and XButton2 with a fancy mouse.
                    throw new NotSupportedException("The selected mouse button is not yet supported: " + mouseButton.ToString());
            }

            Simulate(x, y, screenWidth, screenHeight, mouseDownOption);
            Thread.Sleep(holdClickTime);
            Simulate(x, y, screenWidth, screenHeight, mouseUpOption);
        }
开发者ID:KarakLive,项目名称:VirtualInput,代码行数:39,代码来源:VirtualMouse.cs

示例2: ButtonUp

        protected override void ButtonUp(MouseButtons button, int x, int y)
        {
            NativeEnums.MouseEventFlags flag;
            switch (button)
            {
                case MouseButtons.Left:
                    flag = NativeEnums.MouseEventFlags.LeftUp;
                    break;

                case MouseButtons.Right:
                    flag = NativeEnums.MouseEventFlags.RightUp;
                    break;

                case MouseButtons.Middle:
                    flag = NativeEnums.MouseEventFlags.MiddleUp;
                    break;

                default:
                    throw new NotImplementedException(button.ToString());
            }
            SendMouseInput(x, y, flag);
        }
开发者ID:TGOSeraph,项目名称:StUtil,代码行数:22,代码来源:MouseSendInputProvider.cs

示例3: AddBinding

 public void AddBinding(string name, MouseButtons mouseButton)
 {
     if (!Bindings_Mouse.Values.Contains(mouseButton))
     {
         if (!Bindings_Mouse.Keys.Contains(name) && !Bindings_Keyboard.Keys.Contains(name))
         {
             Bindings_Mouse[name] = mouseButton;
         }
         else
         {
             throw new Exception("The binding " + name + " already exists.");
         }
     }
     else
     {
         throw new Exception("The button: " + mouseButton.ToString() + " already exists as a binding.");
     }
 }
开发者ID:axis7818,项目名称:AxisEngine,代码行数:18,代码来源:Input.cs

示例4: OnMouseUp

        public override UIHandleResult OnMouseUp(MouseEventArgs args)
        {
            #if DEBUG_MOUSETRACKING
            Debug.WriteLine(_instance + " OnMouseUp: Buttons = " + _pressedButtons.ToString());
            #endif
            if (!IsGrabbing())
                return UIHandleResult.Pass;

            Keys modKeys = Control.ModifierKeys;

            int col, row;
            _control.MousePosToTextPos(args.X, args.Y, out col, out row);

            // Note:
            // We keep this handler in "Captured" status while any other mouse buttons being pressed.
            // "Captured" handler can process mouse events exclusively.
            //
            // This trick would provide good experience to the user,
            // but it doesn't work expectedly in the following scenario.
            //
            //   1. Press left button on Terminal-1
            //   2. Press right button on Terminal-1
            //   3. Move (drag) mouse to Terminal-2
            //   4. Release left button on Terminal-2
            //   5. Release right button on Terminal-2
            //
            // In step 1, System.Windows.Forms.Control object starts mouse capture automatically
            // when left button was pressed.
            // So the next mouse-up event will be notified to the Terminal-1 (step 4).
            // But Control object stops mouse capture by mouse-up event for any button.
            // Mouse-up event of the right button in step 5 will not be notified to the Terminal-1,
            // and the handler of the Terminal-1 will not end "Captured" status.
            //
            // The case like above will happen rarely.
            // To avoid never ending "Captured" status, OnMouseMove() ends "Captured" status
            // if no mouse buttons were set in the MouseEventArgs.Button.
            //

            lock (_terminalSync) {
                if (_terminal != null) {
                    // Mouse tracking mode may be already turned off.
                    // We just ignore result of ProcessMouse().
                    _terminal.ProcessMouse(TerminalMouseAction.ButtonUp, args.Button, modKeys, row, col);
                }
            }

            _pressedButtons &= ~args.Button;

            if (IsGrabbing()) {
            #if DEBUG_MOUSETRACKING
                Debug.WriteLine(_instance + " OnMouseUp: Continue Capture : Buttons = " + _pressedButtons.ToString());
            #endif
                return UIHandleResult.Stop;
            }
            else {
            #if DEBUG_MOUSETRACKING
                Debug.WriteLine(_instance + " OnMouseUp: End Capture : Buttons = " + _pressedButtons.ToString());
            #endif
                return UIHandleResult.EndCapture;
            }
        }
开发者ID:noraviewer,项目名称:PoderosaTerminalControl,代码行数:61,代码来源:TerminalControl.cs

示例5: OnMouseDown

        public override UIHandleResult OnMouseDown(MouseEventArgs args)
        {
            Keys modKeys = Control.ModifierKeys;

            #if DEBUG_MOUSETRACKING
            Debug.WriteLine(_instance + " OnMouseDown: Buttons = " + _pressedButtons.ToString());
            #endif
            if (!IsGrabbing()) {
                if (IsEscaped())
                    return UIHandleResult.Pass; // bypass mouse tracking
            }

            int col, row;
            _control.MousePosToTextPos(args.X, args.Y, out col, out row);

            bool processed;

            lock (_terminalSync) {
                if (_terminal == null)
                    return UIHandleResult.Pass;

                processed = _terminal.ProcessMouse(TerminalMouseAction.ButtonDown, args.Button, modKeys, row, col);
            }

            if (processed) {
                _pressedButtons |= args.Button;
            #if DEBUG_MOUSETRACKING
                Debug.WriteLine(_instance + " OnMouseDown: Processed --> Capture : Buttons = " + _pressedButtons.ToString());
            #endif
                return UIHandleResult.Capture;  // process next mouse events exclusively.
            }
            else {
            #if DEBUG_MOUSETRACKING
                Debug.WriteLine(_instance + " OnMouseDown: Not Processed : Buttons = " + _pressedButtons.ToString());
            #endif
                if (IsGrabbing())
                    return UIHandleResult.Stop;
                else
                    return UIHandleResult.Pass;
            }
        }
开发者ID:noraviewer,项目名称:PoderosaTerminalControl,代码行数:41,代码来源:TerminalControl.cs

示例6: MouseBtnToExtraBtn

 public static ExtraMouseBtns MouseBtnToExtraBtn(MouseButtons button)
 {
     ExtraMouseBtns btn = ExtraMouseBtns.None;
     btn = (ExtraMouseBtns)Enum.Parse(typeof(ExtraMouseBtns), button.ToString());
     return btn;
     //switch (button)
     //{
     //    case MouseButtons.Left: btn = ExtraMouseBtns.Left; break;
     //    case MouseButtons.Right: btn = ExtraMouseBtns.Right; break;
     //    case MouseButtons.Middle: btn = ExtraMouseBtns.Middle; break;
     //    case MouseButtons.XButton1: btn = ExtraMouseBtns.XButton1; break;
     //    case MouseButtons.XButton2: btn = ExtraMouseBtns.XButton2; break;
     //}
     //return btn;
 }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:15,代码来源:ExtraMouse.cs

示例7: IsMouseButtonActive

 /// <summary>
 /// Determines if the mouse button should trigger a screenshot.
 /// </summary>
 /// <param name="button"></param>
 /// <returns></returns>
 private bool IsMouseButtonActive(MouseButtons button)
 {
     return Settings.Default.MouseKeyTriggers.Contains(button.ToString());
 }
开发者ID:squid-box,项目名称:ScreenCapturer,代码行数:9,代码来源:MainWindow.cs

示例8: Register

        public void Register(string mapName, MouseButtons? button)
        {
            if (string.IsNullOrEmpty(mapName))
                throw new MouseManagerException("button name is null or empty!");

            if (_maps.FirstOrDefault(x => string.Equals(x.Name, mapName)) != null)
                throw new MouseManagerException(string.Format("the map \"{0}\" is already registered!", mapName));

            if (_maps.FirstOrDefault(x => string.Equals(x.Button, button)) != null)
                throw new MouseManagerException(string.Format("the button \"{0}\" is already registered in \"{1}\" map!", button.ToString(), mapName));

            lock (_maps) { _maps.Add(new MouseMap { Name = mapName, Button = button }); }
        }
开发者ID:gabry90,项目名称:BIOXFramework,代码行数:13,代码来源:MouseManager.cs

示例9: MouseButtons

 public bool MouseButtons(MouseButtons button)
 {
     RestRequest request = GeneratePost("/steam/mouse/click");
     request.AddParameter("button", button.ToString().ToLower(), ParameterType.GetOrPost);
     return (ProcessRequest(request).StatusCode == HttpStatusCode.Accepted);            
 }
开发者ID:BenWoodford,项目名称:SteamWeb.NET,代码行数:6,代码来源:SteamWebClient.cs


注:本文中的MouseButtons.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。