本文整理汇总了C#中Windows.UI.Core.AcceleratorKeyEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# AcceleratorKeyEventArgs类的具体用法?C# AcceleratorKeyEventArgs怎么用?C# AcceleratorKeyEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AcceleratorKeyEventArgs类属于Windows.UI.Core命名空间,在下文中一共展示了AcceleratorKeyEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CoreDispatcher_AcceleratorKeyActivated
/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard navigation
/// between pages even when the page itself doesn't have focus.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
var virtualKey = args.VirtualKey;
// Only investigate further when Left, Right, or the dedicated Previous or Next keys are pressed
if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
(virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167))
{
var coreWindow = Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
var menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
var controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
var shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
var noModifiers = !menuKey && !controlKey && !shiftKey;
var onlyAlt = menuKey && !controlKey && !shiftKey;
if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt))
{
// When the previous key or Alt+Left are pressed navigate back
args.Handled = true;
GoBack(this, new RoutedEventArgs());
}
else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt))
{
// When the next key or Alt+Right are pressed navigate forward
args.Handled = true;
GoForward(this, new RoutedEventArgs());
}
}
}
示例2: HandleKeyDown
private void HandleKeyDown(AcceleratorKeyEventArgs args)
{
var alt = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var shift = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var control = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var windows = ((Window.Current.CoreWindow.GetKeyState(VirtualKey.LeftWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) || ((Window.Current.CoreWindow.GetKeyState(VirtualKey.RightWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
var character = ToChar(args.VirtualKey, shift);
System.Diagnostics.Debug.WriteLine("{0} alt:{1} shift:{2} control:{3} windows:{4} virt:{5}", character, alt, shift, control, windows, args.VirtualKey);
var keyDown = new KeyboardEventArgs
{
AltKey = alt,
Character = character,
ControlKey = control,
EventArgs = args,
ShiftKey = shift,
VirtualKey = args.VirtualKey
};
try { KeyDown?.Invoke(keyDown); } catch { }
if (windows && (character == 'z' || character == 'Z'))
{
RaiseWindowZGestured();
}
else if (args.KeyStatus.IsExtendedKey && args.VirtualKey == VirtualKey.Back)
{
RaiseGoBackGestured();
}
else
{
return;
}
args.Handled = true;
}
示例3: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
{
if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
e.EventType == CoreAcceleratorKeyEventType.KeyDown))
{
var coreWindow = Windows.UI.Xaml.Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
var virtualKey = e.VirtualKey;
bool winKey = ((coreWindow.GetKeyState(VirtualKey.LeftWindows) & downState) == downState || (coreWindow.GetKeyState(VirtualKey.RightWindows) & downState) == downState);
bool altKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
// raise keydown actions
var keyDown = new KeyboardEventArgs
{
AltKey = altKey,
Character = ToChar(virtualKey, shiftKey),
ControlKey = controlKey,
EventArgs = e,
ShiftKey = shiftKey,
VirtualKey = virtualKey
};
try { _KeyDown?.Raise(this, keyDown); }
catch { }
// Handle F5 to refresh content
if (virtualKey == VirtualKey.F5)
{
bool noModifiers = !altKey && !controlKey && !shiftKey;
_RefreshRequest?.Raise(this, keyDown);
}
}
}
示例4: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if (args.EventType.ToString().Contains("Down") && !args.Handled)
{
var alt = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var shift = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var control = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var windows = ((Window.Current.CoreWindow.GetKeyState(VirtualKey.LeftWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) || ((Window.Current.CoreWindow.GetKeyState(VirtualKey.RightWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
var character = ToChar(args.VirtualKey, shift);
var keyDown = new KeyboardEventArgs
{
AltKey = alt,
Character = character,
ControlKey = control,
EventArgs = args,
ShiftKey = shift,
VirtualKey = args.VirtualKey
};
try { KeyDown?.Invoke(keyDown); }
finally
{
args.Handled = keyDown.Handled;
}
}
}
示例5: CoreDispatcher_AcceleratorKeyActivated
/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard navigation
/// between pages even when the page itself doesn't have focus.
/// </summary>
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
var virtualKey = args.VirtualKey;
// Only investigate further when Left, Right, or the dedicated Previous or Next keys
// are pressed
if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
(virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
(int)virtualKey == 166 || (int)virtualKey == 167))
{
var coreWindow = Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
bool noModifiers = !menuKey && !controlKey && !shiftKey;
bool onlyAlt = menuKey && !controlKey && !shiftKey;
if (((int)virtualKey == 166 && noModifiers) ||
(virtualKey == VirtualKey.Left && onlyAlt))
{
// When the previous key or Alt+Left are pressed navigate back
args.Handled = true;
var vm = DataContext as FrameworkPageViewModel;
if (vm != null)
{
vm.NavigateBack();
}
}
}
}
示例6: OnAcceleratorKeyActivated
private void OnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
// Ensures the ENTER key always runs the same code as your default button.
if (args.EventType == CoreAcceleratorKeyEventType.KeyDown && args.VirtualKey == VirtualKey.Enter)
{
_searchViewModel.LaunchSearch();
}
}
示例7: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if (args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown
|| args.EventType == CoreAcceleratorKeyEventType.KeyDown)
{
HandleKeyDown(args);
}
}
示例8: AcceleratorKeyActivated
public void AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if (args.VirtualKey == VirtualKey.Control)
ctrlDown = args.EventType == CoreAcceleratorKeyEventType.KeyDown;
if (args.VirtualKey == VirtualKey.F3 || (args.VirtualKey == VirtualKey.F && ctrlDown))
{
searchKeyPressed();
args.Handled = true;
}
}
示例9: Dispatcher_AcceleratorKeyActivated
private static void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if (!_isEnterPressed) return;
if (_command == null) return;
if (args.VirtualKey != VirtualKey.Enter) return;
if (args.EventType == CoreAcceleratorKeyEventType.KeyDown)
{
args.Handled = true;
_command?.Execute(null);
}
}
示例10: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
{
if (e.EventType.ToString().Contains("Down") && !e.Handled)
{
var args = KeyboardEventArgs(e.VirtualKey);
args.EventArgs = e;
try { KeyDown?.Invoke(args); }
finally
{
e.Handled = e.Handled;
}
}
}
示例11: zCoreDispatcher_AcceleratorKeyActivated
private void zCoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
{
if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
e.EventType == CoreAcceleratorKeyEventType.KeyDown))
{
var coreWindow = Windows.UI.Xaml.Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
var virtualKey = e.VirtualKey;
bool winKey = ((coreWindow.GetKeyState(VirtualKey.LeftWindows) & downState) == downState || (coreWindow.GetKeyState(VirtualKey.RightWindows) & downState) == downState);
bool altKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
bool noModifiers = !altKey && !controlKey && !shiftKey;
bool onlyAlt = altKey && !controlKey && !shiftKey;
// raise keydown actions
var keyDown = new KeyboardEventArgs
{
AltKey = altKey,
Character = ToChar(virtualKey, shiftKey),
ControlKey = controlKey,
EventArgs = e,
ShiftKey = shiftKey,
VirtualKey = virtualKey
};
try { KeyDown?.Invoke(keyDown); }
catch { }
if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt))
{
// When the previous key or Alt+Left are pressed navigate back
e.Handled = true;
RaiseGoBackGestured();
}
else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt))
{
// When the next key or Alt+Right are pressed navigate forward
e.Handled = true;
RaiseGoForwardGestured();
}
else if (((int)virtualKey == 69 && controlKey))
{
// when control-E
e.Handled = true;
RaiseControlEGestured();
}
}
}
示例12: OnAcceleratorKeyActivated
private void OnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if ((args.EventType == CoreAcceleratorKeyEventType.KeyDown) ||
args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown)
{
if (args.VirtualKey == VirtualKey.Right)
{
if (FeedListView.Items != null && FeedListView.SelectedIndex < FeedListView.Items.Count)
{
FeedListView.SelectedIndex++;
if (FeedListView.Items.Count > FeedListView.SelectedIndex + ScrollOffset)
{
FeedListView.ScrollIntoView(FeedListView.Items[FeedListView.SelectedIndex + ScrollOffset]);
}
else
{
FeedListView.ScrollIntoView(FeedListView.Items.Count - 1);
}
}
}
if (args.VirtualKey == VirtualKey.Left)
{
if (FeedListView.SelectedIndex > 0)
{
FeedListView.SelectedIndex--;
if (FeedListView.SelectedIndex - ScrollOffset > 0)
{
FeedListView.ScrollIntoView(FeedListView.Items[FeedListView.SelectedIndex - ScrollOffset]);
}
else
{
FeedListView.ScrollIntoView(FeedListView.Items[0]);
}
}
}
if (args.VirtualKey == VirtualKey.F5)
{
Vm.MasterDetailViewModel.LoadNewFeedsCommand.Execute(null);
}
}
}
示例13: SettingsFlyout1_AcceleratorKeyActivated
/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard back
/// navigation via Alt+Left key combination.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
void SettingsFlyout1_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
// Only investigate further when Left is pressed
if (args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown &&
args.VirtualKey == VirtualKey.Left)
{
var coreWindow = Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
// Check for modifier keys
// The Menu VirtualKey signifies Alt
bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
if (menuKey && !controlKey && !shiftKey)
{
args.Handled = true;
this.Hide();
}
}
}
示例14: CoreDispatcher_AcceleratorKeyActivated
/// <summary>
/// 當這個頁面作用中且佔用整個視窗時,在按下每個按鍵時叫用,
/// 包括如 Alt 鍵組合等系統按鍵。用來偵測頁面之間的鍵盤巡覽,
/// 即使頁面本身沒有焦點。
/// </summary>
/// <param name="sender">觸發事件的執行個體。</param>
/// <param name="e">描述造成事件之狀況的事件資料。</param>
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender,
AcceleratorKeyEventArgs e)
{
var virtualKey = e.VirtualKey;
// 只在按下左、右或專用的 [上一頁] 或 [下一頁] 按鍵時才
// 進一步調查
if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
e.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
(virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
(int)virtualKey == 166 || (int)virtualKey == 167))
{
var coreWindow = Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
bool noModifiers = !menuKey && !controlKey && !shiftKey;
bool onlyAlt = menuKey && !controlKey && !shiftKey;
if (((int)virtualKey == 166 && noModifiers) ||
(virtualKey == VirtualKey.Left && onlyAlt))
{
// 按下上一頁按鍵或 Alt+Left 時,向後巡覽
e.Handled = true;
this.GoBackCommand.Execute(null);
}
else if (((int)virtualKey == 167 && noModifiers) ||
(virtualKey == VirtualKey.Right && onlyAlt))
{
// 按下下一頁按鍵或 Alt+Right 時,向前巡覽
e.Handled = true;
this.GoForwardCommand.Execute(null);
}
}
}
示例15: OnAcceleratorKeyActivated
private void OnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || args.EventType == CoreAcceleratorKeyEventType.KeyDown) && (args.VirtualKey == VirtualKey.Escape))
{
if (!DetailFrame.CanGoBack || CurrentState != MasterDetailState.Narrow) return;
DetailFrame.GoBack();
args.Handled = true;
}
}