Details for control tabbing events.
Inheritance: CancelEventArgs
        /// <summary>
        /// Process a dialog key in a manner appropriate for the view.
        /// </summary>
        /// <param name="keyData">Key data.</param>
        /// <returns>True if the key eaten; otherwise false.</returns>
        public override bool ProcessDialogKey(Keys keyData)
        {
            // Find out which modifier keys are being pressed
            bool shift   = ((keyData & Keys.Shift) == Keys.Shift);
            bool control = ((keyData & Keys.Control) == Keys.Control);

            // Extract just the key and not modifier keys
            Keys keyCode = (keyData & Keys.KeyCode);

            // There must be a selected page before any action can occur
            if (Navigator.SelectedPage != null)
            {
                // Check for keys without modifiers
                switch (keyCode)
                {
                case Keys.Tab:
                    // Using a CONTROL tab means selecting another page
                    if (control)
                    {
                        // Are we allowed to perform a Ctrl+Tab change in selection
                        CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(!shift);
                        Navigator.OnCtrlTabStart(ce);

                        if (!ce.Cancel)
                        {
                            bool changed = !shift?SelectNextPage(Navigator.SelectedPage, true, true) : SelectPreviousPage(Navigator.SelectedPage, true, true);
                        }
                    }
                    return(true);
                }
            }

            // Last of all check for a shortcut to the action buttons
            return(CheckActionShortcuts(keyData));
        }
        /// <summary>
        /// Select the previous page to the one provided.
        /// </summary>
        /// <param name="page">Starting page for search.</param>
        /// <param name="wrap">Wrap around end of collection to the start.</param>
        /// <param name="ctrlTab">Associated with a Ctrl+Tab action.</param>
        /// <returns>True if new page selected; otherwise false.</returns>
        public virtual bool SelectPreviousPage(KryptonPage page,
                                               bool wrap,
                                               bool ctrlTab)
        {
            // There must be at least one page and allowed to select a page
            if ((Navigator.Pages.Count > 0) && Navigator.AllowTabSelect)
            {
                KryptonPage first;

                // If given a starting page, it must be in the pages collection,
                // otherwise we start by searching from the last page backwards
                if ((page != null) && Navigator.Pages.Contains(page))
                {
                    first = Navigator.PreviousActionPage(page);

                    // If at start of collection and wrapping is enabled then get the last page
                    if ((first == null) && wrap)
                    {
                        // Are we allowed to wrap around?
                        CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(false);
                        Navigator.OnCtrlTabWrap(ce);

                        if (ce.Cancel)
                        {
                            return(false);
                        }

                        first = Navigator.LastActionPage();
                    }
                }
                else
                {
                    first = Navigator.LastActionPage();
                }

                // Page to test is the first one
                KryptonPage previous = first;

                // Keep testing previous pages until no more are left
                while (previous != null)
                {
                    // Attempt to select the previous page
                    Navigator.SelectedPage = previous;

                    // If previous page was selected, then all finished
                    if (Navigator.SelectedPage == previous)
                    {
                        return(true);
                    }
                    else
                    {
                        // Otherwise keep looking for another visible previous page
                        previous = Navigator.PreviousActionPage(previous);

                        // If we reached the start of the collection and we should wrap
                        if ((previous == null) && wrap)
                        {
                            // Are we allowed to wrap around?
                            CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(false);
                            Navigator.OnCtrlTabWrap(ce);

                            if (ce.Cancel)
                            {
                                return(false);
                            }

                            // Wrap around to the last page
                            previous = Navigator.Pages[Navigator.Pages.Count - 1];
                        }

                        // If we are back at the first page we examined then we must have
                        // wrapped around collection and still found nothing, time to exit
                        if (previous == first)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Process a dialog key in a manner appropriate for the view.
        /// </summary>
        /// <param name="keyData">Key data.</param>
        /// <returns>True if the key eaten; otherwise false.</returns>
        public override bool ProcessDialogKey(Keys keyData)
        {
            // Find out which modifier keys are being pressed
            bool shift   = ((keyData & Keys.Shift) == Keys.Shift);
            bool control = ((keyData & Keys.Control) == Keys.Control);

            // Extract just the key and not modifier keys
            Keys keyCode = (keyData & Keys.KeyCode);

            // There must be a selected page before any action can occur
            if (Navigator.SelectedPage != null)
            {
                switch (keyCode)
                {
                case Keys.Tab:
                    // Using a CONTROL tab means selecting the another page
                    if (control)
                    {
                        // Are we allowed to perform a Ctrl+Tab change in selection
                        CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(!shift);
                        Navigator.OnCtrlTabStart(ce);

                        if (!ce.Cancel)
                        {
                            bool changed = !shift?SelectNextPage(Navigator.SelectedPage, true, true) : SelectPreviousPage(Navigator.SelectedPage, true, true);
                        }
                    }
                    return(true);

                case Keys.Home:
                    if (_hasFocus)
                    {
                        SelectNextPage(null, false, false);
                        return(true);
                    }
                    break;

                case Keys.End:
                    if (_hasFocus)
                    {
                        SelectPreviousPage(null, false, false);
                        return(true);
                    }
                    break;

                case Keys.Up:
                    if (_hasFocus)
                    {
                        // Can only use Up arrow when on a vertical stack
                        if (Navigator.Stack.StackOrientation == Orientation.Vertical)
                        {
                            SelectPreviousPage(Navigator.SelectedPage, false, false);
                        }
                        return(true);
                    }
                    break;

                case Keys.Down:
                    if (_hasFocus)
                    {
                        // Can only use Down arrow when on a vertical stack
                        if (Navigator.Stack.StackOrientation == Orientation.Vertical)
                        {
                            SelectNextPage(Navigator.SelectedPage, false, false);
                        }
                        return(true);
                    }
                    break;

                case Keys.Right:
                    if (_hasFocus)
                    {
                        // Can only use Right arrow when on a horizontal stack
                        if (Navigator.Stack.StackOrientation == Orientation.Horizontal)
                        {
                            // Reverse the direction if working RightToLeft
                            if (Navigator.RightToLeft != RightToLeft.Yes)
                            {
                                SelectNextPage(Navigator.SelectedPage, false, false);
                            }
                            else
                            {
                                SelectPreviousPage(Navigator.SelectedPage, false, false);
                            }
                        }
                        return(true);
                    }
                    break;

                case Keys.Left:
                    if (_hasFocus)
                    {
                        // Can only use Right arrow when on a horizontal stack
                        if (Navigator.Stack.StackOrientation == Orientation.Horizontal)
                        {
                            // Reverse the direction if working RightToLeft
                            if (Navigator.RightToLeft != RightToLeft.Yes)
                            {
                                SelectPreviousPage(Navigator.SelectedPage, false, false);
                            }
                            else
                            {
                                SelectNextPage(Navigator.SelectedPage, false, false);
                            }
                        }
                        return(true);
                    }
                    break;

                case Keys.Space:
                case Keys.Enter:
                    if (_hasFocus)
                    {
                        KeyPressedPageView();
                    }
                    break;
                }
            }

            // We do not eat the key
            return(false);
        }
        /// <summary>
        /// Process a dialog key in a manner appropriate for the view.
        /// </summary>
        /// <param name="keyData">Key data.</param>
        /// <returns>True if the key eaten; otherwise false.</returns>
        public override bool ProcessDialogKey(Keys keyData)
        {
            // Find out which modifier keys are being pressed
            bool shift = ((keyData & Keys.Shift) == Keys.Shift);
            bool control = ((keyData & Keys.Control) == Keys.Control);

            // Extract just the key and not modifier keys
            Keys keyCode = (keyData & Keys.KeyCode);

            // There must be a selected page before any action can occur
            if (Navigator.SelectedPage != null)
            {
                // Check for keys without modifiers
                switch (keyCode)
                {
                    case Keys.Tab:
                        // Using a CONTROL tab means selecting another page
                        if (control)
                        {
                            // Are we allowed to perform a Ctrl+Tab change in selection
                            CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(!shift);
                            Navigator.OnCtrlTabStart(ce);

                            if (!ce.Cancel)
                            {
                                bool changed;
                                if (!shift)
                                    changed = SelectNextPage(Navigator.SelectedPage, true, true);
                                else
                                    changed = SelectPreviousPage(Navigator.SelectedPage, true, true);
                            }
                        }
                        return true;
                }

                // Check for keys with modifiers
                switch(keyData)
                {
                    case Keys.Home:
                        if (_hasFocus)
                        {
                            SelectNextPage(null, false, false);
                            return true;
                        }
                        break;
                    case Keys.End:
                        if (_hasFocus)
                        {
                            SelectPreviousPage(null, false, false);
                            return true;
                        }
                        break;
                    case Keys.Up:
                        if (_hasFocus)
                        {
                            // Can only use Up arrow when on a vertical bar
                            if (!BarHorizontal)
                                SelectPreviousPage(Navigator.SelectedPage, false, false);
                            return true;
                        }
                        break;
                    case Keys.Down:
                        if (_hasFocus)
                        {
                            // Can only use Down arrow when on a vertical bar
                            if (!BarHorizontal)
                                SelectNextPage(Navigator.SelectedPage, false, false);
                            return true;
                        }
                        break;
                    case Keys.Right:
                        if (_hasFocus)
                        {
                            // Can only use Right arrow when on a horizontal bar
                            if (BarHorizontal)
                            {
                                // Reverse the direction if working RightToLeft
                                if (Navigator.RightToLeft != RightToLeft.Yes)
                                    SelectNextPage(Navigator.SelectedPage, false, false);
                                else
                                    SelectPreviousPage(Navigator.SelectedPage, false, false);
                            }
                            return true;
                        }
                        break;
                    case Keys.Left:
                        if (_hasFocus)
                        {
                            // Can only use Right arrow when on a horizontal bar
                            if (BarHorizontal)
                            {
                                // Reverse the direction if working RightToLeft
                                if (Navigator.RightToLeft != RightToLeft.Yes)
                                    SelectPreviousPage(Navigator.SelectedPage, false, false);
                                else
                                    SelectNextPage(Navigator.SelectedPage, false, false);
                            }
                            return true;
                        }
                        break;
                    case Keys.Space:
                    case Keys.Enter:
                        if (_hasFocus)
                            KeyPressedPageView();
                        break;
                }
            }

            // Last of all check for a shortcut to the action buttons
            return CheckActionShortcuts(keyData);
        }
        /// <summary>
        /// Process a dialog key in a manner appropriate for the view.
        /// </summary>
        /// <param name="keyData">Key data.</param>
        /// <returns>True if the key eaten; otherwise false.</returns>
        public override bool ProcessDialogKey(Keys keyData)
        {
            // Find out which modifier keys are being pressed
            bool shift = ((keyData & Keys.Shift) == Keys.Shift);
            bool control = ((keyData & Keys.Control) == Keys.Control);

            // Extract just the key and not modifier keys
            Keys keyCode = (keyData & Keys.KeyCode);

            // There must be a selected page before any action can occur
            if (Navigator.SelectedPage != null)
            {
                // Check for keys without modifiers
                switch (keyCode)
                {
                    case Keys.Tab:
                        // Using a CONTROL tab means selecting another page
                        if (control)
                        {
                            // Are we allowed to perform a Ctrl+Tab change in selection
                            CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(!shift);
                            Navigator.OnCtrlTabStart(ce);

                            if (!ce.Cancel)
                            {
                                bool changed;
                                if (!shift)
                                    changed = SelectNextPage(Navigator.SelectedPage, true, true);
                                else
                                    changed = SelectPreviousPage(Navigator.SelectedPage, true, true);
                            }
                        }
                        return true;
                }
            }

            // Last of all check for a shortcut to the action buttons
            return CheckActionShortcuts(keyData);
        }
Example #6
0
 /// <summary>
 /// Raises the CtrlTabWrap event.
 /// </summary>
 /// <param name="e">An CtrlTabCancelEventArgs containing event details.</param>
 protected internal virtual void OnCtrlTabWrap(CtrlTabCancelEventArgs e)
 {
     if (CtrlTabWrap != null)
         CtrlTabWrap(this, e);
 }
Example #7
0
 /// <summary>
 /// Raises the CtrlTabStart event.
 /// </summary>
 /// <param name="e">An CtrlTabCancelEventArgs containing event details.</param>
 protected internal virtual void OnCtrlTabStart(CtrlTabCancelEventArgs e)
 {
     if (CtrlTabStart != null)
         CtrlTabStart(this, e);
 }