Beispiel #1
0
 // Public Methods (1)
 public Boolean Equals(Shortcut shortcut)
 {
     if (PlatformKey != None && shortcut.PlatformKey != None)
     {
         return (shortcut.PlatformKey == PlatformKey && shortcut.Modifiers.Equals(Modifiers));
     }
     return (shortcut.ShortcutKey.Equals(ShortcutKey) && shortcut.Modifiers.Equals(Modifiers));
 }
        void _keyCommandHandler_KeyIsReleased(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Find parent of the control sending this keypress to see if it is part of this views context.
            RescaleUIPopupContents popupContext = UIElementExtensions.GetUIParentOfType<RescaleUIPopupContents>(e.keyEventArgs.OriginalSource as UIElement);

            //If not null, then we are in the search context
            if(popupContext != null && e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.IncreaseInterfaceSize))
                {
                    if(SpeakPercentage != null)
                    {
                        SpeakPercentage(this, new EventArgs());
                    }
                    e.SubViewHandled = true;
                }
                if(keysPressed.Equals(Shortcuts.DecreaseInterfaceSize))
                {
                    if(SpeakPercentage != null)
                    {
                        SpeakPercentage(this, new EventArgs());
                    }
                    e.SubViewHandled = true;
                }
            }
        }
        // Private Methods (20)
        private void _keyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Panel Specific Shortcuts

            //Find parent of the control sending this keypress to see if it is part of this views context.
            RescaleUIPopupContents popupContext = UIElementExtensions.GetUIParentOfType<RescaleUIPopupContents>(e.keyEventArgs.OriginalSource as UIElement);

            //If not null, then we are in the search context
            if(popupContext != null && e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.ClosePanel))
                {
                    closePopupButton_Click(sender, new RoutedEventArgs());
                    e.SubViewHandled = true;
                }
                else if(keysPressed.Equals(Shortcuts.IncreaseInterfaceSize))
                {
                    increaseSizeButton.Focus();
                }
                else if(keysPressed.Equals(Shortcuts.DecreaseInterfaceSize))
                {
                    decreaseSizeButton.Focus();
                }
                else if(keysPressed.Equals(Shortcuts.ToggleSelfVoicing) || keysPressed.Equals(Shortcuts.StopSelfVoice) || keysPressed.Equals(Shortcuts.SpeakHelpText))
                {
                    //let shortcuts can are not application panel related through?
                }
                else
                {
                    //Treat this popup as if the application doesn't exist below, so block all other shortcuts
                    e.SubViewHandled = true;
                }
            }
        }
Beispiel #4
0
        //private void increaseStorage_Click(object sender, RoutedEventArgs e)
        //{
        //    try
        //    {
        //        using (var store = IsolatedStorageFile.GetUserStoreForApplication())
        //        {
        //            if(store.IncreaseQuotaTo(900000000)) //900MB
        //            {
        //                increaseStorage.Visibility = Visibility.Collapsed;
        //            }
        //        }
        //    }
        //    catch
        //    {
        //    }
        //}
        /// <summary>
        /// Handle Player Key Commands
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void KeyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Universal Application Shortcuts

            if(e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.OpenBookDialog))
                {
                    //Call dispatcher to run this code in the main UI thread, queues the code until the main thread is non-blocking,
                    //and prevents multiple keydown events from crashing IE by attempting to open multiple dialogs
                    if(openBookButton.Visibility == Visibility.Visible)
                    {
                        Dispatcher.BeginInvoke(
                            () => { openBookButton_Click(new object(), new RoutedEventArgs()); });
                    }
                }

                //if (keysPressed.Equals(Shortcuts.AddBookmark))
                //{
                //}
                if(keysPressed.Equals(Shortcuts.HelpPanel))
                {
                    showHelpSettingsButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.BookInformationPanel))
                {
                    //open/close the book information panel
                    if(NavigationViewFocusChanged != null)
                    {
                        NavigationViewFocusChanged(new object(), new PanelFocusedItemEventArgs((int)NavigationState.Focus.BookInformation));
                    }
                    showNavPanelButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.ContentsPanel))
                {
                    //open/close the table of contents panel
                    if(NavigationViewFocusChanged != null)
                    {
                        NavigationViewFocusChanged(new object(), new PanelFocusedItemEventArgs((int)NavigationState.Focus.Contents));
                    }
                    showNavPanelButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.BookmarkPanel))
                {
                    //open/close the bookmark panel
                    if(NavigationViewFocusChanged != null)
                    {
                        NavigationViewFocusChanged(new object(), new PanelFocusedItemEventArgs((int)NavigationState.Focus.Bookmarks));
                    }
                    showNavPanelButton_Click(new object(), new RoutedEventArgs());
                }

                if(keysPressed.Equals(Shortcuts.DisplaySettingsPanel))
                {
                    if(DisplaySettingsFocusChanged != null)
                    {
                        DisplaySettingsFocusChanged(new object(), new PanelFocusedItemEventArgs((int)DisplaySettingsState.Focus.ChangeSize));
                    }
                    //open/close the display settings panel
                    showDisplaySettingsButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.Contrast))
                {
                    if(DisplaySettingsFocusChanged != null)
                    {
                        DisplaySettingsFocusChanged(new object(), new PanelFocusedItemEventArgs((int)DisplaySettingsState.Focus.Contrast));
                    }
                    //open/close the display settings panel
                    showDisplaySettingsButton_Click(new object(), new RoutedEventArgs());
                }

                if(keysPressed.Equals(Shortcuts.FindPanelPage))
                {
                    if(SearchViewFocusChanged != null)
                    {
                        SearchViewFocusChanged(new object(), new PanelFocusedItemEventArgs(SearchState.FocusGoToPage));
                    }
                    showSearchPanelButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.FindPanelSearch))
                {
                    if(SearchViewFocusChanged != null)
                    {
                        SearchViewFocusChanged(new object(), new PanelFocusedItemEventArgs(SearchState.FocusFindText));
                    }
                    showSearchPanelButton_Click(new object(), new RoutedEventArgs());
                }

                if(keysPressed.Equals(Shortcuts.ClosePanel))
                {
                    //close currently open panel
                    hidePanelButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.SpeakHelpText))
                {
                    e.keyEventArgs.Handled = true; //Prevents text boxes from typing this shortcut
                    //DependencyObject focusedElement = FocusManager.GetFocusedElement() as DependencyObject;
                    SpeakableElementSelectedHelpText(new object(), new ElementSelectedEventArgs(e.keyEventArgs.OriginalSource as DependencyObject));
                }

                if(keysPressed.Equals(Shortcuts.IncreaseInterfaceSize))
                {
                    if(rescaleUIPopupContents != null)
                    {
                        rescaleUIPopupContents.IncreaseSize();
                    }
                    if(!changeSizePopup.IsOpen)
                    {
                        ShowRescalePopup();
                    }
                }

                if(keysPressed.Equals(Shortcuts.DecreaseInterfaceSize))
                {
                    if(rescaleUIPopupContents != null)
                    {
                        rescaleUIPopupContents.DecreaseSize();
                    }
                    if(!changeSizePopup.IsOpen)
                    {
                        ShowRescalePopup();
                    }
                }
            }
        }
        // Private Methods (22)
        /// <summary>
        /// Raised by the keyboard command handler in response to a keypress to disambiguate the command.
        /// </summary>
        void _keyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Panel Specific Shortcuts

            //Find parent of the control sending this keypress to see if it is part of this views context.
            Search searchContext = UIElementExtensions.GetUIParentOfType<Search>(e.keyEventArgs.OriginalSource as UIElement);

            //If not null, then we are in the search context
            if(searchContext != null && e.SubViewHandled == false)
            {
                //Block key presses on textboxes in this view from triggering key shortcuts
                if(e.keyEventArgs.OriginalSource == searchTextBox && !keysPressed.Equals(Shortcuts.SpeakHelpText) && !keysPressed.Equals(Shortcuts.ClosePanel))
                {
                    e.SubViewHandled = true;
                    return;
                }

                //Block up, down, left, right when inside the listboxes on this view
                if(e.keyEventArgs.OriginalSource.ToString() == KeyCommandHandler.ListBoxItem)
                {
                    if(keysPressed.Equals(Shortcuts.PreviousHeader) || keysPressed.Equals(Shortcuts.NextHeader) || keysPressed.Equals(Shortcuts.PreviousSection) ||
                        keysPressed.Equals(Shortcuts.NextSection))
                    {
                        e.SubViewHandled = true;
                    }
                }

                //Page and Find shortcuts should just switch between those two textboxes?
                if(keysPressed.Equals(Shortcuts.FindPanelPage))
                {
                    pageNumTextBox.Focus();
                    e.SubViewHandled = true;
                }
                if(keysPressed.Equals(Shortcuts.FindPanelSearch))
                {
                    searchTextBox.Focus();
                    e.SubViewHandled = true;
                }

                //Enter key for executing page navigation and search is handled in their respective text box keydown events
            }
        }
        // Private Methods (19)
        /// <summary>
        /// Raised when a key is pressed while this panel (or one of its child controls) has focus.
        /// </summary>
        void _keyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Panel Specific Shortcuts

            //Find parent of the control sending this keypress to see if it is part of this views context.
            DisplaySettings displayContext = UIElementExtensions.GetUIParentOfType<DisplaySettings>(e.keyEventArgs.OriginalSource as UIElement);

            //If not null, then we are in the display settings context
            if(displayContext != null && e.SubViewHandled == false)
            {
                //Block up, down, left, right when inside the listboxes on this view
                if (e.keyEventArgs.OriginalSource.ToString() == KeyCommandHandler.ListBoxItem)
                {
                    if (keysPressed.Equals(Shortcuts.PreviousHeader) || keysPressed.Equals(Shortcuts.NextHeader) || keysPressed.Equals(Shortcuts.PreviousSection) ||
                        keysPressed.Equals(Shortcuts.NextSection))
                    {
                        e.SubViewHandled = true;
                    }
                }

                //Tell main not to navigate on Up,Down,Left,Right for the slider control
                if(e.keyEventArgs.OriginalSource.ToString() == KeyCommandHandler.SliderControl)
                {
                    if(keysPressed.Equals(Shortcuts.PreviousHeader) || keysPressed.Equals(Shortcuts.NextHeader) || keysPressed.Equals(Shortcuts.PreviousSection) ||
                        keysPressed.Equals(Shortcuts.NextSection))
                    {
                        e.SubViewHandled = true;
                    }
                }

                if (keysPressed.Equals(Shortcuts.DisplaySettingsPanel))
                {
                    if (FocusManager.GetFocusedElement() != changeSizeButton)
                    {
                        changeSizeButton.Focus();
                        e.SubViewHandled = true;
                    }
                }
                if (keysPressed.Equals(Shortcuts.Contrast))
                {
                    if (UIElementExtensions.GetUIParentOfType<MediaListBox>(FocusManager.GetFocusedElement() as UIElement) != contrastSchemeSelector)
                    {
                        contrastSchemeSelector.Focus();
                        e.SubViewHandled = true;
                    }
                }
            }
        }
Beispiel #7
0
        void KeyCommandHandler_KeyIsReleased(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            if(e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.IncreaseVolume))
                {
                    SpeakVolume();
                }
                if(keysPressed.Equals(Shortcuts.DecreaseVolume))
                {
                    SpeakVolume();
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Handle Player Key Commands
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void KeyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Universal Player Shortcuts

            if(e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.PlayPause))
                {
                    // Play/Pause the book reader
                    playPauseButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.PreviousHeader))
                {
                    // go to previous header
                    PrevSectionButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.NextHeader))
                {
                    // go to next header
                    NextSectionButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.PreviousSection))
                {
                    // go to previous section
                    PrevSentenceButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.NextSection))
                {
                    // go to next section
                    NextSentenceButton_Click(new object(), new RoutedEventArgs());
                }
                if(keysPressed.Equals(Shortcuts.PreviousPage))
                {
                    // go to previous page
                    if(PreviousPage != null)
                    {
                        PreviousPage(this, new EventArgs());
                        if(SectionChanged != null)
                        {
                            SectionChanged(this, new EventArgs());
                        }
                    }
                }
                if(keysPressed.Equals(Shortcuts.NextPage))
                {
                    // go to next page
                    if(NextPage != null)
                    {
                        NextPage(this, new EventArgs());
                        if(SectionChanged != null)
                        {
                            SectionChanged(this, new EventArgs());
                        }
                    }
                }
                if(keysPressed.Equals(Shortcuts.IncreaseVolume))
                {
                    // increase volume
                    if(VolumeSlider.Value < VolumeSlider.Maximum)
                    {
                        ChangeVolume(VolumeSlider.Value += 1);
                    }
                }
                if(keysPressed.Equals(Shortcuts.DecreaseVolume))
                {
                    // decrease volume
                    if(VolumeSlider.Value > VolumeSlider.Minimum)
                    {
                        ChangeVolume(VolumeSlider.Value -= 1);
                    }
                }
                if(keysPressed.Equals(Shortcuts.MuteUnmute))
                {
                    // mute/unmute volume
                    ToggleMute();
                }

                if(keysPressed.Equals(Shortcuts.ToggleSelfVoicing))
                {
                    if(ToggleSelfVoicing != null)
                    {
                        ToggleSelfVoicing(new object(), new EventArgs());
                    }
                }
                if(keysPressed.Equals(Shortcuts.StopSelfVoice))
                {
                    //TODO: Shift this _all_ to playerpresenter and playerstate
                    StopSelfVoiceSpeaking();
                }

                //These shortcuts are not for the demo, increase and decrease SAPI voice rate
                //TODO: Comment these out!!
                //if (keysPressed.Equals(Shortcuts.DecreaseRate))
                //{
                //    if (Rate > -10)
                //    {
                //        ChangeRate(Rate -= 1);
                //        if (Rate == -10)
                //            SelfVoicingSpeakText(new object(), new SpeechTextEventArgs("Slowest."));
                //        else
                //            SelfVoicingSpeakText(new object(), new SpeechTextEventArgs("Slower."));

                //    }
                //}
                //if (keysPressed.Equals(Shortcuts.IncreaseRate))
                //{
                //    if (Rate < 10)
                //    {
                //        ChangeRate(Rate += 1);
                //        if (Rate == 10)
                //            SelfVoicingSpeakText(new object(), new SpeechTextEventArgs("Fastest."));
                //        else
                //            SelfVoicingSpeakText(new object(), new SpeechTextEventArgs("Faster."));
                //    }
                //}
            }
        }
        // Private Methods (14)
        void _keyCommandHandler_KeyIsPressed(object sender, KeyCommandEventArgs e)
        {
            Shortcut keysPressed = new Shortcut(e.keyEventArgs.PlatformKeyCode, e.keyEventArgs.Key, Keyboard.Modifiers);

            //Universal Shortcuts

            //Single key shortcuts
            if(e.SubViewHandled == false)
            {
                if(keysPressed.Equals(Shortcuts.FirstHeading))
                {
                    //Navigate to the first heading in the book
                    if(TableOfContentsListBox.Items.Count > 0)
                    {
                        SelectedElement = 0;
                        _resetCurrentPositionToHeading = true;
                        NavigateToHeadingID(0);
                    }
                }
                if(keysPressed.Equals(Shortcuts.LastHeading))
                {
                    //Navigate to the last heading in the book
                    if(TableOfContentsListBox.Items.Count > 0)
                    {
                        SelectedElement = TableOfContentsListBox.Items.Count - 1;
                        _resetCurrentPositionToHeading = true;
                        NavigateToHeadingID(TableOfContentsListBox.Items.Count - 1);
                    }
                }
            }

            //Panel Specific Shortcuts

            //Find parent of the control sending this keypress to see if it is part of this views context.
            Navigation navigationContext = UIElementExtensions.GetUIParentOfType<Navigation>(e.keyEventArgs.OriginalSource as UIElement);

            //If not null, then we are in the search context
            if(navigationContext != null && e.SubViewHandled == false)
            {
                //Block up, down, left, right when inside the listboxes on this view
                if(e.keyEventArgs.OriginalSource.ToString() == KeyCommandHandler.ListBoxItem)
                {
                    if(keysPressed.Equals(Shortcuts.PreviousHeader) || keysPressed.Equals(Shortcuts.NextHeader) || keysPressed.Equals(Shortcuts.PreviousSection) ||
                        keysPressed.Equals(Shortcuts.NextSection))
                    {
                        e.SubViewHandled = true;
                    }
                }

                //Contents, Book Information and Bookmarks shortcuts should just switch between those tabs?
                if(keysPressed.Equals(Shortcuts.ContentsPanel))
                {
                    if(navTabs.SelectedIndex != (int)NavigationState.Focus.Contents)
                    {
                        navTabs.SelectedIndex = (int)NavigationState.Focus.Contents;
                        navTabs.Focus();
                        e.SubViewHandled = true;
                    }
                }
                if(keysPressed.Equals(Shortcuts.BookInformationPanel))
                {
                    if(navTabs.SelectedIndex != (int)NavigationState.Focus.BookInformation)
                    {
                        navTabs.SelectedIndex = (int)NavigationState.Focus.BookInformation;
                        navTabs.Focus();
                        e.SubViewHandled = true;
                    }
                }
                if(keysPressed.Equals(Shortcuts.BookmarkPanel))
                {
                    if(navTabs.SelectedIndex != (int)NavigationState.Focus.Bookmarks)
                    {
                        navTabs.SelectedIndex = (int)NavigationState.Focus.Bookmarks;
                        navTabs.Focus();
                        e.SubViewHandled = true;
                    }
                }
            }
        }