public override UIHandleResult OnMouseUp(MouseEventArgs args) { if (!_control.EnabledEx) { return(UIHandleResult.Pass); } if (args.Button == MouseButtons.Right || args.Button == MouseButtons.Middle) { ITerminalEmulatorOptions opt = TerminalEmulatorPlugin.Instance.TerminalEmulatorOptions; MouseButtonAction act = args.Button == MouseButtons.Right? opt.RightButtonAction : opt.MiddleButtonAction; if (act != MouseButtonAction.None) { if (Control.ModifierKeys == Keys.Shift ^ act == MouseButtonAction.ContextMenu) //シフトキーで動作反転 { ShowContextMenu(new Point(args.X, args.Y)); } else //Paste { IGeneralViewCommands vc = (IGeneralViewCommands)_control.GetAdapter(typeof(IGeneralViewCommands)); TerminalEmulatorPlugin.Instance.GetCommandManager().Execute(vc.Paste, (ICommandTarget)vc.GetAdapter(typeof(ICommandTarget))); //ペースト後はフォーカス if (!_control.Focused) { _control.Focus(); } } return(UIHandleResult.Stop); } } return(UIHandleResult.Pass); }
/// <summary> /// Add a new listener to the specific action passed in. /// </summary> /// <param name="action">The action to listen for.</param> /// <param name="listener">The listener to alert.</param> public void AddListener(MouseButtonAction action, MouseButtonListener listener) { switch (action) { case MouseButtonAction.Down: if (downListeners == null) { downListeners = new List <MouseButtonListener>(); } downListeners.Add(listener); break; case MouseButtonAction.Pressed: if (pressedListeners == null) { pressedListeners = new List <MouseButtonListener>(); } pressedListeners.Add(listener); break; case MouseButtonAction.Up: if (upListeners == null) { upListeners = new List <MouseButtonListener>(); } upListeners.Add(listener); break; } }
public MapMouseButtonForm(PadTieForm main, Controller cc, MouseButtonAction editing) : this(main, cc) { this.editing = editing; mouseButton.SelectedIndex = (int)editing.Button; slotCapture.SetInput(editing.SlotDescription, true); }
public override void OnMouseButtonAction(Point point, MouseButtonAction type) { Point subItemPoint; GridItemBase subItem = CurrentItem(point, out subItemPoint); if (subItem != null) subItem.OnMouseButtonAction(subItemPoint, type); else base.OnMouseButtonAction(point, type); }
/// <summary> /// Remove very single listener from a button /// and action of it. /// </summary> /// <param name="button">The button to remove listeners from.</param> /// <param name="action">The action to clear listeners of.</param> public void RemoveAllListeners(MouseButton button, MouseButtonAction action) { for (int i = 0, keyCount = buttonHandlers.Count; i < keyCount; i++) { if (buttonHandlers[i].Button == button) { buttonHandlers[i].RemoveAllListeners(action); break; } } }
private void okBtn_Click(object sender, EventArgs e) { MouseButtonAction.Buttons b = MouseButtonAction.Buttons.Left; if (mouseButton.Text == "Left") { b = MouseButtonAction.Buttons.Left; } else if (mouseButton.Text == "Middle") { b = MouseButtonAction.Buttons.Middle; } else if (mouseButton.Text == "Right") { b = MouseButtonAction.Buttons.Right; } else if (mouseButton.Text.StartsWith("Extra 1")) { b = MouseButtonAction.Buttons.Back; } else if (mouseButton.Text.StartsWith("Extra 2")) { b = MouseButtonAction.Buttons.Forward; } if (slotCapture.Value == null) { MessageBox.Show("Please click Capture and press a button or axis direction on the gamepad."); return; } var input = slotCapture.Value; InputAction action; if (editing != null) { editing.Button = b; if (input != editing.SlotDescription) { MapUtil.Map(MainForm, Controller.Virtual, editing.SlotDescription, null); } action = editing; } else { action = new MouseButtonAction(Controller.Core, b); } MapUtil.Map(MainForm, Controller.Virtual, input, action); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
public override void OnMouseButtonAction(Point point, MouseButtonAction type) { Point subItemPoint; GridItemBase subItem = CurrentItem(point, out subItemPoint); if (subItem != null) { subItem.OnMouseButtonAction(subItemPoint, type); } else { base.OnMouseButtonAction(point, type); } }
/// <summary> /// Remove an existing listener from it's key and action. /// </summary> /// <param name="button">The button to remove a listener from.</param> /// <param name="action">The action to stop listening to.</param> /// <param name="listener">The listener to remove.</param> public void RemoveListener(MouseButton button, MouseButtonAction action, MouseButtonListener listener) { if (buttonHandlers != null) { for (int i = 0, keyHandlerCount = buttonHandlers.Count; i < keyHandlerCount; i++) { if (buttonHandlers[i].Button == button) { buttonHandlers[i].RemoveListener(action, listener); return; } } } }
/// <summary> /// Remove a specific listener from the action. /// </summary> /// <param name="action">The action to remove a listener of.</param> /// <param name="listener">The listener to remove.</param> public void RemoveListener(MouseButtonAction action, MouseButtonListener listener) { switch (action) { case MouseButtonAction.Down: if (downListeners != null) { for (int i = 0, downCount = downListeners.Count; i < downCount; i++) { if (downListeners[i] == listener) { downListeners.RemoveAt(i); break; } } } break; case MouseButtonAction.Pressed: if (pressedListeners != null) { for (int i = 0, pressedCount = pressedListeners.Count; i < pressedCount; i++) { if (pressedListeners[i] == listener) { pressedListeners.RemoveAt(i); break; } } } break; case MouseButtonAction.Up: if (upListeners != null) { for (int i = 0, upCount = upListeners.Count; i < upCount; i++) { if (upListeners[i] == listener) { upListeners.RemoveAt(i); break; } } } break; } }
/// <summary> /// Remove all listeners from a specific action of the mouse /// button handler. /// </summary> /// <param name="action">The action to remove all listeners from.</param> public void RemoveAllListeners(MouseButtonAction action) { switch (action) { case MouseButtonAction.Down: downListeners = null; break; case MouseButtonAction.Pressed: pressedListeners = null; break; case MouseButtonAction.Up: upListeners = null; break; } }
internal void OnMouseButtonAction(Point point, MouseButtonAction type) { if (HasLeftExpander) { Image image = Expanded ? ExpandedImage : ShrunkenImage; Size s = new Size(image.Width * 3, image.Height * 3); Rectangle r = new Rectangle(new Point(), s); if (r.Contains(point)) { if (type == MouseButtonAction.MouseDown) { Expanded = !Expanded; GridView.Refresh(); } else { return; } } } if (point.Y < RowHeight) // user has clicked on the row { Point p; GridItemBase item = FindItemFromPoint(point, out p); if (item == null) { return; } item.OnMouseButtonAction(p, type); return; } else // user has clicked on a sub row of the row { Point p; GridRow row = FindRowFromPoint(point, out p); if (row == null) { return; } row.OnMouseButtonAction(p, type); } }
protected virtual void OnMouseButtonAction(MouseEventArgs e, MouseButtonAction type) { if (HeaderRow == null) { return; } if (!DraggingColumns && !ResizingColumns) { this.Focus(); Point p; GridRow row = FindRowFromPoint(e.Location, out p); if (row == null) { return; } if (e.Button == MouseButtons.Right && row is GridHeaderRow) { OpenChooseColumnsMenu(e.Location); } else if (e.Button == MouseButtons.Left) { if (Cursor == Cursors.SizeWE) { if (type == MouseButtonAction.DoubleClick) { FitColumnWidthToHeaderAndContents(row, p); } } else { row.OnMouseButtonAction(p, type); } } else if (type == MouseButtonAction.SingleRightClick) { row.OnMouseButtonAction(p, type); } } }
/// <summary> /// Add a new event listener to the specific mouse button, /// and action. /// </summary> /// <param name="button">The button to listen for.</param> /// <param name="action">It's life cycle event to listen for.</param> /// <param name="listener">The listener to invoke.</param> public void AddListener(MouseButton button, MouseButtonAction action, MouseButtonListener listener) { if (buttonHandlers != null) { for (int i = 0, keyHandlerCount = buttonHandlers.Count; i < keyHandlerCount; i++) { if (buttonHandlers[i].Button == button) { buttonHandlers[i].AddListener(action, listener); return; } } } else { buttonHandlers = new List <MouseButtonHandler>(); } MouseButtonHandler buttonHandler = new MouseButtonHandler(button); buttonHandler.AddListener(action, listener); buttonHandlers.Add(buttonHandler); }
public virtual void OnMouseButtonAction(Point point, MouseButtonAction type) { if (type == MouseButtonAction.DoubleClick) { OnDoubleClick(point); } else if (type == MouseButtonAction.SingleClick) { OnClick(point); } else if (type == MouseButtonAction.StartDrag) { OnStartDrag(point); } else if (type == MouseButtonAction.SingleRightClick) { OnRightClick(point); } else { OnMouseDown(point); } }
protected virtual void OnMouseButtonAction(MouseEventArgs e, MouseButtonAction type) { if (HeaderRow == null) return; if (!DraggingColumns && !ResizingColumns) { this.Focus(); Point p; GridRow row = FindRowFromPoint(e.Location, out p); if (row == null) return; if (e.Button == MouseButtons.Right && row is GridHeaderRow) { OpenChooseColumnsMenu(e.Location); } else if (e.Button == MouseButtons.Left) { if (Cursor == Cursors.SizeWE) { if (type == MouseButtonAction.DoubleClick) FitColumnWidthToHeaderAndContents(row, p); } else { row.OnMouseButtonAction(p, type); } } else if (type == MouseButtonAction.SingleRightClick) { row.OnMouseButtonAction(p, type); } } }
internal NativeMouseButtonEventArgs(int w) { Button = (MouseButton)(w & 0xF); Action = (MouseButtonAction)(w >> 16); }
internal MouseButtonHook(MouseButtonAction buttonAction, Action<MouseButton> hookMethod) { ButtonAction = buttonAction; HookMethod = hookMethod; }
public MouseButtonAssignment(MouseButtons button, MouseButtonAction action, MouseButtonActionType actionType) { _button = button; _action = action; _actionType = actionType; }
public static IntPtr NcHitTest([NotNull] this Form form, Point mouseLocation, MouseButtonAction action, int horizontalMargin, int verticalMargin, int captionMargin) { if (action == MouseButtonAction.None) { return(IntPtr.Zero); } try { NativeMethods.ReleaseCapture(); int ncAction; switch (action) { case MouseButtonAction.LeftButtonDown: ncAction = NativeConstants.WM_NCLBUTTONDOWN; break; case MouseButtonAction.LeftButtonUp: ncAction = NativeConstants.WM_NCLBUTTONUP; break; case MouseButtonAction.LeftButtonDoubleClick: ncAction = NativeConstants.WM_NCLBUTTONDBLCLK; break; case MouseButtonAction.RightButtonDown: ncAction = NativeConstants.WM_NCRBUTTONDOWN; break; case MouseButtonAction.RightButtonUp: ncAction = NativeConstants.WM_NCRBUTTONUP; break; case MouseButtonAction.RightButtonDoubleClick: ncAction = NativeConstants.WM_NCRBUTTONDBLCLK; break; case MouseButtonAction.MouseMove: ncAction = NativeConstants.WM_NCMOUSEMOVE; break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } int ncLocation; Cursor formCursor; var size = form.Size; var isMaximized = form.WindowState == FormWindowState.Maximized; if (mouseLocation.X <= horizontalMargin) { if (!isMaximized) { if (mouseLocation.Y <= verticalMargin) { formCursor = Cursors.SizeNWSE; ncLocation = NativeConstants.HTTOPLEFT; } else if (mouseLocation.Y >= size.Height - verticalMargin) { formCursor = Cursors.SizeNESW; ncLocation = NativeConstants.HTBOTTOMLEFT; } else { formCursor = Cursors.SizeWE; ncLocation = NativeConstants.HTLEFT; } } else { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCLIENT; } } else if (mouseLocation.X >= size.Width - horizontalMargin) { if (!isMaximized) { if (mouseLocation.Y <= verticalMargin) { formCursor = Cursors.SizeNESW; ncLocation = NativeConstants.HTTOPRIGHT; } else if (mouseLocation.Y >= size.Height - verticalMargin) { formCursor = Cursors.SizeNWSE; ncLocation = NativeConstants.HTBOTTOMRIGHT; } else { formCursor = Cursors.SizeWE; ncLocation = NativeConstants.HTRIGHT; } } else { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCLIENT; } } else { if (mouseLocation.Y <= verticalMargin) { if (!isMaximized) { formCursor = Cursors.SizeNS; ncLocation = NativeConstants.HTTOP; } else { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCLIENT; } } else if (mouseLocation.Y <= captionMargin) { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCAPTION; if (action == MouseButtonAction.LeftButtonDoubleClick) { form.Cursor = formCursor; form.WindowState = form.WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized; return(IntPtr.Zero); } } else if (mouseLocation.Y >= size.Height - verticalMargin) { if (!isMaximized) { formCursor = Cursors.SizeNS; ncLocation = NativeConstants.HTBOTTOM; } else { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCLIENT; } } else { formCursor = Cursors.Default; ncLocation = NativeConstants.HTCLIENT; } } form.Cursor = formCursor; return(NativeMethods.SendMessage(form.Handle, ncAction, (IntPtr)ncLocation, IntPtr.Zero)); } catch (Win32Exception ex) { Debug.Print(ex.ToString()); } return(IntPtr.Zero); }