Ejemplo n.º 1
0
        /// <summary>
        ///     Invoked on every keystroke, including system keys such as Alt key combinations.
        ///     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="e">Event data describing the conditions that led to the event.</param>
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            var virtualKey = e.VirtualKey;

            // Only investigate further when Left, Right, or the dedicated Previous or Next keys are pressed
            if (e.EventType != CoreAcceleratorKeyEventType.SystemKeyDown &&
                e.EventType != CoreAcceleratorKeyEventType.KeyDown ||
                virtualKey != VirtualKey.Left && virtualKey != VirtualKey.Right && (int)virtualKey != 166 &&
                (int)virtualKey != 167)
            {
                return;
            }
            var coreWindow = Window.Current.CoreWindow;
            const CoreVirtualKeyStates 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))
            {
                return;
            }
            OnBackRequested();
            e.Handled = true;
        }
Ejemplo n.º 2
0
        void OnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
        {
            if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                 args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
                (args.VirtualKey == VirtualKey.C || args.VirtualKey == VirtualKey.V))
            {
                CoreWindow           window = Window.Current.CoreWindow;
                CoreVirtualKeyStates down   = CoreVirtualKeyStates.Down;

                // Only want case where Ctrl is down
                if ((window.GetKeyState(VirtualKey.Shift) & down) == down ||
                    (window.GetKeyState(VirtualKey.Control) & down) != down ||
                    (window.GetKeyState(VirtualKey.Menu) & down) == down)
                {
                    return;
                }

                if (args.VirtualKey == VirtualKey.C)
                {
                    OnCopyAppBarButtonClick(null, null);
                }
                else if (args.VirtualKey == VirtualKey.V)
                {
                    OnPasteAppBarButtonClick(pasteAppBarButton, null);
                }
            }
        }
Ejemplo n.º 3
0
        public static void GetMetaKeyState(out bool shift, out bool ctrl, out bool alt)
        {
            GetMetaKeyState(out shift, out ctrl);
            CoreVirtualKeyStates keyState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu);

            alt = (keyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
        }
Ejemplo n.º 4
0
        /// <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="e">Event data describing the conditions that led to the event.</param>
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            VirtualKey virtualKey = e.VirtualKey;

            // Only investigate further when Left, Right, or the dedicated Previous or Next keys
            // are pressed
            if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                 e.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
                (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
                 (int)virtualKey == 166 || (int)virtualKey == 167))
            {
                CoreWindow           coreWindow = Window.Current.CoreWindow;
                CoreVirtualKeyStates 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
                    e.Handled = true;
                    GoBackCommand.Execute(null);
                }
                else if (((int)virtualKey == 167 && noModifiers) ||
                         (virtualKey == VirtualKey.Right && onlyAlt))
                {
                    // When the next key or Alt+Right are pressed navigate forward
                    e.Handled = true;
                    GoForwardCommand.Execute(null);
                }
            }
        }
Ejemplo n.º 5
0
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender,
                                                            AcceleratorKeyEventArgs args)
        {
            var virtualKey = args.VirtualKey;

            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;
                const CoreVirtualKeyStates 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))
                {
                    args.Handled = true;
                    GoBack(this, new RoutedEventArgs());
                }
                else if (((int)virtualKey == 167 && noModifiers) ||
                         (virtualKey == VirtualKey.Right && onlyAlt))
                {
                    args.Handled = true;
                    GoForward();
                }
            }
        }
Ejemplo n.º 6
0
        /// <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 CoreDispatcherAcceleratorKeyActivated(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;
                const CoreVirtualKeyStates 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;
                    GoBack(this, new RoutedEventArgs());
                }
            }
        }
Ejemplo n.º 7
0
        private void OnSplitButtonKeyUp(object sender, KeyRoutedEventArgs args)
        {
            VirtualKey key = args.Key;

            if (key == VirtualKey.Space || key == VirtualKey.Enter || key == VirtualKey.GamepadA)
            {
                m_isKeyDown = false;
                UpdateVisualStates();

                // Consider this a click on the primary button
                if (IsEnabled)
                {
                    OnClickPrimary(null, null);
                    args.Handled = true;
                }
            }
            else if (key == VirtualKey.Down)
            {
                CoreVirtualKeyStates menuState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Menu);
                bool menuKeyDown = (menuState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                if (IsEnabled && menuKeyDown)
                {
                    // Open the menu on alt-down
                    OpenFlyout();
                    args.Handled = true;
                }
            }
            else if (key == VirtualKey.F4 && IsEnabled)
            {
                // Open the menu on F4
                OpenFlyout();
                args.Handled = true;
            }
        }
Ejemplo n.º 8
0
        private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CoreVirtualKeyStates shift = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);
            bool isShift = shift.HasFlag(CoreVirtualKeyStates.Down);

            switch (args.VirtualKey)
            {
            case VirtualKey.Down:
                _playerDirection.Down = true;
                break;

            case VirtualKey.Left:
                _playerDirection.Left = true;
                break;

            case VirtualKey.Right:
                _playerDirection.Right = true;
                break;

            case VirtualKey.Up:
                _playerDirection.Up = true;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 9
0
        private void Page_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            CoreVirtualKeyStates ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control);

            if (ctrlState == CoreVirtualKeyStates.Down && e.Key == VirtualKey.S)
            {
                goalModel.SaveToXml();
            }
        }
Ejemplo n.º 10
0
        public static void GetMetaKeyState(out bool shift, out bool ctrl)
        {
            CoreVirtualKeyStates keyState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);

            ctrl = (keyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
            CoreVirtualKeyStates states2 = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);

            shift = (states2 & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
        }
        private async void TabViewContainer_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            if (!QueueContentDialog.IsRunningOrWaiting)
            {
                CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

                switch (args.VirtualKey)
                {
                case VirtualKey.W when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    if (TabViewControl.SelectedItem is TabViewItem Tab)
                    {
                        args.Handled = true;

                        await CleanUpAndRemoveTabItem(Tab);
                    }

                    return;
                }
                }

                if (CurrentNavigationControl?.Content is ThisPC PC)
                {
                    switch (args.VirtualKey)
                    {
                    case VirtualKey.T when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                    {
                        await CreateNewTabAsync();

                        args.Handled = true;

                        break;
                    }

                    case VirtualKey.Space when SettingControl.IsQuicklookEnable:
                    {
                        using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                        {
                            if (await Exclusive.Controller.CheckIfQuicklookIsAvaliableAsync())
                            {
                                if (PC.DeviceGrid.SelectedItem is DriveRelatedData Device && !string.IsNullOrEmpty(Device.Folder.Path))
                                {
                                    await Exclusive.Controller.ViewWithQuicklookAsync(Device.Folder.Path);
                                }
                                else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library && !string.IsNullOrEmpty(Library.Folder.Path))
                                {
                                    await Exclusive.Controller.ViewWithQuicklookAsync(Library.Folder.Path);
                                }
                            }
                        }

                        args.Handled = true;

                        break;
                    }
Ejemplo n.º 12
0
 private void OnPageKeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.S)
     {
         CoreVirtualKeyStates controlState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
         if (controlState.HasFlag(CoreVirtualKeyStates.Down) && ViewModel.Save.CanExecute())
         {
             ViewModel.Save.Execute();
             e.Handled = true;
         }
     }
 }
Ejemplo n.º 13
0
 private void SetCapsLock()
 {
     keystate = Window.Current.CoreWindow.GetKeyState(VirtualKey.CapitalLock);
     capsLock = (keystate & CoreVirtualKeyStates.Locked) != 0;
     if (capsLock)
     {
         mainPage.CSignetic6502.MemoryBus.Keyboard.Keystates[7] &= 0xfe;
     }
     else
     {
         mainPage.CSignetic6502.MemoryBus.Keyboard.Keystates[7] |= 0x01;
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 탭키다운
        /// </summary>
        /// <param name="focusedItem"></param>
        private void OnTabKeyDown(object focusedItem)
        {
#if NETFX_CORE
            CoreVirtualKeyStates shiftKeyState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift);
            bool shiftKeyDown = (shiftKeyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

            // If we're on the header item then this will be null and we'll still get the default behavior.
            switch (focusedItem)
            {
            case ListViewItem focusedListViewItem:
                bool onLastItem  = IndexFromContainer(focusedListViewItem) == Items.Count - 1;
                bool onFirstItem = IndexFromContainer(focusedListViewItem) == 0;
                if (!shiftKeyDown)
                {
                    //tab키를 눌렀을 때 쉬프트키를 누른 상태가 아니라면 기본적으로는 Down이고 마지막 아이템이면 Next
                    if (onLastItem)
                    {
                        TryMoveFocus(FocusNavigationDirection.Next);
                    }
                    else
                    {
                        TryMoveFocus(FocusNavigationDirection.Down);
                    }
                }
                else
                {
                    //Shift + Tab
                    if (onFirstItem)
                    {
                        TryMoveFocus(FocusNavigationDirection.Previous);
                    }
                    else
                    {
                        TryMoveFocus(FocusNavigationDirection.Up);
                    }
                }
                break;

            case Control _:
                if (!shiftKeyDown)
                {
                    TryMoveFocus(FocusNavigationDirection.Down);
                }
                else
                {
                    TryMoveFocus(FocusNavigationDirection.Up);
                }
                break;
            }
#endif
        }
Ejemplo n.º 15
0
        private void SearchPage_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            SearchCommandFlyout.Hide();

            CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

            switch (args.VirtualKey)
            {
            case VirtualKey.L when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                Location_Click(null, null);
                break;
            }
            }
        }
Ejemplo n.º 16
0
        private void OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            CoreVirtualKeyStates ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);

            if (ctrl.HasFlag(CoreVirtualKeyStates.Down))
            {
                if (e.OriginalKey == VirtualKey.S)
                {
                    ViewModel.Save.Execute(null);
                }
                else if (e.OriginalKey == VirtualKey.D)
                {
                    ViewModel.Delete.Execute(null);
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Handles setting up the caps lock key handler.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            CoreVirtualKeyStates capsState = Window.Current.CoreWindow.GetKeyState(VirtualKey.CapitalLock);

            this.capsLockEnabled = (capsState == CoreVirtualKeyStates.Locked);

            DebugHelper.Trace($"Got initial caps lock state: {this.capsLockEnabled}");
            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;

            // XXX - this works around what seems to be a Windows bug where
            // when navigating from RootView bindings are not updating.
            // Remove when able.
            this.Bindings.Update();
        }
Ejemplo n.º 18
0
        private void RecycleBin_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

            switch (args.VirtualKey)
            {
            case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                ListViewControl.SelectAll();
                break;
            }

            case VirtualKey.Delete when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                PermanentDelete_Click(null, null);
                break;
            }
            }
        }
Ejemplo n.º 19
0
        private void SecureArea_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

            switch (args.VirtualKey)
            {
            case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                SecureGridView.SelectAll();
                break;
            }

            case VirtualKey.Delete when SecureGridView.SelectedItems.Count > 0:
            case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down) && SecureGridView.SelectedItems.Count > 0:
            {
                DeleteFile_Click(null, null);
                break;
            }
            }
        }
Ejemplo n.º 20
0
        private void SearchPage_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CloseAllFlyout();

            CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

            switch (args.VirtualKey)
            {
            case VirtualKey.L when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                Location_Click(null, null);
                break;
            }

            case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                SearchResultList.SelectAll();
                break;
            }

            case VirtualKey.C when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                Copy_Click(null, null);
                break;
            }

            case VirtualKey.X when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                Cut_Click(null, null);
                break;
            }

            case VirtualKey.Delete:
            case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                Delete_Click(null, null);
                break;
            }
            }
        }
Ejemplo n.º 21
0
        internal static byte GetShiftCode(VirtualKey virtualKey, byte current, bool isDown)
        {
            byte result = 0;

            CoreVirtualKeyStates shiftState       = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Shift);
            CoreVirtualKeyStates capitalLockState = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.CapitalLock);

            bool shiftIsDown = shiftState != CoreVirtualKeyStates.None ||
                               capitalLockState != CoreVirtualKeyStates.None ||
                               virtualKey == VirtualKey.Shift ||
                               virtualKey == VirtualKey.LeftShift ||
                               virtualKey == VirtualKey.RightShift;

            if (shiftIsDown)
            {
                int  bitIndex = 1;
                byte mask     = (byte)(1 << bitIndex);
                result |= mask;
            }

            return(result);
        }
Ejemplo n.º 22
0
 private void Init()
 {
     CSignetic6502 = new CSignetic6502(mainPage);
     CClock        = new CClock(this);
     CSignetic6502.MemoryBus.VDU.InitCVDU(this, gridScreen);
     cbSelectNumberOfLines.SelectedIndex = 1;
     keystate = Window.Current.CoreWindow.GetKeyState(VirtualKey.NumberKeyLock);
     numLock  = (keystate & CoreVirtualKeyStates.Locked) != 0;
     keystate = Window.Current.CoreWindow.GetKeyState(VirtualKey.CapitalLock);
     capsLock = (keystate & CoreVirtualKeyStates.Locked) != 0;
     Midi     = new MIDI(this);
     SetPage(0);
     btnHistory.Background           = new SolidColorBrush(Color.FromArgb(255, 160, 160, 64));
     btnTheProject.Background        = new SolidColorBrush(Color.FromArgb(255, 160, 160, 160));
     btnOperation.Background         = new SolidColorBrush(Color.FromArgb(255, 160, 160, 160));
     btnManuals.Background           = new SolidColorBrush(Color.FromArgb(255, 160, 160, 160));
     btnCompukitUK101.Background     = new SolidColorBrush(Color.FromArgb(255, 160, 160, 64));
     btnCegmon.Background            = new SolidColorBrush(Color.FromArgb(255, 160, 160, 160));
     cbSelectACIAUsage.SelectedIndex = 0;
     Editor = new Editor(this);
     handleControlEvents = true;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Handles KeyDown events for the current window.
        /// </summary>
        /// <param name="sender">The CoreWindow that dispatched the event.</param>
        /// <param name="args">KeyEventArgs for the event.</param>
        private async void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CoreVirtualKeyStates ctrlState = sender.GetKeyState(VirtualKey.Control);

            if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down)
            {
                CoreVirtualKeyStates shiftState = sender.GetKeyState(VirtualKey.Shift);
                bool shiftDown = (shiftState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                // Handle accelerator (Ctrl) hotkeys
                switch (args.VirtualKey)
                {
                case VirtualKey.O:
                    if (!shiftDown)
                    {
                        // Prompt to open a file
                        args.Handled = true;
                        await PickFileForOpenAsync(
                            file =>
                        {
                            OpenFile(file);
                        }
                            );
                    }
                    break;

                default:
                    args.Handled = ((PassKeepPage)this.contentFrame.Content).HandleAcceleratorKey(args.VirtualKey, shiftDown);
                    break;
                }
            }
            else
            {
                if (args.VirtualKey == VirtualKey.Escape)
                {
                    ViewModel.TaskNotificationService.RequestCancellation();
                }
            }
        }
Ejemplo n.º 24
0
        void OnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
        {
            if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                 args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
                (args.VirtualKey == VirtualKey.Left ||
                 args.VirtualKey == VirtualKey.Right ||
                 (int)args.VirtualKey == 166 ||
                 (int)args.VirtualKey == 167))
            {
                CoreWindow           window = Window.Current.CoreWindow;
                CoreVirtualKeyStates down   = CoreVirtualKeyStates.Down;

                // Ignore key combinations where Shift or Ctrl is down
                if ((window.GetKeyState(VirtualKey.Shift) & down) == down ||
                    (window.GetKeyState(VirtualKey.Control) & down) == down)
                {
                    return;
                }

                // Get alt key state
                bool alt = (window.GetKeyState(VirtualKey.Menu) & down) == down;

                // Go back for Alt-Left key or browser left key
                if (args.VirtualKey == VirtualKey.Left && alt ||
                    (int)args.VirtualKey == 166 && !alt)
                {
                    GoBack();
                    args.Handled = true;
                }

                // Go forward for Alt-Right key or browser right key
                if (args.VirtualKey == VirtualKey.Right && alt ||
                    (int)args.VirtualKey == 167 && !alt)
                {
                    GoForward();
                    args.Handled = true;
                }
            }
        }
Ejemplo n.º 25
0
        private void RecycleBin_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            if (!LoadingControl.IsLoading)
            {
                SelectFlyout.Hide();
                EmptyFlyout.Hide();

                CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

                switch (args.VirtualKey)
                {
                case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    ListViewControl.SelectAll();
                    break;
                }

                case VirtualKey.Delete:
                case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    PermanentDelete_Click(null, null);
                    break;
                }

                case VirtualKey.R when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    RestoreRecycle_Click(null, null);
                    break;
                }

                case VirtualKey.E when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    ClearRecycleBin_Click(null, null);
                    break;
                }
                }
            }
        }
Ejemplo n.º 26
0
        public static bool IsKeyPressed(VirtualKey key)
        {
            CoreVirtualKeyStates controlKeyState = Window.Current.CoreWindow.GetKeyState(key);

            return((controlKeyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
        }
Ejemplo n.º 27
0
        private async void OnKeyboards(CoreWindow sender, KeyEventArgs args)
        {
            try
            {
                CoreVirtualKeyStates controlKeyState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
                var isCtrlDown = (controlKeyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                CoreVirtualKeyStates shiftKeyState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);
                var isShiftDown = (shiftKeyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                var ctrl  = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
                var shift = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);
                switch (args.VirtualKey)
                {
                case VirtualKey.Escape:
                    //NavigationService.GoBack();
                    break;
                }
                if (isCtrlDown && args.VirtualKey == VirtualKey.Left || args.VirtualKey == VirtualKey.Escape)
                {
                    NavigationService.GoBack();
                }

                if (isCtrlDown && args.VirtualKey == VirtualKey.V || isShiftDown && args.VirtualKey == VirtualKey.Insert)
                {
                    if (InstaApi != null && InstaApi.IsUserAuthenticated)
                    {
                        DataPackageView dataPackageView = Clipboard.GetContent();
                        if (dataPackageView.Contains(StandardDataFormats.StorageItems))
                        {
                            var items = await dataPackageView.GetStorageItemsAsync();

                            if (items.Count > 0)
                            {
                                if (items[0] is StorageFile file)
                                {
                                    if (file.Path.IsSupportedImage()) // IsSupportedVideo ?
                                    {
                                        if (NavigationService.Frame.Content is Views.Direct.ThreadView thread)
                                        {
                                            thread.UploadFile(file);
                                        }
                                        else
                                        {
                                            await new ContentDialogs.FileAssociationDialog(file).ShowAsync();
                                        }
                                    }
                                    else
                                    {
                                        ShowNotify("This file is not supported.\r\n" + file.Path, 3000);
                                    }
                                }
                            }
                        }
                        else if (dataPackageView.Contains(StandardDataFormats.Bitmap))
                        {
                            var bitmap = await dataPackageView.GetBitmapAsync();

                            var decoder = await BitmapDecoder.CreateAsync(await bitmap.OpenReadAsync());

                            var file = await GenerateRandomOutputFile();

                            var encoder = await BitmapEncoder.CreateForTranscodingAsync(await file.OpenAsync(FileAccessMode.ReadWrite), decoder);

                            await encoder.FlushAsync();

                            if (NavigationService.Frame.Content is Views.Direct.ThreadView thread)
                            {
                                thread.UploadFile(file);
                            }
                            else
                            {
                                await new ContentDialogs.FileAssociationDialog(file).ShowAsync();
                            }
                        }
                    }
                }
            }
            catch { }
        }
        public static bool IsDown(this VirtualKey key)
        {
            CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);

            return((state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
        }
        private async void TabViewContainer_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            if (!QueueContentDialog.IsRunningOrWaiting)
            {
                CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

                switch (args.VirtualKey)
                {
                case VirtualKey.W when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    if (TabViewControl.SelectedItem is TabViewItem Tab)
                    {
                        args.Handled = true;

                        await CleanUpAndRemoveTabItem(Tab).ConfigureAwait(true);
                    }

                    return;
                }
                }

                if (CurrentTabNavigation?.Content is ThisPC PC)
                {
                    switch (args.VirtualKey)
                    {
                    case VirtualKey.Space when SettingControl.IsQuicklookAvailable && SettingControl.IsQuicklookEnable:
                    {
                        if (PC.DeviceGrid.SelectedItem is HardDeviceInfo Device)
                        {
                            await FullTrustProcessController.Current.ViewWithQuicklookAsync(Device.Folder.Path).ConfigureAwait(false);
                        }
                        else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library)
                        {
                            await FullTrustProcessController.Current.ViewWithQuicklookAsync(Library.Folder.Path).ConfigureAwait(false);
                        }
                        break;
                    }

                    case VirtualKey.Enter:
                    {
                        if (PC.DeviceGrid.SelectedItem is HardDeviceInfo Device)
                        {
                            if (string.IsNullOrEmpty(Device.Folder.Path))
                            {
                                QueueContentDialog Dialog = new QueueContentDialog
                                {
                                    Title             = Globalization.GetString("Common_Dialog_TipTitle"),
                                    Content           = Globalization.GetString("QueueDialog_MTP_CouldNotAccess_Content"),
                                    PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                                    CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
                                };

                                if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
                                {
                                    await Launcher.LaunchFolderAsync(Device.Folder);
                                }
                            }
                            else
                            {
                                if (AnimationController.Current.IsEnableAnimation)
                                {
                                    CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, string>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Device.Folder.Path), new DrillInNavigationTransitionInfo());
                                }
                                else
                                {
                                    CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, string>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Device.Folder.Path), new SuppressNavigationTransitionInfo());
                                }
                            }

                            args.Handled = true;
                        }
                        else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library)
                        {
                            if (AnimationController.Current.IsEnableAnimation)
                            {
                                CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, string>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Library.Folder.Path), new DrillInNavigationTransitionInfo());
                            }
                            else
                            {
                                CurrentTabNavigation.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, string>(new WeakReference <TabViewItem>(TabViewControl.SelectedItem as TabViewItem), Library.Folder.Path), new SuppressNavigationTransitionInfo());
                            }

                            args.Handled = true;
                        }

                        break;
                    }

                    case VirtualKey.F5:
                    {
                        PC.Refresh_Click(null, null);

                        args.Handled = true;

                        break;
                    }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private static void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            const CoreVirtualKeyStates downState = CoreVirtualKeyStates.Down;
            var coreWindow  = Window.Current.CoreWindow;
            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;

            if (!noModifiers || e.EventType != CoreAcceleratorKeyEventType.KeyDown ||
                (e.VirtualKey != VirtualKey.Enter && e.VirtualKey != VirtualKey.Escape))
            {
                return;
            }
            var frame = Window.Current.Content as Frame;

            if (frame == null)
            {
                return;
            }

            var currentPage = frame.Content as Page;

            if (currentPage == null)
            {
                return;
            }

            if (e.VirtualKey == VirtualKey.Enter)
            {
                // Quick check to avoid TextBox with ENTER support
                var tb = FocusManager.GetFocusedElement() as TextBox;
                if (tb != null && tb.AcceptsReturn)
                {
                    return;
                }

                var defaultButton = currentPage.GetValue(DefaultButtonProperty) as Button;
                if (defaultButton == null || !defaultButton.IsEnabled)
                {
                    return;
                }
                var peer       = new ButtonAutomationPeer(defaultButton);
                var invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                if (invokeProv != null)
                {
                    invokeProv.Invoke();
                }
            }
            else
            {
                var cancelButton = currentPage.GetValue(CancelButtonProperty) as Button;
                if (cancelButton == null || !cancelButton.IsEnabled)
                {
                    return;
                }
                var peer       = new ButtonAutomationPeer(cancelButton);
                var invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                if (invokeProv != null)
                {
                    invokeProv.Invoke();
                }
            }
        }