當前位置: 首頁>>代碼示例>>C#>>正文


C# Core.AcceleratorKeyEventArgs類代碼示例

本文整理匯總了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());
                }
            }
        }
開發者ID:stevehansen,項目名稱:vidyano_v1,代碼行數:37,代碼來源:LayoutAwarePage.cs

示例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;
        }
開發者ID:joshberry,項目名稱:Template10,代碼行數:35,代碼來源:KeyboardHelper.cs

示例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);
                }
            }
        }
開發者ID:ZedTheYeti,項目名稱:Hangups-UWP,代碼行數:35,代碼來源:KeyboardService.cs

示例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;
                }
            }
        }
開發者ID:haroldma,項目名稱:Audiotica,代碼行數:27,代碼來源:KeyboardHelper.cs

示例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();
                    }
                }
            }
        }
開發者ID:ryanhorath,項目名稱:Rybird.Framework,代碼行數:37,代碼來源:WindowsruntimePage.cs

示例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();
     }
 }
開發者ID:stephgou,項目名稱:Thot,代碼行數:8,代碼來源:SearchPage.xaml.cs

示例7: CoreDispatcher_AcceleratorKeyActivated

 private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
 {
     if (args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown
         || args.EventType == CoreAcceleratorKeyEventType.KeyDown)
     {
         HandleKeyDown(args);
     }
 }
開發者ID:joshberry,項目名稱:Template10,代碼行數:8,代碼來源:KeyboardHelper.cs

示例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;
                }
            }
開發者ID:fstn,項目名稱:WindowsPhoneApps,代碼行數:11,代碼來源:PageUtilities.cs

示例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);
            }
        }
開發者ID:hungdluit,項目名稱:ChatterBox,代碼行數:12,代碼來源:ReturnKeyCommandBehavior.cs

示例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;
                }
            }
        }
開發者ID:Rasetech,項目名稱:Template10,代碼行數:14,代碼來源:KeyboardHelper.cs

示例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();
                }
            }
        }
開發者ID:joshberry,項目名稱:Template10,代碼行數:49,代碼來源:KeyboardHelper.cs

示例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);
         }
     }
 }
開發者ID:Anarh2404,項目名稱:TechNews,代碼行數:41,代碼來源:Shell.xaml.cs

示例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();
                }
            }
        }
開發者ID:mbin,項目名稱:Win81App,代碼行數:29,代碼來源:SettingsFlyout1.xaml.cs

示例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);
                }
            }
        }
開發者ID:vulcanlee,項目名稱:Windows8Lab,代碼行數:43,代碼來源:NavigationHelper.cs

示例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;
     }
 }
開發者ID:startewho,項目名稱:CnBetaUWA,代碼行數:9,代碼來源:MasterDetailView.cs


注:本文中的Windows.UI.Core.AcceleratorKeyEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。