Exemplo n.º 1
0
 /// <summary>
 /// Run the modal help dialog until the user exits.
 /// </summary>
 public static void Launch()
 {
     using (HelpDialog dialog = new HelpDialog())
     {
         Application.Run(dialog);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Implement custom key handling on this view.
        /// </summary>
        /// <param name="kb">Contains the details about the key that produced the event.</param>
        /// <returns>True if the key was handled, False otherwise.</returns>
        public override bool ProcessKey(KeyEvent kb)
        {
            if (kb == null)
            {
                throw new ArgumentNullException(nameof(kb));
            }

            // Handle specific characters we want to have behavior.
            //
            char keyChar = (char)((uint)kb.Key & (uint)Key.CharMask);

            switch (keyChar)
            {
            // Map vim Keys to be up and down.
            //
            case 'j':
                kb.Key = Key.CursorDown;
                return(base.ProcessKey(kb));

            case 'k':
                kb.Key = Key.CursorUp;
                return(base.ProcessKey(kb));

            // Enable hotkey refresh.
            //
            case 'r':
                m_refreshTask.RequestRefresh();
                return(true);

            // Enable hotkey switch view to waiting.
            //
            case 'w':
                SwitchPrStateView(PrState.Waiting);
                return(true);

            // Enable hotkey switch view to drafts.
            //
            case 'd':
                SwitchPrStateView(PrState.Drafts);
                return(true);

            // Enable hotkey switch view to actionable.
            //
            case 'a':
                SwitchPrStateView(PrState.Actionable);
                return(true);

            // Enable hotkey switch view to signed off.
            //
            case 's':
                SwitchPrStateView(PrState.SignedOff);
                return(true);

            // Enable hotkey switch view to our created prs.
            //
            case 'c':
                SwitchPrStateView(PrState.Created);
                return(true);

            // Enable hotkey help.
            //
            case 'h':
                HelpDialog.Launch();
                return(true);

            // Enable hotkey quit.
            //
            case 'q':
                Application.RequestStop();
                return(true);
            }

            // Handle special characters.
            //
            switch (kb.Key)
            {
            // Hook Control-C and Esc as exit.
            //
            case Key.Esc:
            case Key.C | Key.CtrlMask:
                Application.RequestStop();
                return(true);
            }

            // Forward everything else to the real implementation.
            //
            return(base.ProcessKey(kb));
        }