public static System.VirtualKey GetLogicalKey(FlowDirection flowDirection, System.VirtualKey originalKey) { System.VirtualKey result = originalKey; if (flowDirection == FlowDirection.RightToLeft) { switch (originalKey) { case System.VirtualKey.Left: result = System.VirtualKey.Right; break; case System.VirtualKey.Right: result = System.VirtualKey.Left; break; } } return(result); }
protected override void OnKeyDown(KeyRoutedEventArgs e) #endif { base.OnKeyDown(e); if (e.Handled || !IsEnabled) { return; } // Some keys (e.g. Left/Right) need to be translated in RightToLeft mode #if WORKINPROGRESS #if MIGRATION Key invariantKey = InteractionHelper.GetLogicalKey(FlowDirection, e.Key); #else System.VirtualKey invariantKey = InteractionHelper.GetLogicalKey(FlowDirection, e.Key); #endif #else #if MIGRATION Key invariantKey = InteractionHelper.GetLogicalKey(FlowDirection.LeftToRight, e.Key); #else System.VirtualKey invariantKey = InteractionHelper.GetLogicalKey(FlowDirection.LeftToRight, e.Key); #endif #endif bool isExpanded = IsExpanded; switch (ExpandDirection) { case ExpandDirection.Down: #if MIGRATION if ((isExpanded && invariantKey == Key.Up) || (!isExpanded && invariantKey == Key.Down)) #else if ((isExpanded && invariantKey == System.VirtualKey.Up) || (!isExpanded && invariantKey == System.VirtualKey.Down)) #endif { IsExpanded = !isExpanded; } break; case ExpandDirection.Up: #if MIGRATION if ((isExpanded && invariantKey == Key.Down) || (!isExpanded && invariantKey == Key.Up)) #else if ((isExpanded && invariantKey == System.VirtualKey.Down) || (!isExpanded && invariantKey == System.VirtualKey.Up)) #endif { IsExpanded = !isExpanded; } break; case ExpandDirection.Left: #if MIGRATION if ((isExpanded && invariantKey == Key.Right) || (!isExpanded && invariantKey == Key.Left)) #else if ((isExpanded && invariantKey == System.VirtualKey.Right) || (!isExpanded && invariantKey == System.VirtualKey.Left)) #endif { IsExpanded = !isExpanded; } break; case ExpandDirection.Right: #if MIGRATION if ((isExpanded && invariantKey == Key.Left) || (!isExpanded && invariantKey == Key.Right)) #else if ((isExpanded && invariantKey == System.VirtualKey.Left) || (!isExpanded && invariantKey == System.VirtualKey.Right)) #endif { IsExpanded = !isExpanded; } break; } }
public CoreVirtualKeyStates GetKeyState(System.VirtualKey virtualKey) => CoreVirtualKeyStates.None;