/// <summary> /// Handles the <see cref="Mouse.PreviewMouseDownEvent"/>. /// </summary> private static void HandlePreviewMouseDown(DependencyObject element, MouseDevice device, MouseButton button, ref RoutedEventData data) { if (button == MouseButton.Left) { ((SliderBase)element).Focus(); } }
/// <inheritdoc/> protected override void OnMouseEnter(MouseDevice device, ref RoutedEventData data) { if (HighlightOnMouseOver) { HighlightOpacity = 1.0; } base.OnMouseEnter(device, ref data); }
/// <inheritdoc/> protected override void OnPreviewGotKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (!data.Handled && newFocus == this) { Select(); } base.OnPreviewGotKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <inheritdoc/> protected override void OnGotKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (PART_Input != null) { PART_Input.Focus(); } base.OnGotKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <inheritdoc/> protected override void OnGenericInteraction(UltravioletResource device, ref RoutedEventData data) { if (!data.Handled) { Focus(); data.Handled = true; } base.OnGenericInteraction(device, ref data); }
/// <inheritdoc/> protected override void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (PART_Input != null) { PART_Input.InvalidateDisplayCache(TextBox.TextProperty); PART_Input.CaretIndex = 0; } base.OnLostKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <inheritdoc/> void IRoutedEventRaisedNotificationSubscriber.ReceiveRoutedEventRaisedNotification(DependencyObject dobj, RoutedEvent evt, RoutedEventData data) { if (!data.Handled || handled) { Activate(dobj); if (setHandled) { data.Handled = true; } } }
/// <inheritdoc/> protected override void OnGenericInteraction(UltravioletResource device, ref RoutedEventData data) { if (!data.Handled) { var comboBox = ItemsControl.ItemsControlFromItemContainer(this) as ComboBox; if (comboBox != null) { comboBox.HandleItemClicked(this); } data.Handled = true; } base.OnGenericInteraction(device, ref data); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { switch (key) { case Key.Left: DecreaseSmall(); data.Handled = true; break; case Key.Right: IncreaseSmall(); data.Handled = true; break; } base.OnKeyDown(device, key, modifiers, ref data); }
/// <inheritdoc/> protected override void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, RoutedEventData data) { if (!GamePad.UseAxisForDirectionalNavigation) { switch (button) { case GamePadButton.DPadUp: DecreaseSmall(); data.Handled = true; break; case GamePadButton.DPadDown: IncreaseSmall(); data.Handled = true; break; } } base.OnGamePadButtonDown(device, button, repeat, data); }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: DecreaseSmall(); data.Handled = true; break; case GamePadJoystickDirection.Down: IncreaseSmall(); data.Handled = true; break; } } base.OnGamePadAxisDown(device, axis, value, repeat, data); }
/// <summary> /// Handles the <see cref="Mouse.PreviewMouseDownEvent"/>. /// </summary> private static void HandlePreviewMouseDown(DependencyObject element, MouseDevice device, MouseButton button, RoutedEventData data) { var slider = element as OrientedSlider; if (slider == null) { return; } if (button == MouseButton.Left) { slider.Focus(); } }
/// <inheritdoc/> protected override void OnLostTouchCapture(TouchDevice device, Int64 id, RoutedEventData data) { HandleCursorUp(id); base.OnLostTouchCapture(device, id, data); }
/// <inheritdoc/> protected override void OnMouseDoubleClick(MouseDevice device, MouseButton button, ref RoutedEventData data) { if (PART_Editor != null && IsMouseWithinEditor()) { PART_Editor.HandleMouseDoubleClick(device, button, ref data); } base.OnMouseDoubleClick(device, button, ref data); }
/// <summary> /// Occurs when the user completes a thumb drag operation. /// </summary> private static void HandleThumbDragCompleted(DependencyObject element, Double hchange, Double vchange, RoutedEventData data) { var slider = (OrientedSlider)element; slider.OnThumbDragCompleted(hchange, vchange, data); }
/// <summary> /// Occurs when the user finishes dragging the slider's thumb button. /// </summary> /// <param name="hchange">The total distance that the thumb moved horizontally.</param> /// <param name="vchange">The total distance that the thumb moved vertically.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnThumbDragCompleted(Double hchange, Double vchange, RoutedEventData data) { }
/// <inheritdoc/> protected override void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { Ultraviolet.GetInput().HideSoftwareKeyboard(); if (PART_Editor != null) { PART_Editor.HandleLostKeyboardFocus(); } UpdateIsSelectionActive(); base.OnLostKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <summary> /// Handles the <see cref="Keyboard.PreviewKeyDownEvent"/> routed event. /// </summary> private static void HandlePreviewKeyDown(DependencyObject element, KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { var numericUpDown = (NumericUpDown)element; if (numericUpDown.PART_Input == data.OriginalSource) { switch (key) { case Key.Up: numericUpDown.IncreaseSmall(); data.Handled = true; break; case Key.Down: numericUpDown.DecreaseSmall(); data.Handled = true; break; } } }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Mouse.LostMouseCapture"/> /// attached event for the specified element. /// </summary> internal static void RaiseLostMouseCapture(DependencyObject element, RoutedEventData data) { var evt = EventManager.GetInvocationDelegate<UpfRoutedEventHandler>(LostMouseCaptureEvent); evt?.Invoke(element, data); }
/// <summary> /// Called when the ButtonDown component is clicked. /// </summary> private void Decrement(DependencyObject element, ref RoutedEventData data) { DecreaseSmall(); }
/// <summary> /// Handles the <see cref="Mouse.PreviewMouseWheelEvent"/> routed event. /// </summary> private static void HandlePreviewMouseWheel(DependencyObject element, MouseDevice device, Double x, Double y, ref RoutedEventData data) { var numericUpDown = (NumericUpDown)element; if (numericUpDown.PART_Input.IsKeyboardFocused) { numericUpDown.Value += y; } }
/// <inheritdoc/> protected override void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, ref RoutedEventData data) { if (!GamePad.UseAxisForDirectionalNavigation) { switch (button) { case GamePadButton.DPadUp: IncreaseSmall(); data.Handled = true; break; case GamePadButton.DPadDown: DecreaseSmall(); data.Handled = true; break; } } base.OnGamePadButtonDown(device, button, repeat, ref data); }
/// <inheritdoc/> protected override void OnTouchMove(TouchDevice device, Int64 id, Double x, Double y, Double dx, Double dy, Single pressure, RoutedEventData data) { if (IsDragging) { HandleCursorMove(0); data.Handled = true; } base.OnTouchMove(device, id, x, y, dx, dy, pressure, data); }
/// <inheritdoc/> protected override void OnTouchDown(TouchDevice device, Int64 id, Double x, Double y, Single pressure, RoutedEventData data) { Focus(); CaptureTouch(id); HandleCursorDown(id); data.Handled = true; base.OnTouchDown(device, id, x, y, pressure, data); }
/// <summary> /// Raises the PreviewAxisUp attached event for the specified element. /// </summary> internal static void RaisePreviewAxisUp(DependencyObject element, GamePadDevice device, GamePadAxis axis, ref RoutedEventData data) { var temp = EventManager.GetInvocationDelegate<UpfGamePadAxisUpEventHandler>(PreviewAxisUpEvent); if (temp != null) { temp(element, device, axis, ref data); } }
/// <summary> /// Handles text entry validation for the updown's text editor. /// </summary> private static void HandleTextEntryValidation(DependencyObject element, StringSegment text, Int32 offset, Char character, ref Boolean valid, ref RoutedEventData data) { var numericUpDown = (NumericUpDown)element; if (numericUpDown.PART_Input != data.OriginalSource) { return; } data.Handled = true; // Negative sign must be inserted at the beginning of the text. // Negative sign is only allowed if Minimum is less than zero. if (character == '-') { if (offset > 0 || numericUpDown.Minimum >= 0) { valid = false; } return; } // Nothing can be inserted before the negative sign, if there is one. var negativeSignPos = text.IndexOf('-'); if (negativeSignPos >= 0 && offset < 1) { valid = false; return; } // Decimal separator can only be inserted if we allow decimal points. // Decimal separator can only be inserted if it doesn't introduce more than the allowed number of decimals. var decimalSeparatorPos = text.IndexOf('.'); if (character == '.') { if (decimalSeparatorPos >= 0 || numericUpDown.DecimalPlaces == 0) { valid = false; return; } var decimalsIntroduced = text.Length - offset; if (decimalsIntroduced > numericUpDown.DecimalPlaces) { valid = false; } return; } // Non-digit characters cannot be inserted. if (!Char.IsDigit(character)) { valid = false; return; } // Post-decimal digits can only be inserted if we have fewer than DecimalPlaces digits there already. var decimalCount = (decimalSeparatorPos < 0) ? 0 : text.Length - (decimalSeparatorPos + 1); if (decimalSeparatorPos >= 0 && decimalSeparatorPos < offset && decimalCount >= numericUpDown.DecimalPlaces) { valid = false; return; } }
/// <summary> /// Raises the ButtonUp attached event for the specified element. /// </summary> internal static void RaiseButtonUp(DependencyObject element, GamePadDevice device, GamePadButton button, ref RoutedEventData data) { var temp = EventManager.GetInvocationDelegate<UpfGamePadButtonUpEventHandler>(ButtonUpEvent); if (temp != null) { temp(element, device, button, ref data); } }
/// <inheritdoc/> protected override void OnLostMouseCapture(RoutedEventData data) { HandleCursorUp(0); base.OnLostMouseCapture(data); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Mouse.PreviewMouseUp"/> /// attached event for the specified element. /// </summary> internal static void RaisePreviewMouseUp(DependencyObject element, MouseDevice device, MouseButton button, RoutedEventData data) { var evt = EventManager.GetInvocationDelegate<UpfMouseButtonEventHandler>(PreviewMouseUpEvent); evt?.Invoke(element, device, button, data); }
/// <inheritdoc/> protected override void OnGamePadButtonUp(GamePadDevice device, GamePadButton button, RoutedEventData data) { if (GamePad.ConfirmButton == button) { HandleReleased(false); data.Handled = true; } base.OnGamePadButtonUp(device, button, data); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { if (PART_Editor != null) { PART_Editor.HandleKeyDown(device, key, modifiers, ref data); } base.OnKeyDown(device, key, modifiers, ref data); }
/// <inheritdoc/> protected override void OnKeyUp(KeyboardDevice device, Key key, RoutedEventData data) { if (key == Key.Return || key == Key.Space) { HandleReleased(false); data.Handled = true; } base.OnKeyUp(device, key, data); }
/// <inheritdoc/> protected override void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, ref RoutedEventData data) { if (PART_Editor != null) { PART_Editor.HandleMouseMove(device, ref data); } data.Handled = true; base.OnMouseMove(device, x, y, dx, dy, ref data); }
/// <inheritdoc/> protected override void OnLostMouseCapture(RoutedEventData data) { IsPressed = false; base.OnLostMouseCapture(data); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Touch.FingerMotion"/> /// attached event for the specified element. /// </summary> internal static void RaiseFingerMotion(DependencyObject element, TouchDevice device, Int64 fingerID, Double x, Double y, Double dx, Double dy, Single pressure, ref RoutedEventData data) { var evt = EventManager.GetInvocationDelegate <UpfTouchMotionEventHandler>(FingerMotionEvent); evt?.Invoke(element, device, fingerID, x, y, dx, dy, pressure, ref data); }
/// <inheritdoc/> protected override void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data) { if (ClickMode != ClickMode.Hover) { if (IsMouseCaptured && device.IsButtonDown(MouseButton.Left)) { var position = Mouse.GetPosition(this); IsPressed = Bounds.Contains(position); } } base.OnMouseMove(device, x, y, dx, dy, data); }
/// <summary> /// Occurs when the user starts a thumb drag operation. /// </summary> private static void HandleThumbDragStarted(DependencyObject element, Double hoffset, Double voffset, RoutedEventData data) { var slider = (OrientedSlider)element; slider.OnThumbDragStarted(hoffset, voffset, data); }
/// <inheritdoc/> protected override void OnFingerMotion(TouchDevice device, Int64 fingerID, Double x, Double y, Double dx, Double dy, Single pressure, RoutedEventData data) { data.Handled = true; base.OnFingerMotion(device, fingerID, x, y, dx, dy, pressure, data); }
/// <inheritdoc/> protected override void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data) { if (IsDragging) { HandleCursorMove(0); data.Handled = true; } base.OnMouseMove(device, x, y, dx, dy, data); }
/// <inheritdoc/> protected override void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, RoutedEventData data) { if (GamePad.ConfirmButton == button && !repeat) { HandlePressed(); data.Handled = true; } base.OnGamePadButtonDown(device, button, repeat, data); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { if (key == Key.Return || key == Key.Space) { HandlePressed(); data.Handled = true; } base.OnKeyDown(device, key, modifiers, data); }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: IncreaseSmall(); data.Handled = true; break; case GamePadJoystickDirection.Down: DecreaseSmall(); data.Handled = true; break; } } base.OnGamePadAxisDown(device, axis, value, repeat, ref data); }
/// <inheritdoc/> protected override void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data) { if (IsPressed) { IsPressed = false; } base.OnLostKeyboardFocus(device, oldFocus, newFocus, data); }
/// <inheritdoc/> protected override void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data) { LinkUtil.UpdateLinkCursor(textLayoutCommands, this, Mouse.GetPosition(this)); base.OnMouseMove(device, x, y, dx, dy, data); }
/// <inheritdoc/> protected override void OnMouseEnter(MouseDevice device, RoutedEventData data) { if (ClickMode == ClickMode.Hover) { OnClick(); OnClickByUser(); } base.OnMouseEnter(device, data); }
/// <inheritdoc/> protected override void OnMouseLeave(MouseDevice device, RoutedEventData data) { LinkUtil.UpdateLinkCursor(textLayoutCommands, this, Mouse.GetPosition(this)); base.OnMouseLeave(device, data); }
/// <inheritdoc/> protected override void OnMouseUp(MouseDevice device, MouseButton button, RoutedEventData data) { if (button == MouseButton.Left) { HandleReleased(); data.Handled = true; } base.OnMouseUp(device, button, data); }
/// <summary> /// Raises the <see cref="P:Ultraviolet.Presentation.Controls.ToolTipService.ToolTipClosing"/> /// attached event for the specified element. /// </summary> internal static void RaiseToolTipClosing(DependencyObject element, RoutedEventData data) { var evt = EventManager.GetInvocationDelegate <UpfToolTipEventHandler>(ToolTipClosingEvent); evt?.Invoke(element, data); }
/// <summary> /// Handles the <see cref="ButtonBase.Click"/> event for LineUpButton. /// </summary> private void HandleClickLineUp(DependencyObject element, RoutedEventData data) { DecreaseSmall(); RaiseScrollEvent(ScrollEventType.SmallDecrement); }
/// <inheritdoc/> public override Boolean MatchesKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { return(key == Key && modifiers.IsEquivalentTo(Modifiers)); }
/// <summary> /// Raises the AxisDown attached event for the specified element. /// </summary> internal static void RaiseAxisDown(DependencyObject element, GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { var temp = EventManager.GetInvocationDelegate<UpfGamePadAxisDownEventHandler>(AxisDownEvent); if (temp != null) { temp(element, device, axis, value, repeat, ref data); } }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Keyboard.LostKeyboardFocus"/> /// attached event for the specified element. /// </summary> internal static void RaiseLostKeyboardFocus(DependencyObject element, KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { var evt = EventManager.GetInvocationDelegate <UpfKeyboardFocusChangedEventHandler>(LostKeyboardFocusEvent); evt?.Invoke(element, device, oldFocus, newFocus, ref data); }
/// <summary> /// Raises the <see cref="PasswordBox.PasswordChangedEvent"/> routed event against the editor's templated parent. /// </summary> private void RaisePasswordChanged(PasswordBox target) { var evtDelegate = EventManager.GetInvocationDelegate<UpfRoutedEventHandler>(PasswordBox.PasswordChangedEvent); var evtData = new RoutedEventData(target); evtDelegate(target, ref evtData); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Keyboard.PreviewTextEditing"/> /// attached event for the specified element. /// </summary> internal static void RaisePreviewTextEditing(DependencyObject element, KeyboardDevice device, ref RoutedEventData data) { var evt = EventManager.GetInvocationDelegate <UpfKeyboardEventHandler>(PreviewTextEditingEvent); evt?.Invoke(element, device, ref data); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Mouse.MouseLeave"/> /// attached event for the specified element. /// </summary> internal static void RaiseMouseLeave(DependencyObject element, MouseDevice device, RoutedEventData data) { var evt = EventManager.GetInvocationDelegate<UpfMouseEventHandler>(MouseLeaveEvent); evt?.Invoke(element, device, data); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Keyboard.PreviewKeyDown"/> /// attached event for the specified element. /// </summary> internal static void RaisePreviewKeyDown(DependencyObject element, KeyboardDevice device, Key key, Boolean ctrl, Boolean alt, Boolean shift, Boolean repeat, ref RoutedEventData data) { var evt = EventManager.GetInvocationDelegate <UpfKeyDownEventHandler>(PreviewKeyDownEvent); evt?.Invoke(element, device, key, Modifiers, ref data); }
/// <summary> /// Raises the <see cref="E:TwistedLogik.Ultraviolet.UI.Presentation.Input.Mouse.PreviewMouseWheel"/> /// attached event for the specified element. /// </summary> internal static void RaisePreviewMouseWheel(DependencyObject element, MouseDevice device, Double x, Double y, RoutedEventData data) { var evt = EventManager.GetInvocationDelegate<UpfMouseWheelEventHandler>(PreviewMouseWheelEvent); evt?.Invoke(element, device, x, y, data); }
/// <summary> /// Occurs when the user begins dragging the slider's thumb button. /// </summary> /// <param name="hoffset">The horizontal offset at which the thumb was clicked, in relative coordinates.</param> /// <param name="voffset">The vertical offset at which the thumb was clicked, in relative coordinates.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnThumbDragStarted(Double hoffset, Double voffset, RoutedEventData data) { }