SuperPutty.ctlPuttyPanel.AdjustMenu C# (CSharp) Method

AdjustMenu() public method

public AdjustMenu ( ) : void
return void
        public void AdjustMenu()
        {
            // for mintty, disable the putty menu items
            if (this.Session.Proto == ConnectionProtocol.Mintty)
            {
                this.toolStripPuttySep1.Visible = false;
                this.eventLogToolStripMenuItem.Visible = false;
                this.toolStripPuttySep2.Visible = false;
                this.changeSettingsToolStripMenuItem.Visible = false;
                this.copyAllToClipboardToolStripMenuItem.Visible = false;
                this.restartSessionToolStripMenuItem.Visible = false;
                this.clearScrollbackToolStripMenuItem.Visible = false;
                this.resetTerminalToolStripMenuItem.Visible = false;
            }
            // for putty/kitty inactive tab
            else {
                if (this.inactive)
                {
                    this.duplicateSessionToolStripMenuItem.Visible = false;
                    this.toolStripSeparator1.Visible = false;
                    this.renameTabToolStripMenuItem.Visible = false;
                    this.refreshToolStripMenuItem.Visible = false;
                    this.acceptCommandsToolStripMenuItem.Visible = false;
                    this.toolStripPuttySep1.Visible = false;
                    this.changeSettingsToolStripMenuItem.Visible = false;
                    this.clearScrollbackToolStripMenuItem.Visible = false;
                    this.resetTerminalToolStripMenuItem.Visible = false;
                    this.toolStripSeparator3.Visible = false;
                    this.aboutPuttyToolStripMenuItem.Visible = false;
                    this.toolStripSeparator4.Visible = false;
                }
                else
                {
                    this.duplicateSessionToolStripMenuItem.Visible = true;
                    this.toolStripSeparator1.Visible = true;
                    this.renameTabToolStripMenuItem.Visible = true;
                    this.refreshToolStripMenuItem.Visible = true;
                    this.acceptCommandsToolStripMenuItem.Visible = true;
                    this.toolStripPuttySep1.Visible = true;
                    this.changeSettingsToolStripMenuItem.Visible = true;
                    this.clearScrollbackToolStripMenuItem.Visible = true;
                    this.resetTerminalToolStripMenuItem.Visible = true;
                    this.toolStripSeparator3.Visible = true;
                    this.aboutPuttyToolStripMenuItem.Visible = true;
                    this.toolStripSeparator4.Visible = true;
                }
            }

        }

Usage Example

Example #1
0
        private void UpdateTitle()
        {
            ctlPuttyPanel panel  = (ctlPuttyPanel)this.Parent;
            int           length = NativeMethods.SendMessage(m_AppWin, NativeMethods.WM_GETTEXTLENGTH, 0, 0) + 1;
            StringBuilder sb     = new StringBuilder(length + 1);

            NativeMethods.SendMessage(m_AppWin, NativeMethods.WM_GETTEXT, sb.Capacity, sb);
            string controlText = sb.ToString();
            string parentText  = panel.TextOverride;

            switch ((SuperPutty.frmSuperPutty.TabTextBehavior)Enum.Parse(typeof(frmSuperPutty.TabTextBehavior), SuperPuTTY.Settings.TabTextBehavior))
            {
            case frmSuperPutty.TabTextBehavior.Static:
                this.Parent.Text = parentText;
                break;

            case frmSuperPutty.TabTextBehavior.Dynamic:
                this.Parent.Text = controlText;
                break;

            case frmSuperPutty.TabTextBehavior.Mixed:
                this.Parent.Text = parentText + ": " + controlText;
                break;
            }

            // putty/kitty tab became inactive
            if (!panel.inactive && controlText.EndsWith("TTY (inactive)"))
            {
                Icon   icon     = null;
                string imageKey = (SuperPuTTY.Images.Images.ContainsKey("dead")) ? "dead" : null;
                try
                {
                    Image  img = SuperPuTTY.Images.Images[imageKey];
                    Bitmap bmp = img as Bitmap;
                    if (bmp != null)
                    {
                        icon = Icon.FromHandle(bmp.GetHicon());
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Error getting icon for dead tab", ex);
                }
                panel.inactive = true;
                panel.Icon     = icon;
                panel.AdjustMenu();
                panel.Pane.Refresh();
            }
            else if (panel.inactive && !controlText.EndsWith("TTY (inactive)"))
            {
                panel.inactive = false;
                panel.Icon     = SuperPuTTY.GetIconForSession(panel.Session);
                panel.AdjustMenu();
                panel.Pane.Refresh();
            }
        }