private void MainImage_PointerWheelChanged(object sender, PointerWheelEventArgs e) { bool shift = e.KeyModifiers.HasFlag(KeyModifiers.Shift); bool ctrl = e.KeyModifiers.HasFlag(KeyModifiers.Control); bool alt = e.KeyModifiers.HasFlag(KeyModifiers.Alt); float delta = (float)e.Delta.Y; if (shift || ctrl) { _viewport.AddScale(delta * 0.1f, straight: ctrl, ToPoint(_pointerPos)); UpdateDrawerBounds(); } else if (alt) { _drawerSettings.pointRadiusLinear += delta * 0.1f; UpdateDrawerPointRadius(); } else { _viewport.MoveOrigin(new TD.Point(0, -delta * 10f)); UpdateDrawerBounds(); } MarkPresetChanged(); InvalidateView(false); // viewport changed only }
/// <inheritdoc/> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { if (Extent.Height > Viewport.Height || Extent.Width > Viewport.Width) { var scrollable = Child as ILogicalScrollable; bool isLogical = scrollable?.IsLogicalScrollEnabled == true; double x = Offset.X; double y = Offset.Y; if (Extent.Height > Viewport.Height) { double height = isLogical ? scrollable.ScrollSize.Height : 50; y += -e.Delta.Y * height; y = Math.Max(y, 0); y = Math.Min(y, Extent.Height - Viewport.Height); } if (Extent.Width > Viewport.Width) { double width = isLogical ? scrollable.ScrollSize.Width : 50; x += -e.Delta.X * width; x = Math.Max(x, 0); x = Math.Min(x, Extent.Width - Viewport.Width); } Offset = new Vector(x, y); e.Handled = true; } }
/// <inheritdoc/> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (!e.Handled) { if (!IsDropDownOpen) { if (IsFocused) { if (e.Delta.Y < 0) { SelectNext(); } else { SelectPrev(); } e.Handled = true; } } else { e.Handled = true; } } }
private static void GraphCanvas_PointerWheelChanged(object?sender, PointerWheelEventArgs e) { Zoom = Math.Min(Math.Max(Zoom * (1 - 0.1 * e.Delta.Y), 0.001), 200); TheMainWindow.FindControl <TextBlock>("tbInfo").Text = "Zoom: " + Math.Round(Zoom, 3).ToString(); UpdateCanvas(true); }
public void KeyboardPointerWheelChanged(object sender, PointerWheelEventArgs args) { lyricBox?.EndEdit(); var scrollbar = this.FindControl <ScrollBar>("VScrollBar"); VScrollPointerWheelChanged(scrollbar, args); }
public void NotesCanvasPointerWheelChanged(object sender, PointerWheelEventArgs args) { lyricBox?.EndEdit(); if (args.KeyModifiers == KeyModifiers.None) { var scrollbar = this.FindControl <ScrollBar>("VScrollBar"); VScrollPointerWheelChanged(scrollbar, args); } else if (args.KeyModifiers == KeyModifiers.Alt) { var canvas = (Canvas)sender; var position = args.GetCurrentPoint((IVisual)sender).Position; var size = canvas.Bounds.Size; position = position.WithX(position.X / size.Width).WithY(position.Y / size.Height); ViewModel.NotesViewModel.OnYZoomed(position, 0.1 * args.Delta.Y); } else if (args.KeyModifiers == KeyModifiers.Shift) { var scrollbar = this.FindControl <ScrollBar>("HScrollBar"); HScrollPointerWheelChanged(scrollbar, args); } else if (args.KeyModifiers == KeyModifiers.Control) { var canvas = this.FindControl <Canvas>("TimelineCanvas"); TimelinePointerWheelChanged(canvas, args); } }
public void VScrollPointerWheelChanged(object sender, PointerWheelEventArgs args) { var scrollbar = (ScrollBar)sender; scrollbar.Value = Math.Max(scrollbar.Minimum, Math.Min(scrollbar.Maximum, scrollbar.Value - scrollbar.SmallChange * args.Delta.Y)); lyricBox?.EndEdit(); }
private void Border_PointerWheelChanged(object?sender, PointerWheelEventArgs e) { if (!EnableZoom) { return; } Wheel(e); }
private void TextArea_MouseWheel(object sender, PointerWheelEventArgs e) { e.Handled = RaiseEventPair(GetScrollEventTarget(), null, PointerWheelChangedEvent, new PointerWheelEventArgs { Device = e.Device, Delta = e.Delta, InputModifiers = e.InputModifiers }); }
private void TabsListOnPointerWheelChanged(object sender, PointerWheelEventArgs e) { var command = e.Delta.Y > 0 ? ViewModel.SelectTabToTheLeftCommand : ViewModel.SelectTabToTheRightCommand; command.Execute(null); }
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { if (double.IsNaN(ShiftX)) { ShiftX = 0; } if (double.IsNaN(ShiftY)) { ShiftY = 0; } var oldx = ShiftX; var oldy = ShiftY; double newx = ShiftX, newy = ShiftY; base.OnPointerWheelChanged(e); var delta = e.Delta.Y; Debug.WriteLine("Delta = " + e.Delta); Debug.WriteLine(e.KeyModifiers); if (e.KeyModifiers == KeyModifiers.Control) { Debug.WriteLine("Raw position: " + e.GetPosition(this)); // get the screen coordinate of the current point. var p = ScreenPointToDominoCoordinates(e.GetPosition(this)); Debug.WriteLine("Computed position in domino coordinates: " + oldx + ", " + oldy); var newzoom = Zoom; if (delta > 0) { newzoom *= 1.1; } else { newzoom *= 1 / 1.1; } if (newzoom > FitAllZoomValue / 4 && newzoom < 4) { Zoom = newzoom; } newx = (p.X - e.GetPosition(this).X / Zoom); newy = (p.Y - e.GetPosition(this).Y / Zoom); } else { if (e.KeyModifiers == KeyModifiers.Shift) { newx = oldx - 100 * (e.Delta.X + e.Delta.Y); } else { newx = oldx - 100 * e.Delta.X; newy = oldy - 100 * delta; } } ShiftX = newx; ShiftY = newy; }
public void TimelinePointerWheelChanged(object sender, PointerWheelEventArgs args) { var canvas = (Canvas)sender; var position = args.GetCurrentPoint((IVisual)sender).Position; var size = canvas.Bounds.Size; position = position.WithX(position.X / size.Width).WithY(position.Y / size.Height); viewModel.TracksViewModel.OnXZoomed(position, 0.1 * args.Delta.Y); }
public void ImageScroll(object sender, PointerWheelEventArgs args) { var transform = (ScaleTransform)((TransformGroup)image.RenderTransform) .Children.First(x => x is ScaleTransform); var zoom = args.Delta.Y > 0 ? .2 : -.2; transform.ScaleX += zoom; transform.ScaleY += zoom; }
/// <summary> /// Converts <see cref="MouseWheelEventArgs" /> to <see cref="OxyMouseWheelEventArgs" /> for a mouse wheel event. /// </summary> /// <param name="e">The <see cref="MouseWheelEventArgs" /> instance containing the event data.</param> /// <param name="relativeTo">The <see cref="IInputElement" /> that the event is relative to.</param> /// <returns>A <see cref="OxyMouseWheelEventArgs" /> containing the converted event arguments.</returns> public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this PointerWheelEventArgs e, IInputElement relativeTo) { return(new OxyMouseWheelEventArgs { Position = e.GetPosition(relativeTo).ToScreenPoint(), ModifierKeys = Keyboard.Instance.GetModifierKeys(), Delta = (int)(e.Delta.Y + e.Delta.X) * 120 }); }
private void Border_PointerWheelChanged(object sender, PointerWheelEventArgs e) { if (_element != null) { Point point = e.GetPosition(_element); point = FixInvalidPointPosition(point); ZoomDeltaTo(e.Delta.Y, point); } }
private void TextArea_MouseWheel(object sender, PointerWheelEventArgs e) { if (!IsOpen) { return; } e.Handled = RaiseEventPair(GetScrollEventTarget(), null, PointerWheelChangedEvent, e); }
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { var pointer = e.GetPosition(this); var controlPressed = e.InputModifiers.HasFlag(InputModifiers.Control); if (controlPressed) { double scale = 0.9 * (e.Delta.Y / 120); var newFontSize = FontSize; if (scale < 0) { newFontSize *= Math.Abs(scale); } else { newFontSize /= scale; } if (newFontSize < 2) { newFontSize = 2; } if (newFontSize > 20) { newFontSize = 20; } if (newFontSize != FontSize) { FontSize = newFontSize; InvalidateVisual(); } } else { int oldViewTop = ViewTop; ViewTop -= (int)(e.Delta.Y / 40); if (ViewTop < 0) { ViewTop = 0; } else if (ViewTop > Terminal.ViewPort.TopRow) { ViewTop = Terminal.ViewPort.TopRow; } if (oldViewTop != ViewTop) { InvalidateVisual(); } } }
/// <summary> /// Redistribute the mouse wheel event on the parent. /// We don't want the sublist to catch the mouse wheel events because it would /// prevent scrolling in the parent list. /// </summary> private void OnSubListBoxPreviewMouseWheel(object sender, PointerWheelEventArgs e) { if (!e.Handled) { //TODO e.Handled = true; var parent = ((Control)sender).Parent; parent.RaiseEvent(e); } }
private void Wheel(PointerWheelEventArgs e) { if (_element == null || _captured) { return; } var point = e.GetPosition(_element); ZoomDeltaTo(e.Delta.Y, point.X, point.Y); }
/* * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationStarted" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationStarted(ManipulationStartedEventArgs e) * { * base.OnManipulationStarted(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchStarted(this, e.ToTouchEventArgs(this)); * } * * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationDelta" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationDelta(ManipulationDeltaEventArgs e) * { * base.OnManipulationDelta(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchDelta(this, e.ToTouchEventArgs(this)); * } * * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationCompleted" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e) * { * base.OnManipulationCompleted(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchCompleted(this, e.ToTouchEventArgs(this)); * } */ /// <summary> /// Called before the <see cref="E:System.Windows.UIElement.MouseWheel" /> event occurs to provide handling for the event in a derived class without attaching a delegate. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Input.MouseWheelEventArgs" /> that contains the event data.</param> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (e.Handled || !IsMouseWheelEnabled) { return; } e.Handled = ActualController.HandleMouseWheel(this, e.ToMouseWheelEventArgs(this)); }
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { if (this.Extent.Height > this.Viewport.Height) { var y = this.Offset.Y + (-e.Delta.Y * 50); y = Math.Max(y, 0); y = Math.Min(y, this.Extent.Height - this.Viewport.Height); this.Offset = new Vector(this.Offset.X, y); e.Handled = true; } }
/// <inheritdoc /> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (!e.Handled && AllowSpin) { if (e.Delta.Y != 0) { var spinnerEventArgs = new SpinEventArgs(SpinEvent, (e.Delta.Y < 0) ? SpinDirection.Decrease : SpinDirection.Increase, true); OnSpin(spinnerEventArgs); e.Handled = spinnerEventArgs.Handled; } } }
private void MouseScrollCanvas(object sender, PointerWheelEventArgs args) { var pos = args.GetPosition(this); var matrix = mt.Matrix; double scale = 1 + args.Delta.Y / 10; mt.Matrix = ZoomToLocation(matrix, new Point(pos.X - graphCanvas.Bounds.Width / 2, pos.Y - graphCanvas.Bounds.Height / 2), scale); if (fsmData != null) { fsmData.matrix = mt.Matrix; } }
private void OnPointerWheelChanged(object?sender, PointerWheelEventArgs e) { // Scroll faster if ((sender as Control)?.Parent is ScrollViewer scrollViewer) { const int offset = 100; // 100 feels about right scroll-wise var y = e.Delta.Y < 0 ? offset : -offset; scrollViewer.Offset += new Vector(0, y); } }
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (!e.Handled && SelectedDate.HasValue && _calendar != null) { DateTime selectedDate = this.SelectedDate.Value; DateTime?newDate = DateTimeHelper.AddDays(selectedDate, e.Delta.Y > 0 ? -1 : 1); if (newDate.HasValue && Calendar.IsValidDateSelection(_calendar, newDate.Value)) { SelectedDate = newDate; e.Handled = true; } } }
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { // Scroll Horizontally default when content width greater than viewport width // and the height of content is less equal than viewport height if (Extent.Width > Viewport.Width) { var scrollable = Child as ILogicalScrollable; bool isLogical = scrollable?.IsLogicalScrollEnabled == true; double x = Offset.X; double y = Offset.Y; double width = isLogical ? scrollable !.ScrollSize.Width : 50; x += -e.Delta.Y * width; x = Math.Max(x, 0); x = Math.Min(x, Extent.Width - Viewport.Width); Offset = new Vector(x, y); e.Handled = true; } /*if (Extent.Height > Viewport.Height || Extent.Width > Viewport.Width) * { * var scrollable = Child as ILogicalScrollable; * bool isLogical = scrollable?.IsLogicalScrollEnabled == true; * * double x = Offset.X; * double y = Offset.Y; * * if (Extent.Height > Viewport.Height) * { * double height = isLogical ? scrollable!.ScrollSize.Height : 50; * y += -e.Delta.Y * height; * y = Math.Max(y, 0); * y = Math.Min(y, Extent.Height - Viewport.Height); * } * * if (Extent.Width > Viewport.Width) * { * double width = isLogical ? scrollable!.ScrollSize.Width : 50; * x += -e.Delta.X * width; * x = Math.Max(x, 0); * x = Math.Min(x, Extent.Width - Viewport.Width); * } * * Offset = new Vector(x, y); * e.Handled = true; * }*/ }
/// <inheritdoc /> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (e.Handled) { return; } PointerPoint point = e.GetCurrentPoint(this); if (HandlePointerEvent(point, e.Delta)) { e.Handled = true; } }
private void OnWheelChanged(object sender, PointerWheelEventArgs e) { if (IsCtrlPressed) { if (e.Delta.Y > 0) { OwnerEditor.StatusBar.IncreaseFontSize(); } else { OwnerEditor.StatusBar.DecreaseFontSize(); } e.Handled = true; } }
private void Host_MouseWheel(object?sender, PointerWheelEventArgs e) { if (PlayerHost == null) { return; } if (ChangeVolumeOnMouseWheel) { if (e.Delta.Y > 0) { PlayerHost.Volume += 5; } else if (e.Delta.Y < 0) { PlayerHost.Volume -= 5; } } }
private void PanAndZoomBorder_PointerWheelChanged(object sender, PointerWheelEventArgs e) { if (_initialize == false && _child != null) { var st = GetScaleTransform(_child); var tt = GetTranslateTransform(_child); double zoom = e.Delta.Y > 0 ? .2 : -.2; if (!(e.Delta.Y > 0) && (st.ScaleX < .4 || st.ScaleY < .4)) { return; } Point relative = e.GetPosition(_child); double abosuluteX = relative.X * st.ScaleX + tt.X; double abosuluteY = relative.Y * st.ScaleY + tt.Y; st.ScaleX += zoom; st.ScaleY += zoom; tt.X = abosuluteX - relative.X * st.ScaleX; tt.Y = abosuluteY - relative.Y * st.ScaleY; } }