//TODO TabStop private void DataGridRowGroupHeader_PointerPressed(PointerPressedEventArgs e) { if (OwningGrid == null) { return; } if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { if (OwningGrid.IsDoubleClickRecordsClickOnCall(this) && !e.Handled) { ToggleExpandCollapse(!RowGroupInfo.IsVisible, true); e.Handled = true; } else { //if (!e.Handled && OwningGrid.IsTabStop) if (!e.Handled) { OwningGrid.Focus(); } e.Handled = OwningGrid.UpdateStateOnMouseLeftButtonDown(e, OwningGrid.CurrentColumnIndex, RowGroupInfo.Slot, allowEdit: false); } } else if (e.GetCurrentPoint(this).Properties.IsRightButtonPressed) { if (!e.Handled) { OwningGrid.Focus(); } e.Handled = OwningGrid.UpdateStateOnMouseRightButtonDown(e, OwningGrid.CurrentColumnIndex, RowGroupInfo.Slot, allowEdit: false); } }
private void TrackPressed(object sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { MoveToPoint(e.GetCurrentPoint(_track)); _isDragging = true; } }
private void DecreaseButton_PointerPressed(object sender, PointerPressedEventArgs e) { if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { return; } var x = e.GetCurrentPoint(_track); Value = x.Position.X / _track.Bounds.Width; }
protected override void OnPointerPressed(PointerPressedEventArgs e) { // in the same frame got focus and pressed button, ignore the event if (lastGotFocusFrame == frame) { return; } var left = e.GetCurrentPoint(this).Properties.IsLeftButtonPressed; var right = e.GetCurrentPoint(this).Properties.IsRightButtonPressed; engine?.inputManager.mouse.MouseDown((left ? MouseButton.Left : MouseButton.None) | (right ? MouseButton.Right : MouseButton.None)); base.OnPointerPressed(e); }
private void ImgResize_OnPointerPressed(object?sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { BeginResizeDrag(WindowEdge.SouthEast, e); } }
private void InputElement_OnPointerPressed(object?sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { BeginMoveDrag(e); } }
// Handlers: public void OnComponentClick(Component sender, PointerPressedEventArgs e) { if (_buffer == null) { _buffer = sender; var pos = ToGridCoordinates(e.GetCurrentPoint(Canvas).Position); Canvas.Children.Add(_previewConnection = new Polyline { Points = new List <Point> { pos, pos } }); } else { if (!(sender is ObservingComponent)) { Connections.Add(new Connection(sender, (ObservingComponent)_buffer, _previewConnection)); } else if (!(_buffer is Output)) { Connections.Add(new Connection(_buffer, (ObservingComponent)sender, _previewConnection)); } else { Connections.Add(new Connection((ObservingComponent)sender, (Output)_buffer, _previewConnection)); } _buffer = null; Canvas.Children.Remove(_previewConnection); _previewConnection = null; FileHandler.Changed(); } }
private async void OpenInViewer(object?sender, PointerPressedEventArgs e) { try { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed&& sender is Grid grid && grid.Children[0] is Image image) { e.Handled = true; if ((e.KeyModifiers & KeyModifiers.Control) != 0) { var mediaUrl = (image.DataContext as Media)?.MediaUrl; App.Commands.AddToHiddenImages.Execute((mediaUrl, this.PointToScreen(new Point(5, 10)))); } else { await ImageService.OpenInViewer(image); } } } catch (Exception ex) { TraceService.Message(ex.Message); } }
private void HandlePointerPressed(PointerPressedEventArgs e) { var properties = e.GetCurrentPoint(RelativeTo).Properties; if (properties.IsLeftButtonPressed) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers)); if (InputTarget.IsLeftDownAvailable()) { InputTarget.LeftDown(args); } } } else if (properties.IsRightButtonPressed) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers)); if (InputTarget.IsRightDownAvailable()) { InputTarget.RightDown(args); } } } }
public void DragFailed(PointerPressedEventArgs e) { PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind; if (MouseButton == PointerUpdateKind.RightButtonPressed) { ApolloContextMenu menu = DeviceContextMenu; List <ISelect> selection = Track.Get(_device)?.Window?.Selection.Selection; if (selection.Count == 1) { if (selection[0] is Group group && group.Count == 1) { menu = GroupContextMenu; } else if (selection[0] is Choke) { menu = ChokeContextMenu; } } DeviceMute.Header = GroupMute.Header = ChokeMute.Header = ((Device)selection.First()).Enabled? "Mute" : "Unmute"; menu.Open(Draggable); }
protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (!e.GetCurrentPoint(this).Properties.IsRightButtonPressed) { e.Handled = true; return; } var cm = new ContextMenu(); var items = new List <MenuItem>(); for (var i = 0; i < 100; ++i) { items.Add(new MenuItem { Header = $"Item {i}" }); } cm.Items = items; ContextMenu = cm; cm.PlacementAnchor = Avalonia.Controls.Primitives.PopupPositioning.PopupAnchor.TopLeft; cm.PlacementGravity = Avalonia.Controls.Primitives.PopupPositioning.PopupGravity.BottomRight; cm.PlacementMode = PlacementMode.AnchorAndGravity; cm.PlacementRect = new Avalonia.Rect(100, 100, 1, 1); cm.Open(); e.Handled = true; }
/// <summary> /// just sets is handled to true /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EllipsePointer_MouseLeftButtonDown(object sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(_ellipsePointer).Properties.IsLeftButtonPressed) { e.Handled = true; } }
// 鼠标按下 protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); //if (e.MouseButton != MouseButton.Left) // return; if (e.GetCurrentPoint(this).Properties.PointerUpdateKind != PointerUpdateKind.LeftButtonPressed) { return; } // 所在面板无法在构造函数里求得 if (parentIVisual == null) { parentIVisual = this.Parent.Parent.Parent; } isPressed = true; pressPoint = e.GetPosition(parentIVisual); oldLocation = new Point(NetworkItemVM.X, NetworkItemVM.Y); // 记录每个锚点的旧位置 if (NetworkItemVM.ConnectorVMs != null) { foreach (Connector_VM connectorVM in NetworkItemVM.ConnectorVMs) { connectorVM.OldPos = connectorVM.Pos; } } //ResourceManager.mainWindowVM.Tips = "鼠标按下,记录图形位置:" + oldLocation; e.Handled = true; }
public void ExpCanvasPointerPressed(object sender, PointerPressedEventArgs args) { lyricBox?.EndEdit(); if (ViewModel.NotesViewModel.Part == null) { return; } var canvas = (Canvas)sender; var point = args.GetCurrentPoint(canvas); if (editState != null) { return; } if (point.Properties.IsLeftButtonPressed) { editState = new ExpSetValueState(canvas, ViewModel, expValueTip !); } else if (point.Properties.IsRightButtonPressed) { editState = new ExpResetValueState(canvas, ViewModel); Cursor = ViewConstants.cursorNo; } if (editState != null) { editState.Begin(point.Pointer, point.Position); editState.Update(point.Pointer, point.Position); } }
public void NotesCanvasPointerPressed(object sender, PointerPressedEventArgs args) { lyricBox?.EndEdit(); if (ViewModel.NotesViewModel.Part == null) { return; } var canvas = (Canvas)sender; var point = args.GetCurrentPoint(canvas); if (editState != null) { return; } if (point.Properties.IsLeftButtonPressed) { NotesCanvasLeftPointerPressed(canvas, point, args); } else if (point.Properties.IsRightButtonPressed) { ViewModel.NotesViewModel.DeselectNotes(); editState = new NoteEraseEditState(canvas, ViewModel); Cursor = ViewConstants.cursorNo; } else if (point.Properties.IsMiddleButtonPressed) { editState = new NotePanningState(canvas, ViewModel); Cursor = ViewConstants.cursorHand; } if (editState != null) { editState.Begin(point.Pointer, point.Position); editState.Update(point.Pointer, point.Position); } }
private void TitleBarPressedEventHandler(object sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { ((Window)this.VisualRoot).BeginMoveDrag(e); } }
private void Calendar_PointerPressed(object sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { e.Handled = true; } }
private static void HandlePointerPressed <TControl>(TControl sender, PointerPressedEventArgs e) where TControl : Control { if (e.GetCurrentPoint(sender).Properties.IsLeftButtonPressed) { ((IPseudoClasses)sender.Classes).Set(":pressed", true); } }
private void CardRenderTarget_PointerPressed(object sender, PointerPressedEventArgs e) { if (VM.CursorMode && CardRenderTarget.Children.Count > 0 && CardRenderTarget.Children[0] is Canvas renderedCard) { _dragStartingPoint = e.GetCurrentPoint(renderedCard).Position; } }
/// <inheritdoc/> protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed&& e.Pointer.Type == PointerType.Mouse) { e.Handled = UpdateSelectionFromEventSource(e.Source); } }
/// <summary> /// Provides class handling for the MouseLeftButtonDown event that /// occurs when the left mouse button is pressed while the mouse pointer /// is over this control. /// </summary> /// <param name="e">The event data. </param> /// <exception cref="System.ArgumentNullException"> /// e is a null reference (Nothing in Visual Basic). /// </exception> /// <remarks> /// This method marks the MouseLeftButtonDown event as handled by /// setting the MouseButtonEventArgs.Handled property of the event data /// to true when the button is enabled and its ClickMode is not set to /// Hover. Since this method marks the MouseLeftButtonDown event as /// handled in some situations, you should use the Click event instead /// to detect a button click. /// </remarks> protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { CalendarLeftMouseButtonDown?.Invoke(this, e); } }
protected override void OnPointerPressed(PointerPressedEventArgs e) { var p = e.GetCurrentPoint(this); if (DataContext is EditProjectVM ed) { ed.Canvas_MouseDown(ScreenPointToDominoCoordinates(p.Position), e); } }
protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); e.GetCurrentPoint(this).Position.Deconstruct(out double x, out double y); Color c = SquareRender.HitOn(new Avalonia.PixelPoint((int)x, (int)y)); Debug.WriteLine($"The hit color is: \"{c}\" "); }
void Select(PointerPressedEventArgs e) { PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind; if (MouseButton == PointerUpdateKind.LeftButtonPressed || (MouseButton == PointerUpdateKind.RightButtonPressed && !selected)) { _pattern.Window?.Selection.Select(Viewer.Frame, e.KeyModifiers.HasFlag(KeyModifiers.Shift)); } }
protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true) { switch (Orientation) { case Orientation.Horizontal: SelectableThumbs.Insert((int)e.GetCurrentPoint(this).Position.X, new SelectableThumb <TCustomValue>()); break; case Orientation.Vertical: SelectableThumbs.Insert((int)e.GetCurrentPoint(this).Position.Y, new SelectableThumb <TCustomValue>()); break; } } }
protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) { StartTimer(); } }
void Click(object sender, PointerPressedEventArgs e) { PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind; if (MouseButton == PointerUpdateKind.LeftButtonPressed) { Selected?.Invoke(Program.Project.Undo.History.IndexOf(_entry)); } }
public void picTileset_Click(object sender, PointerPressedEventArgs e) { PointerPoint pt = e.GetCurrentPoint((IVisual)sender); TileBrowserViewModel vm = (TileBrowserViewModel)DataContext; Loc clickedLoc = new Loc((int)pt.Position.X / vm.TileSize, (int)pt.Position.Y / vm.TileSize); vm.SelectTile(clickedLoc, (e.InputModifiers & InputModifiers.RightMouseButton) != InputModifiers.None, (e.KeyModifiers & KeyModifiers.Shift) != KeyModifiers.None); }
public void Select(PointerPressedEventArgs e) { PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind; if (MouseButton == PointerUpdateKind.LeftButtonPressed || (MouseButton == PointerUpdateKind.RightButtonPressed && !Selected)) { Track.Get(_chain)?.Window?.Selection.Select(_chain, e.KeyModifiers.HasFlag(KeyModifiers.Shift)); } }
void MouseDown(object sender, PointerPressedEventArgs e) { PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind; if (MouseButton == PointerUpdateKind.LeftButtonPressed || MouseButton == PointerUpdateKind.RightButtonPressed) { mouseHeld = true; } }