public void HandleDoubleClick(Point clickPosition, Point pan, float scale = 1) { if (Rect.Contains(new Point((clickPosition - pan) * (1 / scale)))) { DoubleClick?.Invoke(this, new EventArgs()); } }
public void HandleDoubleClick(Point clickPosition, Point pan) { if (Rect.Contains(clickPosition - pan)) { DoubleClick?.Invoke(this, new EventArgs()); } }
public OutlinePanel() { View = new OutlineView(); EnclosingScrollView = new ScrollContainerView(View); View.SelectionNodeChanged += (s, e) => { if (View.SelectedNode is WidgetNodeView nodeView) { RaiseFirstResponder?.Invoke(this, nodeView.Wrapper); } }; View.KeyPress += (sender, e) => { if (e == DeleteKey) { if (View.SelectedNode is WidgetNodeView nodeView) { RaiseDeleteItem?.Invoke(this, nodeView.Wrapper); } } }; View.DoubleClick += (sender, e) => { DoubleClick?.Invoke(this, (View.SelectedNode as WidgetNodeView)?.Wrapper); }; View.StartDrag += (sender, e) => { StartDrag?.Invoke(this, (e as WidgetNodeView)?.Wrapper); }; }
public FileViewerInternal() { InitializeComponent(); InitializeComplete(); _currentViewPositionCache = new CurrentViewPositionCache(this); TextEditor.TextChanged += (s, e) => TextChanged?.Invoke(s, e); TextEditor.ActiveTextAreaControl.VScrollBar.ValueChanged += (s, e) => ScrollPosChanged?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.KeyUp += (s, e) => KeyUp?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.DoubleClick += (s, e) => DoubleClick?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseMove += (s, e) => MouseMove?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseEnter += (s, e) => MouseEnter?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseLeave += (s, e) => MouseLeave?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseDown += (s, e) => { SelectedLineChanged?.Invoke( this, new SelectedLineEventArgs( TextEditor.ActiveTextAreaControl.TextArea.TextView.GetLogicalLine(e.Y))); }; HighlightingManager.Manager.DefaultHighlighting.SetColorFor("LineNumbers", new HighlightColor(Color.FromArgb(80, 0, 0, 0), Color.White, false, false)); TextEditor.ActiveTextAreaControl.TextEditorProperties.EnableFolding = false; _lineNumbersControl = new DiffViewerLineNumberControl(TextEditor.ActiveTextAreaControl.TextArea); VRulerPosition = AppSettings.DiffVerticalRulerPosition; }
private void Base_DoubleClick(object sender, EventArgs e) { if (canClick) { DoubleClick?.Invoke(this, e); } }
/// <summary> /// Handles most events of the control /// </summary> /// <param name="eventName">Type of event to raise</param> /// <remarks></remarks> public void DoEvent(LightweightEvents eventName) { switch (eventName) { case LightweightEvents.Click: DoClick(); break; case LightweightEvents.MouseDown: if (canClick) { isPressed = true; Redraw(); } MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; case LightweightEvents.MouseUp: if (canClick) { isPressed = false; Redraw(); } MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; case LightweightEvents.MouseEnter: Scrolling = true; MouseEnter?.Invoke(this, new EventArgs()); break; case LightweightEvents.MouseLeave: Scrolling = false; MouseLeave?.Invoke(this, new EventArgs()); break; case LightweightEvents.Update: Update?.Invoke(this, null); break; case LightweightEvents.DoubleClick: DoubleClick?.Invoke(this, new EventArgs()); break; case LightweightEvents.MouseMove: MouseMove?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; default: throw new NotImplementedException("The requested event for this control does not exist"); } }
public bool PropagateDoubleClick(Point mousePosition) { if (Visibility == Visibility.Hidden) { return(false); } if (mousePosition.X >= AbsolutePosition.X && mousePosition.X <= AbsolutePosition.X + Width && mousePosition.Y >= AbsolutePosition.Y && mousePosition.Y <= AbsolutePosition.Y + Height) { if (Children.Count > 0) { bool ret = false; for (int i = Children.Count - 1; i >= 0; i--) { LogicalNode child = Children[i]; if (child.PropagateDoubleClick(mousePosition)) { ret = true; } if (ret) { break; } } if (ret == false) { DoubleClick?.Invoke(this, null); foreach (MenuEvent ev in events.Values) { if (ev.EventType == MenuEvent.Type.DoubleClick) { ev.Trigger(this); } } return(true); } else { return(ret); } } else { DoubleClick?.Invoke(this, null); foreach (MenuEvent ev in events.Values) { if (ev.EventType == MenuEvent.Type.DoubleClick) { ev.Trigger(this); } } return(true); } } else { return(false); } }
protected virtual void OnDoubleClick(ButtonHandlerEventArgs e) { if (!_initialized) { throw new InvalidOperationException($"Not initialized {_pin}"); } DoubleClick?.Invoke(this, e); }
public void OnPointerClick(PointerEventData eventData) { FirstClick?.Invoke(this, null); if (eventData.clickCount == 2 || (Input.touchCount > 0 && Input.GetTouch(0).tapCount == 2)) { DoubleClick?.Invoke(this, null); } }
protected void HandleMouseDown(IMouse mouse, MouseButton button) { MouseDown?.Invoke(mouse, button); if (_firstClick || (_firstClickButton != null && _firstClickButton != button)) { // This is the first click with the given mouse button. _firstClickTime = null; if (!_firstClick && !(_firstClickButton is null)) { // Only the mouse buttons differ so treat last click as a single click. Click?.Invoke(mouse, _firstClickButton.Value, Position); } ProcessFirstClick(button); } else { // This is the second click with the same mouse button. if (_firstClickTime != null && (DateTime.Now - _firstClickTime.Value).TotalMilliseconds <= DoubleClickTime) { // Within the maximum double click time. _firstClickTime = null; var position = Position; if (Math.Abs(position.X - _firstClickPosition.X) < DoubleClickRange && Math.Abs(position.Y - _firstClickPosition.Y) < DoubleClickRange) { // Second click was in time and in range -> double click. _firstClick = true; DoubleClick?.Invoke(mouse, button, position); } else { // Second click was in time but outside range -> single click. // The second click is another "first click". Click?.Invoke(mouse, button, position); ProcessFirstClick(button); } } else { // The double click time elapsed. // If Update() would have detected the time elapse before, // it would have set _firstClick back to true and we won't be here. // Therefore Update() has not detected time elapse here and we have // to handle it. HandleDoubleClickTimeElapse(); // Now process the second click as another "first click". ProcessFirstClick(button); } } }
private void MouseButtonDownHandler(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2) { LabelDoubleClickArgs eventArgs = new LabelDoubleClickArgs(); eventArgs.Page = TaskPage; DoubleClick?.Invoke(sender, eventArgs); } }
void DoubleClicked(jQueryMouseEvent evt) { var tr = new jQuery(evt.Target).Closest("tr"); if(tr.Length == 0) return; var idx = (int) tr.Data("row-id"); if(!rowBindings.ContainsKey(idx)) return; var obj = rowBindings[idx]; DoubleClick?.Invoke(this, obj); }
private IntPtr HookFunc(int nCode, IntPtr wParam, IntPtr lParam) { // Parse system messages if (nCode >= 0) { if (MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam) { LeftButtonDown?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam) { LeftButtonUp?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam) { RightButtonDown?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_RBUTTONUP == (MouseMessages)wParam) { RightButtonUp?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam) { MouseMove?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_MOUSEWHEEL == (MouseMessages)wParam) { MouseWheel?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_LBUTTONDBLCLK == (MouseMessages)wParam) { DoubleClick?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_MBUTTONDOWN == (MouseMessages)wParam) { MiddleButtonDown?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } if (MouseMessages.WM_MBUTTONUP == (MouseMessages)wParam) { MiddleButtonUp?.Invoke( (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); } } return(CallNextHookEx(_hookId, nCode, wParam, lParam)); }
private void EventsSubscribe() { foreach (var item in _inventorySlots) { item.FirstClick += (obj, e) => SetActiveSlot((InventorySlot)obj); item.DoubleClick += (obj, e) => DoubleClick?.Invoke(obj, e); item.DragStarted += (obj, e) => DragStarted((InventorySlot)obj, e); item.Drag += (obj, e) => Drag((InventorySlot)obj, e); item.DragEnded += (obj, e) => OnDragEnded((InventorySlot)obj, e); } }
/// <summary> /// Raise event to go forward. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DragTime(object sender, EventArgs e) { // Stop the timer ((DispatcherTimer)sender).Stop(); if (!this.CursorIsOver() || Collection.level == Constants.Level.Episode) { return; } DoubleClick?.Invoke(this.Index, e); }
private void MainGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Selected?.Invoke(); IsSelected = true; mainGrid.Background = new SolidColorBrush(Color.FromRgb(216, 237, 255)); if (e.ClickCount == 2) { DoubleClick?.Invoke(); } }
private void ProcessMouseDown(MouseButtons button, bool doubleClick) { if (doubleClick) { DoubleClick?.Invoke(this, new MouseEventArgs(button, 2, 0, 0, 0)); MouseDoubleClick?.Invoke(this, new MouseEventArgs(button, 2, 0, 0, 0)); _doubleClickDown = true; } MouseDown?.Invoke(this, new MouseEventArgs(button, doubleClick ? 2 : 1, 0, 0, 0)); }
protected override int HookCallbackProcedure(int nCode, int wParam, IntPtr lParam) { if (nCode > -1 && (MouseDown != null || MouseUp != null || MouseMove != null)) { MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct)); MouseButtons button = GetButton(wParam); MouseEventType eventType = GetEventType(wParam); MouseEventArgs e = new MouseEventArgs( button, (eventType == MouseEventType.DoubleClick ? 2 : 1), mouseHookStruct.pt.x, mouseHookStruct.pt.y, (eventType == MouseEventType.MouseWheel ? (short)((mouseHookStruct.mouseData >> 16) & 0xffff) : 0)); // Prevent multiple Right Click events (this probably happens for popup menus) if (button == MouseButtons.Right && mouseHookStruct.flags != 0) { eventType = MouseEventType.None; } switch (eventType) { case MouseEventType.MouseDown: MouseDown?.Invoke(this, e); break; case MouseEventType.MouseUp: Click?.Invoke(this, new EventArgs()); MouseUp?.Invoke(this, e); break; case MouseEventType.DoubleClick: DoubleClick?.Invoke(this, new EventArgs()); break; case MouseEventType.MouseWheel: MouseWheel?.Invoke(this, e); break; case MouseEventType.MouseMove: MouseMove?.Invoke(this, e); break; default: break; } } return(CallNextHookEx(_handleToHook, nCode, wParam, lParam)); }
private IEnumerator WaitAndInvoke(int clickCount) { yield return(new WaitForSeconds(0.2f)); if (clickCount == 1) { SingleClick?.Invoke(); } else if (clickCount == 2) { DoubleClick?.Invoke(); } LastClick?.Invoke(clickCount); }
/* * ============================================ * Event * ============================================ */ #region Event /// <summary> /// Double click on the tile. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Tile_DoubleClick(object sender, MouseButtonEventArgs e) { // Don't do forward when holding the control key if (Keyboard.IsKeyDown(Key.LeftCtrl)) { return; } // The event is itercepeted in MainWindow, giving the order to the TileList to go to the next level if (e.ChangedButton == MouseButton.Left) { DoubleClick?.Invoke(this.Index, e); } }
public FileViewerInternal() { InitializeComponent(); InitializeComplete(); Disposed += (sender, e) => { //// _diffHighlightService not disposable //// _lineNumbersControl not disposable //// _currentViewPositionCache not disposable _findAndReplaceForm.Dispose(); }; _currentViewPositionCache = new CurrentViewPositionCache(this); TextEditor.ActiveTextAreaControl.TextArea.SelectionManager.SelectionChanged += SelectionManagerSelectionChanged; TextEditor.ActiveTextAreaControl.TextArea.PreviewKeyDown += (s, e) => { if (e.KeyCode == Keys.Escape && !TextEditor.ActiveTextAreaControl.SelectionManager.HasSomethingSelected) { EscapePressed?.Invoke(); } }; TextEditor.TextChanged += (s, e) => TextChanged?.Invoke(s, e); TextEditor.ActiveTextAreaControl.HScrollBar.ValueChanged += (s, e) => OnHScrollPositionChanged(EventArgs.Empty); TextEditor.ActiveTextAreaControl.VScrollBar.ValueChanged += (s, e) => OnVScrollPositionChanged(EventArgs.Empty); TextEditor.ActiveTextAreaControl.TextArea.KeyUp += (s, e) => KeyUp?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.DoubleClick += (s, e) => DoubleClick?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseMove += (s, e) => MouseMove?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseEnter += (s, e) => MouseEnter?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseLeave += (s, e) => MouseLeave?.Invoke(s, e); TextEditor.ActiveTextAreaControl.TextArea.MouseDown += (s, e) => { SelectedLineChanged?.Invoke( this, new SelectedLineEventArgs( TextEditor.ActiveTextAreaControl.TextArea.TextView.GetLogicalLine(e.Y))); }; TextEditor.ActiveTextAreaControl.TextArea.MouseWheel += TextArea_MouseWheel; HighlightingManager.Manager.DefaultHighlighting.SetColorFor("LineNumbers", new HighlightColor(SystemColors.ControlText, SystemColors.Control, false, false)); TextEditor.ActiveTextAreaControl.TextEditorProperties.EnableFolding = false; _lineNumbersControl = new DiffViewerLineNumberControl(TextEditor.ActiveTextAreaControl.TextArea); VRulerPosition = AppSettings.DiffVerticalRulerPosition; }
/// <summary> /// Callback function /// </summary> private IntPtr HookFunc(int nCode, IntPtr wParam, IntPtr lParam) { // parse system messages if (nCode < 0) { return(NativeMethods.CallNextHookEx(HookId, nCode, wParam, lParam)); } // ReSharper disable once SwitchStatementMissingSomeCases switch ((MouseFlags)wParam) { case MouseFlags.LeftDown: LeftButtonDown?.Invoke((MouseInput)Marshal.PtrToStructure(lParam, typeof(MouseInput))); break; case MouseFlags.LeftUp: LeftButtonUp?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.RightDown: RightButtonDown?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.RightUp: RightButtonUp?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.Move: MouseMove?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.Wheel: MouseWheel?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.DoubleLeftClick: DoubleClick?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.MiddleDown: MiddleButtonDown?.Invoke(MouseInputToStructure(lParam)); break; case MouseFlags.MiddleUp: MiddleButtonUp?.Invoke(MouseInputToStructure(lParam)); break; } return(NativeMethods.CallNextHookEx(HookId, nCode, wParam, lParam)); }
private void Select(object sender, MouseButtonEventArgs e) { OnSelect?.Invoke(Task); IsSelected = true; UpdateBackground(); OnSelected?.Invoke(Task); e.Handled = true; if (e.ClickCount == 2) { DoubleClick?.Invoke(Task); } }
private void OnClick(MouseButton button) { if (button == this.mostRecentButton) { this.numberOfHits++; if (this.numberOfHits == 2) { DoubleClick?.Invoke(button); } } else { this.mostRecentButton = button; this.timer = this.totalWaitTime; this.numberOfHits = 1; } }
/// <summary> /// Callback function /// </summary> protected override IntPtr HookFunc(int nCode, IntPtr wParam, IntPtr lParam) { // parse system messages if (nCode >= 0) { switch ((WM_MESSAGE)wParam) { case WM_MESSAGE.WM_LBUTTONDOWN: LeftButtonDown?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_LBUTTONUP: LeftButtonUp?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_RBUTTONDOWN: RightButtonDown?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_RBUTTONUP: RightButtonUp?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_MOUSEMOVE: MouseMove?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_MOUSEWHEEL: MouseWheel?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_LBUTTONDBLCLK: DoubleClick?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_MBUTTONDOWN: MiddleButtonDown?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; case WM_MESSAGE.WM_MBUTTONUP: MiddleButtonUp?.Invoke((MOUSEINPUT)Marshal.PtrToStructure(lParam, typeof(MOUSEINPUT))); break; } } return(CallNextHookEx(hookID, nCode, wParam, lParam)); }
private void Target_DoubleClick(object sender, EventArgs e) { var region = Target.ClientRectangle; var left = region.Left + MarginLeft; var top = region.Top + MarginTop; var width = region.Width - MarginLeft - MarginRight; var height = region.Height - MarginTop - MarginBottom; var p = Target.PointToClient(Control.MousePosition); var x = (p.X - left) / width; var y = (p.Y - top) / height; if (x >= 0 && x <= 1 && y >= 0 && y <= 1) { DoubleClick?.Invoke(x, y); } }
private void HandleClickActions(CanvasTransform t, IReadOnlyList <BonsaiNode> nodes, Event e) { if (IsClickAction(e)) { if (quickClicksCount == 0) { doubleClickTimer.Start(); } clickTimer.Start(); MouseDown?.Invoke(this, CreateInputEvent(t, nodes)); } else if (IsUnlickAction(e)) { BonsaiInputEvent inputEvent = CreateInputEvent(t, nodes); // A node click is registered if below a time threshold. if (clickTimer.Enabled) { Click?.Invoke(this, inputEvent); } // Collect quick, consecutive clicks. if (doubleClickTimer.Enabled) { quickClicksCount++; } // Double click event occured. if (quickClicksCount >= 2) { DoubleClick?.Invoke(this, inputEvent); doubleClickTimer.Stop(); quickClicksCount = 0; } clickTimer.Stop(); MouseUp?.Invoke(this, inputEvent); } }
private void OnControlLeftUp(object sender, EventArgs e) { // Do nothing if state isn't valid if (!_isEntered || !_isDown) { return; } // We're in here and down so this is a click or a double click depending on duration bool isDoubleClick = _lastClick != null && DateTime.UtcNow.Subtract(_lastClick.Value).TotalSeconds < DoubleClickTime; if (isDoubleClick) { DoubleClick?.Invoke(this, new EventArgs()); } else { Click?.Invoke(this, new EventArgs()); } // Mark as no longer down _isDown = false; _lastClick = isDoubleClick ? null : (DateTime?)DateTime.UtcNow; }
internal void FireMouseDoubleClick(MouseEventArgs e) { OnDoubleClick(e); DoubleClick?.Invoke(this, e); }
/// <summary> /// Raises the <see cref="E:DoubleClick"/> event. /// </summary> /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param> protected virtual void OnDoubleClick(MouseEventArgs e) { DoubleClick?.Invoke(this, e); }