/// <summary> /// Handles <see cref="GamePad.AxisDownEvent"/> when the drop down is open. /// </summary> private void OnGamePadAxisDown_DropDownOpen(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: MoveItemFocus(-1); break; case GamePadJoystickDirection.Down: MoveItemFocus(1); break; case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } break; } data.Handled = true; } } }
/// <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); }
/// <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.Left: DecreaseSmall(); data.Handled = true; break; case GamePadJoystickDirection.Right: IncreaseSmall(); data.Handled = true; break; } } base.OnGamePadAxisDown(device, axis, value, repeat, ref data); }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation && (axis == GamePad.DirectionalNavigationAxisX || axis == GamePad.DirectionalNavigationAxisY)) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Up: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up); } break; case GamePadJoystickDirection.Down: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down); } break; } data.Handled = true; } base.OnGamePadAxisDown(device, axis, value, repeat, ref data); }
/// <summary> /// Handles <see cref="GamePad.AxisDownEvent"/> when the drop down is closed. /// </summary> private void OnGamePadAxisDown_DropDownClosed(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: case GamePadJoystickDirection.Left: MoveItemSelection(-1); break; case GamePadJoystickDirection.Down: case GamePadJoystickDirection.Right: MoveItemSelection(1); break; } data.Handled = true; } } }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation && (axis == GamePad.DirectionalNavigationAxisX || axis == GamePad.DirectionalNavigationAxisY)) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, data); } break; case GamePadJoystickDirection.Up: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up); } break; case GamePadJoystickDirection.Down: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down); } break; } data.Handled = true; } base.OnGamePadAxisDown(device, axis, value, repeat, data); }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { var templatedParent = TemplatedParent as Control; if (templatedParent == null || !templatedParent.HandlesScrolling) { if (GamePad.UseAxisForDirectionalNavigation) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: HandleKeyScrolling(Key.Up, ModifierKeys.None, ref data); break; case GamePadJoystickDirection.Down: HandleKeyScrolling(Key.Down, ModifierKeys.None, ref data); break; case GamePadJoystickDirection.Left: HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); break; case GamePadJoystickDirection.Right: HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); break; } data.Handled = true; } } base.OnGamePadAxisDown(device, axis, value, repeat, ref data); }
/// <summary> /// Attempts to perform navigation as a result of the specified game pad axis press. /// </summary> /// <param name="view">The view for which to perform navigation.</param> /// <param name="device">The game pad device that raised the button press event.</param> /// <param name="axis">The axis that was pressed.</param> /// <returns><c>true</c> if navigation was performed; otherwise, <c>false</c>.</returns> public static Boolean PerformNavigation(PresentationFoundationView view, GamePadDevice device, GamePadAxis axis) { Contract.Require(view, "view"); if (GamePad.UseAxisForDirectionalNavigation) { var element = (view.ElementWithFocus ?? view.LayoutRoot) as UIElement; if (element == null) return false; if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); var succeeded = false; if ((direction & GamePadJoystickDirection.Up) == GamePadJoystickDirection.Up) succeeded = succeeded || PerformNavigation(view, element, FocusNavigationDirection.Up, false); if ((direction & GamePadJoystickDirection.Down) == GamePadJoystickDirection.Down) succeeded = succeeded || PerformNavigation(view, element, FocusNavigationDirection.Down, false); if ((direction & GamePadJoystickDirection.Left) == GamePadJoystickDirection.Left) succeeded = succeeded || PerformNavigation(view, element, FocusNavigationDirection.Left, false); if ((direction & GamePadJoystickDirection.Right) == GamePadJoystickDirection.Right) succeeded = succeeded || PerformNavigation(view, element, FocusNavigationDirection.Right, false); } } return false; }
/// <summary> /// Handles <see cref="GamePad.AxisDownEvent"/> when the drop down is closed. /// </summary> private void OnGamePadAxisDown_DropDownClosed(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: case GamePadJoystickDirection.Left: MoveItemSelection(-1); break; case GamePadJoystickDirection.Down: case GamePadJoystickDirection.Right: MoveItemSelection(1); break; } data.Handled = true; } } }
/// <summary> /// Handles <see cref="GamePad.AxisDownEvent"/> when the drop down is open. /// </summary> private void OnGamePadAxisDown_DropDownOpen(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: MoveItemFocus(-1); break; case GamePadJoystickDirection.Down: MoveItemFocus(1); break; case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, data); } break; } data.Handled = true; } } }