示例#1
0
 public void UpdateFromShortcuts(KeyboardShortcut[] shortcuts)
 {
     foreach (KeyboardShortcut ks in shortcuts)
     {
         SuperPuttyAction action = (SuperPuttyAction)Enum.Parse(typeof(SuperPuttyAction), ks.Name);
         string           name   = string.Format("Action_{0}_Shortcut", action);
         try
         {
             this[name] = ks.Key | ks.Modifiers;
         }
         catch (ArgumentException ex)
         {
             this[name] = Keys.None;
             Log.WarnFormat("Could not update shortcut for " + name + ".  Setting to None.", ex);
         }
     }
 }
示例#2
0
        bool ExecuteSuperPuttyAction(SuperPuttyAction action)
        {
            bool success = true;

            Log.InfoFormat("Executing action, name={0}", action);
            switch (action)
            {
                case SuperPuttyAction.CloseTab:
                    ToolWindow win = this.DockPanel.ActiveDocument as ToolWindow;
                    if (win != null) { win.Close(); }
                    break;
                case SuperPuttyAction.NextTab:
                    this.tabSwitcher.MoveToNextDocument();
                    break;
                case SuperPuttyAction.PrevTab:
                    this.tabSwitcher.MoveToPrevDocument();
                    break;
                case SuperPuttyAction.FullScreen:
                    this.ToggleFullScreen();
                    break;
                case SuperPuttyAction.OpenSession:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.openSessionToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.SwitchSession:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.switchSessionToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.Options:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.optionsToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.DuplicateSession:
                    ctlPuttyPanel p = this.DockPanel.ActiveDocument as ctlPuttyPanel;
                    if (p != null && p.Session != null)
                    {
                        SuperPuTTY.OpenPuttySession(p.Session);
                    }
                    break;
                case SuperPuttyAction.GotoCommandBar:
                    if (!this.fullscreenViewState.IsFullScreen)
                    {
                        KeyEventWindowActivator.ActivateForm(this);
                        if (!this.tsCommands.Visible)
                        {
                            this.toggleCheckedState(this.sendCommandsToolStripMenuItem, EventArgs.Empty);
                        }
                        this.tsSendCommandCombo.Focus();
                    }
                    break;
                case SuperPuttyAction.GotoConnectionBar:
                    // perhaps consider allowing this later...need to really have a better approach to the state saving/invoking the toggle.
                    if (!this.fullscreenViewState.IsFullScreen)
                    {
                        KeyEventWindowActivator.ActivateForm(this);
                        if (!this.tsConnect.Visible)
                        {
                            this.toggleCheckedState(this.quickConnectionToolStripMenuItem, EventArgs.Empty);
                        }
                        this.tbTxtBoxHost.Focus();
                    }
                    break;
                case SuperPuttyAction.FocusActiveSession:
                    // focus on current super putty session...or at least try to
                    KeyEventWindowActivator.ActivateForm(this);
                    ctlPuttyPanel putty = this.DockPanel.ActiveDocument as ctlPuttyPanel;
                    if (putty != null)
                    {
                        putty.SetFocusToChildApplication("ExecuteAction");
                    }
                    break;
                default:
                    success = false;
                    break;
            }

            return success;
        }
示例#3
0
        bool ExecuteSuperPuttyAction(SuperPuttyAction action)
        {
            ctlPuttyPanel activePanel = this.DockPanel.ActiveDocument as ctlPuttyPanel;
            bool success = true;

            Log.InfoFormat("Executing action, name={0}", action);
            switch (action)
            {
                case SuperPuttyAction.CloseTab:
                    ToolWindow win = this.DockPanel.ActiveDocument as ToolWindow;
                    if (win != null) { win.Close(); }
                    break;
                case SuperPuttyAction.NextTab:
                    this.tabSwitcher.MoveToNextDocument();
                    break;
                case SuperPuttyAction.PrevTab:
                    this.tabSwitcher.MoveToPrevDocument();
                    break;
                case SuperPuttyAction.FullScreen:
                    this.ToggleFullScreen();
                    break;
                case SuperPuttyAction.OpenSession:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.openSessionToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.SwitchSession:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.switchSessionToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.Options:
                    KeyEventWindowActivator.ActivateForm(this);
                    this.optionsToolStripMenuItem.PerformClick();
                    break;
                case SuperPuttyAction.DuplicateSession:
                    if (activePanel != null && activePanel.Session != null)
                        SuperPuTTY.OpenPuttySession(activePanel.Session);
                    break;
                case SuperPuttyAction.GotoCommandBar:
                    if (!this.fullscreenViewState.IsFullScreen)
                    {
                        KeyEventWindowActivator.ActivateForm(this);
                        if (!this.tsCommands.Visible)
                        {
                            this.toggleCheckedState(this.sendCommandsToolStripMenuItem, EventArgs.Empty);
                        }
                        this.tsSendCommandCombo.Focus();
                    }
                    break;
                case SuperPuttyAction.GotoConnectionBar:
                    // perhaps consider allowing this later...need to really have a better approach to the state saving/invoking the toggle.
                    if (!this.fullscreenViewState.IsFullScreen)
                    {
                        KeyEventWindowActivator.ActivateForm(this);
                        if (!this.tsConnect.Visible)
                        {
                            this.toggleCheckedState(this.quickConnectionToolStripMenuItem, EventArgs.Empty);
                        }
                        this.tbTxtBoxHost.Focus();
                    }
                    break;
                case SuperPuttyAction.FocusActiveSession:
                    // focus on current super putty session...or at least try to
                    KeyEventWindowActivator.ActivateForm(this);
                    if (activePanel != null)
                        activePanel.SetFocusToChildApplication("ExecuteAction");
                    break;
                case SuperPuttyAction.OpenScriptEditor:
                    KeyEventWindowActivator.ActivateForm(this);
                    toolStripButtonRunScript_Click(this, EventArgs.Empty);
                    break;
                case SuperPuttyAction.RenameTab:                    
                    if (activePanel != null && activePanel.Session != null)
                    {
                        dlgRenameItem dialog = new dlgRenameItem
                        {
                            ItemName = activePanel.Text,
                            DetailName = activePanel.Session.SessionId
                        };

                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            activePanel.Text = activePanel.TextOverride = dialog.ItemName;                            
                        }                        
                    }
                    break;
                default:
                    success = false;
                    break;
            }

            return success;
        }