本文整理汇总了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);
}
示例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);
}
示例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.");
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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());
}
示例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 }); }
}
示例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);
}