public DiagramMouseManager(Diagram diagram) { _diagram = diagram; _currentResizeDirection = ResizeDirection.None; _leftButtonAction = MouseAction.None; _rightButtonAction = MouseAction.None; _leftButtonDown = false; _rightButtonDown = false; _leftButtonDownMousePosition = null; _currentMousePosition = null; _leftButtonDownMousePosition = null; _itemUnderCursor = null; _baseXViewOffset = 0; _baseYViewOffset = 0; _offsetWorker = null; Selector = null; }
/// <summary> /// Activate a <see cref="MouseAction"/> for a given <see cref="DiagramClientView"/> /// </summary> /// <param name="action">The <see cref="MouseAction"/> to activate.</param> /// <param name="clientView">The current <see cref="DiagramClientView"/></param> /// <param name="serviceProvider">The <see cref="IServiceProvider"/></param> public static void ActivateMouseAction(MouseAction action, DiagramClientView clientView, IServiceProvider serviceProvider) { clientView.ActiveMouseAction = action; #if !VISUALSTUDIO_10_0 IVsUIShell shell; if (null != serviceProvider && null != (shell = (IVsUIShell)serviceProvider.GetService(typeof(IVsUIShell)))) { Guid windowGuid = StandardToolWindows.Toolbox; IVsWindowFrame frame; object frameMode; if (0 == shell.FindToolWindow((uint)(__VSFINDTOOLWIN.FTW_fFrameOnly), ref windowGuid, out frame) && 0 == frame.GetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, out frameMode)) { switch ((VSFRAMEMODE)frameMode) { case VSFRAMEMODE.VSFM_FloatOnly: case VSFRAMEMODE.VSFM_Float: new ActionReactivator(action, clientView); break; } } } #endif // !VISUALSTUDIO_10_0 }
public DoMouseEvent(MouseAction action, bool isMouseDown, int x, int y, int monitorIndex) { this.Action = action; this.IsMouseDown = isMouseDown; this.X = x; this.Y = y; this.MonitorIndex = monitorIndex; }
public MouseState(bool left_down=false, MouseAction mouse_action = MouseAction.none) { this.left_down = left_down; this.mouse_action = mouse_action; this.last_location = Point.Empty; this.last_last_location = this.last_location; this.parameters = null; this.block_left = false; this.block_right = false; }
public StaticViewMouseAgent( StaticView p ) { parent = p; dropitem = null; action = MouseAction.None; scroll_active = false; scroll_dx = scroll_dy = 0; scroll_buttons = MouseButtons.None; scroll_timer = new System.Threading.Timer( new TimerCallback( ScrollTimerCallback ), null, Timeout.Infinite, SCROLL_TIMEOUT ); }
/// <summary> /// Constructor /// </summary> /// <param name="mouseAction">Mouse Action</param> /// <param name="modifiers">Modifiers</param> public MouseGesture( MouseAction mouseAction,ModifierKeys modifiers) // acclerator action { if (!MouseGesture.IsDefinedMouseAction(mouseAction)) throw new InvalidEnumArgumentException("mouseAction", (int)mouseAction, typeof(MouseAction)); if (!ModifierKeysConverter.IsDefinedModifierKeys(modifiers)) throw new InvalidEnumArgumentException("modifiers", (int)modifiers, typeof(ModifierKeys)); _modifiers = modifiers; _mouseAction = mouseAction; //AttachClassListeners(); }
/// <summary> /// Constructor /// </summary> /// <param name="mouseAction">Mouse Action</param> /// <param name="modifiers">Modifiers</param> public MouseGesture(MouseAction mouseAction, ModifierKeys modifiers) // acclerator action { if (!MouseGesture.IsDefinedMouseAction(mouseAction)) { throw new InvalidEnumArgumentException("mouseAction", (int)mouseAction, typeof(MouseAction)); } if (!ModifierKeysConverter.IsDefinedModifierKeys(modifiers)) { throw new InvalidEnumArgumentException("modifiers", (int)modifiers, typeof(ModifierKeys)); } _modifiers = modifiers; _mouseAction = mouseAction; //AttachClassListeners(); }
private bool HandleInteraction(int x, int y, MouseAction action) { (int width, int height) = _game.GetScreenSize(); if (_capturedScreen != null) { _capturedScreen.HandleInteraction(x, y, width, height, action); return(true); } foreach (IScreen screen in _screens) { if (screen.HandleInteraction(x, y, width, height, action)) { _capturedScreen = screen; return(true); } } if (this.CurrentTool is not null) { (int column, int row) = _pixelMapper.ViewPortPixelsToCoords(x, y); if (this.CurrentTool.IsValid(column, row) && action != MouseAction.Move) { this.CurrentTool.Execute(column, row); return(true); } else if (this.CurrentTool is IDraggableTool draggableTool) { if (action == MouseAction.Click) { draggableTool.StartDrag(x, y); return(true); } else if (action == MouseAction.Drag) { draggableTool.ContinueDrag(x, y); return(true); } } } return(false); }
private void OnMouseAction(object sender, MouseHookEventArgs e) { MouseAction?.Invoke(this, e); if (e.Handled) { return; } if ((e.Action == Enums.MouseAction.LeftButtonPressed && GestureActionButton == MouseButtons.LeftMouseButton) || (e.Action == Enums.MouseAction.RightButtonPressed && GestureActionButton == MouseButtons.RightMouseButton)) { // If left button is pressed, start work IsGestureMaking = true; } else if ((e.Action == Enums.MouseAction.LeftButtonReleased && GestureActionButton == MouseButtons.LeftMouseButton) || e.Action == Enums.MouseAction.RightButtonReleased && GestureActionButton == MouseButtons.RightMouseButton) { // If left button is released, stop work IsGestureMaking = false; if (_mousePointsList.Count > 2) { // Get gesture that was doing var gesture = DetectGesture(); if (!string.Equals(gesture.Name, "-1", StringComparison.Ordinal) && gesture.CheckPoinstArray != null) { var eventArgs = new MouseGestureEventArgs(gesture.Name, gesture.CheckPoinstArray, DateTime.Now.Ticks); AddEventToHistory(eventArgs); e.Handled = true; Logger.Instance.Information($"Mouse gesture detected by {nameof(MouseAndKeyboardHookService)}."); MouseGestureDetected?.Invoke(this, eventArgs); } } _mousePointsList.Clear(); } else if (e.Action == Enums.MouseAction.MouseMove) { // If the mouse is moved, add point to coords list if (IsGestureMaking) { _mousePointsList.Add(e.Coords); } } }
public void CycleMouseActions(bool forward) { currentAction = forward ? currentAction + 1 : currentAction - 1; int l = Enum.GetNames(typeof(MouseAction)).Length; if (forward && currentAction >= l) { currentAction = 1; } else if (!forward && currentAction <= 0) { currentAction = l - 1; } ma = actions[currentAction]; updateMA(ma); }
private void SetRemoteMouseAction(MouseEventArgs e, bool press = false, bool move = false, bool wheel = false) { if (picDesktop.Image != null && _enableMouseInput && IsStarted && this.ContainsFocus) { int dwData = e.Delta; MouseAction action = MouseAction.MOUSEEVENTF_NONE; if ((e.Button & MouseButtons.Left) != MouseButtons.None) { action |= (press ? MouseAction.MOUSEEVENTF_LEFTDOWN : MouseAction.MOUSEEVENTF_LEFTUP); } if ((e.Button & MouseButtons.Middle) != MouseButtons.None) { action |= (press ? MouseAction.MOUSEEVENTF_MIDDLEDOWN : MouseAction.MOUSEEVENTF_MIDDLEUP); } if ((e.Button & MouseButtons.Right) != MouseButtons.None) { action |= (press ? MouseAction.MOUSEEVENTF_RIGHTDOWN : MouseAction.MOUSEEVENTF_RIGHTUP); } if ((e.Button & MouseButtons.XButton1) != MouseButtons.None) { action |= (press ? MouseAction.MOUSEEVENTF_XDOWN : MouseAction.MOUSEEVENTF_XUP); dwData = 1; } if ((e.Button & MouseButtons.XButton2) != MouseButtons.None) { action |= (press ? MouseAction.MOUSEEVENTF_XDOWN : MouseAction.MOUSEEVENTF_XUP); dwData = 2; } if (move) { action |= MouseAction.MOUSEEVENTF_MOVE; } if (wheel) { action |= MouseAction.MOUSEEVENTF_WHEEL; } action |= MouseAction.MOUSEEVENTF_ABSOLUTE; int remote_x = GetRemoteWidth(e.X); int remote_y = GetRemoteHeight(e.Y); if (_connectClient != null) { new Core.Packets.ServerPackets.DoMouseEvent(action, remote_x, remote_y, dwData, cbMonitors.SelectedIndex).Execute(_connectClient); } } }
/// <summary> /// Applies the given action to the given position /// </summary> /// <param name="position">The position</param> /// <param name="action">The action</param> private Point ApplyAction(Point position, MouseAction action) { Point newPos = position; switch (action) { case MouseAction.Up: newPos.Y--; break; case MouseAction.Down: newPos.Y++; break; case MouseAction.Right: newPos.X++; break; case MouseAction.Left: newPos.X--; break; case MouseAction.UpLeft: newPos.Y--; newPos.X--; break; case MouseAction.UpRight: newPos.Y--; newPos.X++; break; case MouseAction.DownLeft: newPos.Y++; newPos.X--; break; case MouseAction.DownRight: newPos.Y++; newPos.X++; break; } return(newPos); }
void OnEndBuild() { if (Input.GetMouseButtonUp(0) && startBuild) { startBuild = false; IsoLayerManager.instance.ResetAllLayerFocus(); NewObject(); } if (Input.GetMouseButtonDown(1)) { Destroy(currentObj); DestroyShadow(); ImportItemManager.loadedImage = null; currentAction = MouseAction.none; startBuild = false; } }
private IntPtr LLMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { MouseActionEventArgs eventArgs = new MouseActionEventArgs { IsCancelled = false }; if (nCode >= 0) { eventArgs.Action = (MouseAction)wParam.ToInt32(); eventArgs.Data = Marshal.PtrToStructure <MouseEventData>(lParam); try { MouseAction?.Invoke(this, eventArgs); } catch { } } return(eventArgs.IsCancelled ? (IntPtr)1 : CallNextHookEx(m_hhook, nCode, wParam, lParam)); }
void HandlePlayerClicked(byte[] buffer, int offset) { MouseButton Button = (MouseButton)buffer[offset + 1]; MouseAction Action = (MouseAction)buffer[offset + 2]; ushort yaw = NetUtils.ReadU16(buffer, offset + 3); ushort pitch = NetUtils.ReadU16(buffer, offset + 5); byte entityID = buffer[offset + 7]; ushort x = NetUtils.ReadU16(buffer, offset + 8); ushort y = NetUtils.ReadU16(buffer, offset + 10); ushort z = NetUtils.ReadU16(buffer, offset + 12); TargetBlockFace face = (TargetBlockFace)buffer[offset + 14]; if (face > TargetBlockFace.None) { face = TargetBlockFace.None; } OnPlayerClickEvent.Call(this, Button, Action, yaw, pitch, entityID, x, y, z, face); }
protected override void OnMouseUp(MouseEventArgs e) { Point scrPt = GetScrollRelativeLocation(e.Location); switch (fMode) { case ChartControlMode.ccmDefault: TreeChartPerson mPers; MouseAction mAct = GetMouseAction(e, MouseEvent.meUp, out mPers); switch (mAct) { case MouseAction.maNone: break; case MouseAction.maProperties: SelectBy(mPers, false); if (fSelected == mPers && fSelected.Rec != null) { DoPersonProperties(new MouseEventArgs(e.Buttons, Keys.None, e.Location)); } break; case MouseAction.maExpand: DoRootChanged(mPers); GenChart(mPers.Rec, TreeChartKind.ckBoth, true); break; } break; case ChartControlMode.ccmDragImage: Cursor = Cursors.Default; fMode = ChartControlMode.ccmDefault; break; case ChartControlMode.ccmControlsVisible: fTreeControls.MouseUp(scrPt.X, scrPt.Y); break; } e.Handled = true; base.OnMouseUp(e); }
public override void AppendAction(object scriptObj, MouseAction mouseAction, double x, double y, ref int timer) { if (!(scriptObj is List <LDPlayerOperation> script)) { throw new ArgumentException("Passed in object is not of type List<LDPlayerOperation>"); } switch (mouseAction) { case MouseAction.MouseDown: case MouseAction.MouseDrag: script.Add(new LDPlayerOperation(timer, (int)x, (int)y, LDPLayerState.MouseDown)); break; case MouseAction.MouseUp: script.Add(new LDPlayerOperation(timer, (int)x, (int)y, LDPLayerState.MouseUp)); break; } }
private Cursor getCursorForPos(int x, int y) { MouseAction act = getActionAtPos(x, y); if (!act.drag) { return(Cursors.Default); } if (act.vert == ResizeType.ResizeBegin && act.hor == ResizeType.ResizeBegin) { return(Cursors.SizeNWSE); } if (act.vert == ResizeType.ResizeEnd && act.hor == ResizeType.ResizeEnd) { return(Cursors.SizeNWSE); } if (act.vert == ResizeType.ResizeBegin && act.hor == ResizeType.ResizeEnd) { return(Cursors.SizeNESW); } if (act.vert == ResizeType.ResizeEnd && act.hor == ResizeType.ResizeBegin) { return(Cursors.SizeNESW); } if (act.vert == ResizeType.ResizeNone && act.hor == ResizeType.ResizeNone) { return(Cursors.SizeAll); } if (act.vert == ResizeType.ResizeNone) { return(Cursors.SizeWE); } if (act.hor == ResizeType.ResizeNone) { return(Cursors.SizeNS); } return(Cursors.Default); }
protected override void OnMouseMove(MouseEventArgs e) { if (baseLayer != null) { if (is_dragging) { Point diff = new Point(e.X - drag_origin.X, e.Y - drag_origin.Y); imminentAction.Dragged(diff); Invalidate(); drag_origin = new Point(e.X, e.Y); } else { imminentAction = ImminentAction(e); Cursor.Current = imminentAction.GetCursor(false); } } base.OnMouseMove(e); }
private void picDesktop_MouseUp(object sender, MouseEventArgs e) { if (picDesktop.Image != null && _enableMouseInput && this.ContainsFocus) { MouseAction action = MouseAction.None; if (e.Button == MouseButtons.Left) { action = MouseAction.LeftUp; } if (e.Button == MouseButtons.Right) { action = MouseAction.RightUp; } int selectedDisplayIndex = cbMonitors.SelectedIndex; _remoteDesktopHandler.SendMouseEvent(action, false, e.X, e.Y, selectedDisplayIndex); } }
// Drag-n-drop functions public override void StartDrag(UmlObject elem) { dropobj = elem; dropitem = GuiElementFactory.CreateElement(elem); if (dropitem != null) { System.Diagnostics.Debug.Assert(dropitem is IMoveable && dropitem is IRemoveable, "wrong element created"); dropitem.parent = parent; if (dropitem is INeedRefresh) { parent.RefreshObject((INeedRefresh)dropitem); } action = MouseAction.Drag; } else { action = MouseAction.None; } }
private void SendMouseAction(ArrayList arr, MouseEventArgs e, MouseAction act) { foreach (LeShape shape in arr) { switch (act) { case MouseAction.Down: shape.MouseDown(this, e); break; case MouseAction.Up: shape.MouseUp(this, e); break; case MouseAction.Move: shape.MouseMove(this, e); break; } } }
public virtual void AppendAction(object scriptObj, MouseAction mouseAction, double x, double y, ref int timer) { if (!(scriptObj is StringBuilder script)) { throw new ArgumentException("Passed in object is not of type StringBuilder"); } script.Append((int)mouseAction) .Append(GlobalData.noxSeperator) .Append(x.ToString()) .Append(GlobalData.noxSeperator) .Append(y.ToString()) .Append(GlobalData.whatisthis) .Append(timer.ToString()) .Append(GlobalData.noxSeperator) .Append(GlobalData.CustomX) .Append(GlobalData.noxSeperator) .Append(GlobalData.CustomY) .AppendLine(); }
public static void MouseClick(MouseAction button) { switch (button) { case MouseAction.LeftClick: Mouse.Click(MouseButton.Left); break; case MouseAction.RightClick: Mouse.Click(MouseButton.Right); break; case MouseAction.DoubleLeftClick: Mouse.LeftDoubleClick(); break; case MouseAction.DoubleRightClick: Mouse.RightDoubleClick(); break; } }
internal KeyframeM(string line, long t, Recording p) : base(t, p, KFType.MOUSE) { MouseAction ma; int a = line.IndexOf(",") + 1, b = line.IndexOf("(", a); ma = (MouseAction)Enum.Parse(typeof(MouseAction), line.Substring(a, b - a)); int x, y; a = b + 1; b = line.IndexOf(",", a); x = int.Parse(line.Substring(a, b - a)); a = b + 1; b = line.IndexOf(")", a); y = int.Parse(line.Substring(a, b - a)); this.x = x; this.y = y; this.ma = ma; init(); }
void PlayerClickCallback(Player p, MouseButton btn, MouseAction action, ushort yaw, ushort pitch, byte entity, ushort x, ushort y, ushort z, TargetBlockFace face) { if (!p.aiming || btn != MouseButton.Left || action != MouseAction.Pressed) { return; } if (!p.level.Config.Guns) { Disable(p); return; } BlockID held = p.GetHeldBlock(); if (!CommandParser.IsBlockAllowed(p, "use", held)) { return; } OnActivated(p, (byte)(yaw >> 8), (byte)(pitch >> 8), held); }
/// <summary> /// ConvertTo() /// </summary> /// <param name="context">Serialization Context</param> /// <param name="culture">Culture Info</param> /// <param name="value">MouseAction value </param> /// <param name="destinationType">Type to Convert</param> /// <returns>string if parameter is a MouseAction</returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value != null) { MouseAction mouseActionValue = (MouseAction)value; if (MouseActionConverter.IsDefinedMouseAction(mouseActionValue)) { string mouseAction = null; switch (mouseActionValue) { case MouseAction.None: mouseAction = String.Empty; break; case MouseAction.LeftClick: mouseAction = "LeftClick"; break; case MouseAction.RightClick: mouseAction = "RightClick"; break; case MouseAction.MiddleClick: mouseAction = "MiddleClick"; break; case MouseAction.WheelClick: mouseAction = "WheelClick"; break; case MouseAction.LeftDoubleClick: mouseAction = "LeftDoubleClick"; break; case MouseAction.RightDoubleClick: mouseAction = "RightDoubleClick"; break; case MouseAction.MiddleDoubleClick: mouseAction = "MiddleDoubleClick"; break; } if (mouseAction != null) { return(mouseAction); } } throw new InvalidEnumArgumentException("value", (int)mouseActionValue, typeof(MouseAction)); } throw GetConvertToException(value, destinationType); }
// Update is called once per frame public void OnUpdate() { if (EventSystem.current.IsPointerOverGameObject()) { return; } //리스너 패턴 if (Input.anyKey && KeyAction != null) { KeyAction.Invoke(); } if (MouseAction != null) { if (Input.GetMouseButton(0)) { if (!_pressed) { MouseAction.Invoke(Define.MouseEvent.PointerDown); _pressedTime = Time.time; } MouseAction.Invoke(Define.MouseEvent.Press); _pressed = true; } else { if (_pressed) { if (Time.time < _pressedTime + 0.2f) { MouseAction.Invoke(Define.MouseEvent.Click); } MouseAction.Invoke(Define.MouseEvent.PointerUp); } _pressed = false; _pressedTime = 0f; } } }
//Creates and returns event data to send to the controls if the mouse has been clicked. //Returns null if it hasn't. private DXMouseEventArgs GetClickEventData(MouseState newMouseState) { bool[] oldButtonData = this.previousMouseState.GetButtons(); bool[] newButtonData = newMouseState.GetButtons(); MouseAction action = MouseAction.None; int buttonIndex = 0; for (int i = 0; i < oldButtonData.Length; i++) { if (oldButtonData[i] != newButtonData[i]) { buttonIndex = i; if (oldButtonData[i]) { action = MouseAction.Release; } else { action = MouseAction.Click; } break; } } if (action == MouseAction.None) { return(null); } else { return(new DXMouseEventArgs( action, newMouseState, Control.MousePosition, buttonIndex, this)); } }
public override void AppendAction(object scriptObj, MouseAction mouseAction, double x, double y, ref int timer) { if (!(scriptObj is List <BlueStackEvent> script)) { throw new ArgumentException("Passed in object is not of type List<BlueStackEvent>"); } switch (mouseAction) { case MouseAction.MouseDown: script.Add(new BlueStackEvent(timer, Helpers.GetPercentage(x, GlobalData.CustomX), Helpers.GetPercentage(y, GlobalData.CustomY), BSEventType.MouseDown)); break; case MouseAction.MouseDrag: script.Add(new BlueStackEvent(timer, Helpers.GetPercentage(x, GlobalData.CustomX), Helpers.GetPercentage(y, GlobalData.CustomY), BSEventType.MouseMove)); break; case MouseAction.MouseUp: script.Add(new BlueStackEvent(timer, Helpers.GetPercentage(x, GlobalData.CustomX), Helpers.GetPercentage(y, GlobalData.CustomY), BSEventType.MouseUp)); break; } }
/// <summary> /// Synchronized Gesture from properties /// </summary> private void SynchronizeGestureFromProperties(MouseAction mouseAction) { if (!_settingGesture) { _settingGesture = true; try { if (Gesture == null) { Gesture = new MouseGesture(mouseAction); } else { ((MouseGesture)Gesture).MouseAction = mouseAction; } } finally { _settingGesture = false; } } }
public void UpdateActions(int mousex, int mousey, MouseAction act) { if (boundingbox.IsInbox(mousex, mousey)) { hover = true; MouseOver(this, true); switch (act) { case MouseAction.LeftDown: MouseDown(this, false); break; case MouseAction.LeftUp: MouseUp(this, false); break; case MouseAction.RightDown: MouseDown(this, true); break; case MouseAction.RightUp: MouseUp(this, true); break; case MouseAction.WheelDown: MouseWheel(this, false); break; case MouseAction.WheelUp: MouseWheel(this, true); break; } } else { hover = false; MouseOver(this, false); } }
public override void AppendAction(object scriptObj, MouseAction mouseAction, double x, double y, ref int timer) { if (!(scriptObj is StringBuilder script)) { throw new ArgumentException("Passed in object is not of type StringBuilder"); } switch (mouseAction) { case MouseAction.MouseDown: script.Append($"{touchDown} 0 {x} {y}").AppendLine(); break; case MouseAction.MouseDrag: script.Append($"{touchMove} 0 {x} {y}").AppendLine(); break; case MouseAction.MouseUp: script.Append($"{touchUp.ToString()} 0").AppendLine(); break; } }
/// <summary> /// Override to provide the right mouse action when trying /// to create links on the diagram /// </summary> /// <param name="pointArgs"></param> public override void OnViewMouseEnter(DiagramPointEventArgs pointArgs) { if (pointArgs == null) { throw new ArgumentNullException("pointArgs"); } MouseAction action = null; if (ActiveDiagramView != null) { if (ActiveDiagramView.SelectedToolboxItemSupportsFilterString(EditorFactory.SchemaModelItemHasSchemaModelItemConnectorFilterString)) { action = this.SchemaModelItemHasSchemaModelItemConnectorConnectAction; } } if (pointArgs.DiagramClientView.ActiveMouseAction != action) { pointArgs.DiagramClientView.ActiveMouseAction = action; } }
protected override void OnMouseDown(MouseEventArgs e) { Point pt = new Point(e.Location); fMouseX = pt.X; fMouseY = pt.Y; Point scrPt = GetScrollRelativeLocation(e.Location); switch (fMode) { case ChartControlMode.ccmDefault: TreeChartPerson mPers; MouseAction mAct = GetMouseAction(e, MouseEvent.meDown, out mPers); switch (mAct) { case MouseAction.maSelect: SelectBy(mPers, true); break; case MouseAction.maDrag: Cursor = Cursors.Move; // SizeAll; fMode = ChartControlMode.ccmDragImage; break; } break; case ChartControlMode.ccmDragImage: break; case ChartControlMode.ccmControlsVisible: fTreeControls.MouseDown(scrPt.X, scrPt.Y); break; } e.Handled = true; base.OnMouseDown(e); }
/** * @brief get the key of the sprite with the given position * return "" if no sprite is hit **/ private string GetEditorSpriteKeyByPosition(Point _pos, MouseAction _mouseAction) { if (m_sprites != null) { foreach (KeyValuePair <string, BTEditorSprite> keyValue in m_sprites) { if (keyValue.Value.IsMouseOn(_pos)) { if (_mouseAction == MouseAction.MouseDown) { keyValue.Value.OnMouseDown(_pos); } else if (_mouseAction == MouseAction.MouseUp) { keyValue.Value.OnMouseUp(_pos); } return(keyValue.Key); } } } return(""); }
public static void Action(double x, double y, MouseAction buttonState) { Point point = new Point((int)x, (int)y); Cursor.Position = point; NativeMethods.INPUT[] input = new NativeMethods.INPUT[1]; NativeMethods.MOUSEINPUT mi = new NativeMethods.MOUSEINPUT(); mi.dx = 0; mi.dy = 0; if (buttonState == MouseAction.LeftDown) mi.dwFlags = NativeMethods.MOUSEEVENTF_LEFTDOWN | NativeMethods.MOUSEEVENTF_ABSOLUTE; else if (buttonState == MouseAction.LeftUp) mi.dwFlags = NativeMethods.MOUSEEVENTF_LEFTUP | NativeMethods.MOUSEEVENTF_ABSOLUTE; else if (buttonState == MouseAction.RightDown) mi.dwFlags = NativeMethods.MOUSEEVENTF_RIGHTDOWN | NativeMethods.MOUSEEVENTF_ABSOLUTE; else if (buttonState == MouseAction.RightUp) mi.dwFlags = NativeMethods.MOUSEEVENTF_RIGHTUP | NativeMethods.MOUSEEVENTF_ABSOLUTE; input[0] = new NativeMethods.INPUT(); input[0].mi = mi; NativeMethods.SendInput((uint)input.Length, input, Marshal.SizeOf(input[0])); }
public static void SetData(Rectangle bounds, Point point) { m_Left = bounds.Left; m_Top = bounds.Top; m_Right = bounds.Right; m_Bottom = bounds.Bottom; m_LastX = point.X; m_LastY = point.Y; m_LastState = m_State; }
// Checks if two actions are on same cell or not. private static bool AreActionsOnSameExcelCell(SendKeysAction lastAction, MouseAction secondLastAction) { return lastAction != null && secondLastAction != null && lastAction.UIElement is ExcelCellElement && secondLastAction.UIElement is ExcelCellElement && object.Equals(lastAction.UIElement, secondLastAction.UIElement); }
// Checks if this is a left click action or not. private static bool IsLeftClick(MouseAction mouseAction) { return mouseAction != null && mouseAction.ActionType == MouseActionType.Click && mouseAction.MouseButton == MouseButtons.Left && mouseAction.ModifierKeys == System.Windows.Input.ModifierKeys.None; }
public override void StopDrag() { if( dropitem == null ) throw new ArgumentException( "have nothing to stop" ); dropitem.Invalidate(); dropitem = null; action = MouseAction.None; }
public override void MouseUp(MouseButtons b) { if( scroll_active ) { StopScrolling(); } parent.SetDefaultDrawingMode(); original_selected = null; switch( action ) { case MouseAction.Scroll: Cursor.Current = Cursors.Arrow; if( first_move ) { System.Windows.Forms.ContextMenu m = new ContextMenu(); parent.AddMenuItems( m ); if( m.MenuItems.Count > 0 ) m.Show( parent.cview, new Point( menurealx, menurealy ) ); } break; case MouseAction.CreateConnection: if( conn.second.item == null ) conn.Invalidate(); else { conn.ConnectionCreated( parent, null, null, null, null ); parent.Undo.Push( new CreateOperation( conn ), false ); } conn = null; break; case MouseAction.Move: ArrayList movedobjects = new ArrayList(); foreach( GuiObject o in movestates.Keys ) if( o is IAroundObject ) movedobjects.Add( o ); if( movedobjects.Count > 0 ) parent.AroundObjectsMoved( movedobjects, movestates ); foreach( IMoveable o in movestates.Keys ) o.Moved(); if( movestates.Count == 1 ) { foreach( IStateObject t in movestates.Keys ) parent.Undo.Push( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ), false ); } else if( movestates.Count > 1 ) { MultipleOperation p = new MultipleOperation(); foreach( IStateObject t in movestates.Keys ) p.l.Add( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ) ); parent.Undo.Push( p, false ); } movestates.Clear(); moveitem = null; movelist = null; break; case MouseAction.Select: parent.SelectedObjects.Clear(); parent.SelectInRectangle( selrect ); parent.cview.InvalidatePage( selrect ); selrect = Rectangle.Empty; break; } action = MouseAction.None; }
public override void Drop( ) { if( dropitem == null ) throw new ArgumentException( "have nothing to drop" ); parent.AddObject( dropitem, UmlModel.GetUniversal(dropobj) ); action = MouseAction.None; // insert Inheritance ArrayList l = new ArrayList( parent.active_objects ); foreach( GuiObject a in l ) if( a is GuiClass ) { GuiClass c = a as GuiClass; // TODO ????????? /*if( c.st.bases != null && c.st.bases.Contains( dropitem.st.fullname ) ) { NewRelation( dropitem, c, UmlRelationType.Inheritance ); } else if( dropitem.st.bases != null && dropitem.st.bases.Contains( c.st.fullname ) ) { NewRelation( c, dropitem, UmlRelationType.Inheritance ); }*/ } dropitem = null; }
protected override void OnMouseEnter(EventArgs e) { MAction = MouseAction.Over; this.Invalidate(false); base.OnMouseEnter(e); }
public static extern bool TwMouseButton(MouseAction action, MouseButtonID button);
private bool CheckButton(MouseButtonEventArgs e, MouseAction a) { bool control = (Keyboard.IsKeyDown(Key.LeftCtrl)); bool shift = (Keyboard.IsKeyDown(Key.LeftShift)); bool doubleClick = e.ClickCount == 2; if (e.LeftButton == MouseButtonState.Pressed) { if (control) return a == ControlLeftButtonAction; if (shift) return a == ShiftLeftButtonAction; if (doubleClick) return a == LeftDoubleClickAction; return a == LeftButtonAction; } if (e.MiddleButton == MouseButtonState.Pressed) { if (control) return a == ControlMiddleButtonAction; if (shift) return a == ShiftMiddleButtonAction; if (doubleClick) return a == MiddleDoubleClickAction; return a == MiddleButtonAction; } if (e.RightButton == MouseButtonState.Pressed) { if (control) return a == ControlRightButtonAction; if (shift) return a == ShiftRightButtonAction; if (doubleClick) return a == RightDoubleClickAction; return a == RightButtonAction; } return false; }
protected override void OnMouseUp(MouseEventArgs e) { if ((this._mouseAction == MouseAction.None) || (this._image == null)) { base.OnMouseUp(e); } else { this.SuspendRedraw(); this._mouseAction = MouseAction.None; this._mousePreviousPos = Point.Empty; this._cropDragPoint = CropDragPoint.None; this.ResumeRedraw(); } }
private void TryScrollbars( int x, int y, MouseAction ma ) { if( ma == MouseAction.MouseMove ) { if( hold ) ScrollMouseAction( last_over, x, y, ma ); } else if( hold && ma == MouseAction.LeftButtonUp ) { ScrollMouseAction( last_over, x, y, ma ); hold = false; } else if( HScrollRect.Contains( x, y ) ) { ScrollMouseAction( last_over = false, x, y, ma ); hold = (ma == MouseAction.LeftButtonDown); } else if( VScrollRect.Contains( x, y ) ) { ScrollMouseAction( last_over = true, x, y, ma ); hold = (ma == MouseAction.LeftButtonDown); } }
private static RoutedUICommand CreateCommand(string name, MouseAction mouseAction) { return new RoutedUICommand(name, name, typeof(ChartCommands), new InputGestureCollection { new MouseGesture(mouseAction) }); }
private MapViewer.DragAction mapViewer_OnMouseEvent(object sender, MouseAction action, int buttonNumber, bool[] whichButtonsDown, PointF location, PointF locationStart) { if (action == MouseAction.Down && buttonNumber == MapViewer.RightMouseButton) return MapViewer.DragAction.DelayedDrag; if (action == MouseAction.Drag && buttonNumber == MapViewer.RightMouseButton) { RectangleF rect = new RectangleF(Math.Min(location.X, locationStart.X), Math.Min(location.Y, locationStart.Y), Math.Abs(locationStart.X - location.X), Math.Abs(locationStart.Y - location.Y)); highlight = new RectangleHighlight(rect); mapViewer.ChangeHighlight(new IMapViewerHighlight[] { highlight }); return MapViewer.DragAction.DelayedDrag; } // Allow the left mouse button to drag. if (action == MouseAction.Down && buttonNumber == MapViewer.LeftMouseButton) return MapViewer.DragAction.MapDrag; else return MapViewer.DragAction.None; }
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs mevent) { MAction = MouseAction.Over; this.Invalidate(false); base.OnMouseUp(mevent); }
public static void SetState(MouseAction state) { m_State = state; }
protected override void OnMouseLeave(EventArgs e) { MAction = MouseAction.Leave; this.Invalidate(false); base.OnMouseLeave(e); }
public static void ResetState() { m_State = MouseAction.None; m_LastState = MouseAction.None; }
public override void MouseDown( int x, int y, MouseButtons b, Keys modif, int realx, int realy ) { // Left mouse button if( action != MouseAction.None ) return; if( b == MouseButtons.Left ) { if( current_operation == MouseOperation.DrawComment || current_operation == MouseOperation.DrawPackage ) { switch( current_operation ) { case MouseOperation.DrawComment: moveitem = GuiElementFactory.CreateMemo( parent, x, y ); break; case MouseOperation.DrawPackage: moveitem = GuiElementFactory.CreatePackage( parent, x, y ); break; } first_move = true; moveux = 0; moveuy = 0; action = MouseAction.Move; } else if( (modif & Keys.Control) == Keys.Control || current_operation == MouseOperation.DrawConnection ) { conn_item = parent.FindItem( x, y, out moveux, out moveuy, true ) as IAcceptConnection; if( conn_item == null ) { action = MouseAction.Scroll; selx = x; sely = y; return; } int ux; float uy; conn_item.coord_nearest( x, y, out ux, out uy ); action = MouseAction.CreateConnection; conn = new GuiConnection( new GuiConnectionPoint( conn_item, ux, uy, 0 ), new GuiConnectionPoint( x, y, 1 ), conn_type, parent, conn_type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : conn_style ); conn.first.item.coord_nearest( x, y, out conn.first.ux, out conn.first.uy ); conn.first.UpdatePosition( true ); conn.DoCreationFixup(); conn.InvalidateTemporary(); conn.Invalidate(); } else if( ( modif & Keys.Shift) == Keys.Shift ) { GuiObject obj = parent.FindItem( x, y, false ); if( obj != null ) { parent.SelectedObjects.Add( obj ); obj.Invalidate(); } } else { // Left button click: // select // move, move multiple GuiObject s = parent.FindItem( x, y, out moveux, out moveuy, false ); if( s == null ) { parent.SelectedObjects.Clear(); action = MouseAction.Select; selx = x; sely = y; return; } if( !s.selected ) { parent.SelectedObjects.Clear(); parent.SelectedObjects.Add( s ); } // deciding: to move, or not ... moveitem = null; movelist = null; movestates.Clear(); original_selected = null; GuiObject t = parent.FindItem( x, y, out moveux, out moveuy, true ); if( t != null ) { if( t is IMoveRedirect ) { if( t.selected ) original_selected = t; moveitem = (t as IMoveRedirect).MoveRedirect( ref moveux, ref moveuy ); } else if( t is IMoveMultiple && (t as IMoveMultiple).CanMoveInGroup ) { movelist = new ArrayList(); if( !t.selected ) movelist.Add( t ); foreach( GuiObject o in parent.SelectedObjects ) if( o is IMoveMultiple && (o as IMoveMultiple).CanMoveInGroup ) movelist.Add( o ); selx = x; sely = y; } else if( t is IMoveable && (t as IMoveable).IsMoveable( x, y ) ) moveitem = t as IMoveable; if( moveitem != null || movelist != null ) { first_move = true; action = MouseAction.Move; } else if( t is IClickable ) { (t as IClickable).LeftClick( false, x, y ); } } } } else if( b == MouseButtons.Right ) { ISelectable obj = parent.FindItem( x, y, true ) as ISelectable; if( obj != null ) { if( obj is IDropMenu ) { parent.SelectedObjects.Clear(); parent.SelectedObjects.Add( obj as GuiObject ); System.Windows.Forms.ContextMenu m = new ContextMenu(); (obj as IDropMenu).AddMenuItems( m, x, y ); if( m.MenuItems.Count > 0 ) m.Show( parent.cview, new Point( realx, realy ) ); } } else { action = MouseAction.Scroll; Cursor.Current = Cursors.Hand; selx = x; sely = y; menurealx = realx; menurealy = realy; first_move = true; } } }
void ScrollMouseAction( bool vertical, int x, int y, MouseAction ma ) { if( scroll_on && ma != MouseAction.LeftButtonDown ) vertical = scroll_vert; Rectangle r = vertical ? VScrollRect : HScrollRect; if( !r.Contains( x, y ) && ma == MouseAction.LeftButtonDown || ma != MouseAction.LeftButtonDown && !scroll_on ) return; // check for space System.Diagnostics.Debug.Assert( vertical && r.Width == scroller || !vertical && r.Height == scroller ); if( vertical && r.Height < 3*scroller || !vertical && r.Width < 3*scroller ) { return; } int left = vertical ? r.Top : r.Left, right = vertical ? r.Bottom : r.Right, mouse_pos = vertical ? y : x; switch( ma ) { case MouseAction.MouseMove: if( scroll_on && scroll_bar ) { int target = mouse_pos - scroll_pos; if( target < left + scroller ) target = left + scroller; if( target >= right - scroller - scroll_length ) target = right - scroller - scroll_length; SetScrollLeft( scroll_vert, target - (left + scroller), right - left - 2*scroller - scroll_length ); } break; case MouseAction.LeftButtonDown: scroll_vert = vertical; if( mouse_pos >= left && mouse_pos < left + scroller ) { pressed[vertical?0:3] = true; AdjustPageCoords( vertical ? 0 : -20, vertical ? -20 : 0 ); scroll_on = true; scroll_bar = false; } else if( mouse_pos < right && mouse_pos >= right - scroller ) { pressed[vertical?2:1] = true; AdjustPageCoords( vertical ? 0 : 20, vertical ? 20 : 0 ); scroll_on = true; scroll_bar = false; } else { Rectangle page_rect = PageRectangle; Rectangle scroll_rect = GetScrollRectangle( vertical, ScrollMax( vertical ), ScrollLeft( vertical, page_rect), ScrollRight( vertical, page_rect ) ); if( scroll_rect.Contains( x, y ) ) { scroll_pos = vertical ? y - scroll_rect.Top : x - scroll_rect.Left; scroll_length = vertical ? scroll_rect.Height : scroll_rect.Width; scroll_bar = scroll_on = true; bar_selected[vertical?0:1] = true; Invalidate(r); } else { if( mouse_pos < (vertical ? scroll_rect.Top : scroll_rect.Left ) ) { AdjustPageCoords( vertical ? 0 : -DiagramArea.Width/5, vertical ? -DiagramArea.Height/5 : 0 ); } else if( mouse_pos >= (vertical ? scroll_rect.Bottom : scroll_rect.Right) ) { AdjustPageCoords( vertical ? 0 : DiagramArea.Width/5, vertical ? DiagramArea.Height/5 : 0 ); } } } break; case MouseAction.LeftButtonUp: scroll_on = false; bar_selected[0] = bar_selected[1] = pressed[0] = pressed[1] = pressed[2] = pressed[3] = false; Invalidate( r ); break; } }
// Drag-n-drop functions public override void StartDrag( UmlObject elem ) { dropobj = elem; dropitem = GuiElementFactory.CreateElement( elem ); if( dropitem != null ) { System.Diagnostics.Debug.Assert( dropitem is IMoveable && dropitem is IRemoveable, "wrong element created" ); dropitem.parent = parent; if( dropitem is INeedRefresh ) parent.RefreshObject( (INeedRefresh)dropitem ); action = MouseAction.Drag; } else action = MouseAction.None; }
// Helper like Enum.IsDefined, for MouseAction. internal static bool IsDefinedMouseAction(MouseAction mouseAction) { return (mouseAction >= MouseAction.None && mouseAction <= MouseAction.MiddleDoubleClick); }
protected override void OnMouseDown(MouseEventArgs e) { if ((this._penMode == Resco.Controls.ImageBox.PenMode.None) || (this._image == null)) { base.OnMouseDown(e); } else { if (this._penMode == Resco.Controls.ImageBox.PenMode.Move) { if ((this._visibleSize.Width < this._imageSize.Width) || (this._visibleSize.Height < this._imageSize.Height)) { this._mouseAction = MouseAction.MoveImage; } } else if (this._penMode == Resco.Controls.ImageBox.PenMode.Crop) { Rectangle cropBounds = this._drawArgs.CropBounds; if (Math.Abs((int) (cropBounds.Left - e.X)) <= _cropRectSize) { this._cropDragPoint = CropDragPoint.Left; } else if (Math.Abs((int) (cropBounds.Right - e.X)) <= _cropRectSize) { this._cropDragPoint = CropDragPoint.Right; } else if (Math.Abs((int) ((cropBounds.Left + (cropBounds.Width / 2)) - e.X)) <= _cropRectSize) { this._cropDragPoint = CropDragPoint.Middle; } else { this._cropDragPoint = CropDragPoint.None; } if (this._cropDragPoint != CropDragPoint.None) { if (Math.Abs((int) (cropBounds.Top - e.Y)) <= _cropRectSize) { this._cropDragPoint |= CropDragPoint.Top; } else if (Math.Abs((int) (cropBounds.Bottom - e.Y)) <= _cropRectSize) { this._cropDragPoint |= CropDragPoint.Bottom; } else if (Math.Abs((int) ((cropBounds.Top + (cropBounds.Height / 2)) - e.Y)) <= _cropRectSize) { this._cropDragPoint |= CropDragPoint.Middle; } else { this._cropDragPoint = CropDragPoint.None; } } if (((this._cropDragPoint == CropDragPoint.None) && (Math.Abs((int) ((cropBounds.Left + (cropBounds.Width / 2)) - e.X)) <= _cropRectSize)) && (Math.Abs((int) ((cropBounds.Top + (cropBounds.Height / 2)) - e.Y)) <= _cropRectSize)) { this._cropDragPoint = CropDragPoint.Middle; } if (this._cropDragPoint != CropDragPoint.None) { this._mouseAction = MouseAction.DragCrop; } else if ((this._visibleSize.Width < this._imageSize.Width) || (this._visibleSize.Height < this._imageSize.Height)) { this._mouseAction = MouseAction.MoveImage; } } if (this._mouseAction != MouseAction.None) { this._mousePreviousPos = new Point(e.X, e.Y); } } }
public void Update(GameTime gameTime) { //this.PreviousPrevious = this.Previous; this.Previous = this.Current; this.Current = Mouse.GetState(); this.position = this.Current.Position.ToVector2(); bool leftMouseDown = this.Current.LeftButton == ButtonState.Pressed; bool leftMouseClick = this.leftMouseCounter < Configuration.ClickTimer && this.Previous.LeftButton == ButtonState.Pressed && this.Current.LeftButton == ButtonState.Released; bool rightMouseDown = this.Current.RightButton == ButtonState.Pressed; bool rightMouseClick = this.rightMouseCounter < Configuration.ClickTimer && this.Previous.RightButton == ButtonState.Pressed && this.Current.RightButton == ButtonState.Released; if (leftMouseClick) { this.leftMouseAction = MouseAction.MouseClick; } else if (leftMouseDown) { this.leftMouseAction = MouseAction.MouseDown; this.leftMouseCounter += gameTime.ElapsedGameTime.Milliseconds; } else { this.leftMouseAction = MouseAction.MouseUp; this.leftMouseCounter = 0; } if (rightMouseClick) { this.rightMouseAction = MouseAction.MouseClick; } else if (rightMouseDown) { this.rightMouseAction = MouseAction.MouseDown; this.rightMouseCounter += gameTime.ElapsedGameTime.Milliseconds; } else { this.rightMouseAction = MouseAction.MouseUp; this.rightMouseCounter = 0; } }