GetAllSessions() публичный статический Метод

Get a list of all sessions from the in-application database
public static GetAllSessions ( ) : List
Результат List
Пример #1
0
        void CreateMenu()
        {
            this.newSessionToolStripMenuItem.Enabled = SuperPuTTY.Settings.PuttyPanelShowNewSessionMenu;
            if (SuperPuTTY.Settings.PuttyPanelShowNewSessionMenu)
            {
                this.contextMenuStrip1.SuspendLayout();

                // BBB: do i need to dispose each one?
                newSessionToolStripMenuItem.DropDownItems.Clear();
                foreach (SessionData session in SuperPuTTY.GetAllSessions())
                {
                    ToolStripMenuItem tsmiParent = newSessionToolStripMenuItem;
                    foreach (string part in SessionData.GetSessionNameParts(session.SessionId))
                    {
                        if (part == session.SessionName)
                        {
                            ToolStripMenuItem newSessionTSMI = new ToolStripMenuItem
                            {
                                Tag  = session,
                                Text = session.SessionName
                            };
                            newSessionTSMI.Click      += new System.EventHandler(newSessionTSMI_Click);
                            newSessionTSMI.ToolTipText = session.ToString();
                            tsmiParent.DropDownItems.Add(newSessionTSMI);
                        }
                        else
                        {
                            if (tsmiParent.DropDownItems.ContainsKey(part))
                            {
                                tsmiParent = (ToolStripMenuItem)tsmiParent.DropDownItems[part];
                            }
                            else
                            {
                                ToolStripMenuItem newSessionFolder = new ToolStripMenuItem(part)
                                {
                                    Name = part
                                };
                                tsmiParent.DropDownItems.Add(newSessionFolder);
                                tsmiParent = newSessionFolder;
                            }
                        }
                    }
                }
                this.contextMenuStrip1.ResumeLayout();
            }

            DockPane pane = GetDockPane();

            if (pane != null)
            {
                this.closeOthersToTheRightToolStripMenuItem.Enabled =
                    pane.Contents.IndexOf(this) != pane.Contents.Count - 1;
            }
            this.closeOthersToolStripMenuItem.Enabled = this.DockPanel.DocumentsCount > 1;
            this.closeAllToolStripMenuItem.Enabled    = this.DockPanel.DocumentsCount > 1;
        }
Пример #2
0
        /// <summary>
        /// Load the sessions from the registry and populate the treeview control
        /// </summary>
        void LoadSessions()
        {
            treeView1.Nodes.Clear();

            this.nodeRoot = treeView1.Nodes.Add("root", "PuTTY Sessions", ImageKeyFolder, ImageKeyFolder);
            this.nodeRoot.ContextMenuStrip = this.contextMenuStripFolder;

            foreach (SessionData session in SuperPuTTY.GetAllSessions())
            {
                TryAddSessionNode(session);
            }
        }
Пример #3
0
        private void InitNewSessionToolStripMenuItems()
        {
            List <ToolStripMenuItem> tsmi = new List <ToolStripMenuItem>();

            foreach (SessionData session in SuperPuTTY.GetAllSessions())
            {
                ToolStripMenuItem tsmiParent = null;
                foreach (string part in SessionData.GetSessionNameParts(session.SessionId))
                {
                    if (part == session.SessionName)
                    {
                        ToolStripMenuItem newSessionTSMI = new ToolStripMenuItem
                        {
                            Tag  = session,
                            Text = session.SessionName
                        };
                        newSessionTSMI.Click      += new System.EventHandler(newSessionTSMI_Click);
                        newSessionTSMI.ToolTipText = session.ToString();
                        if (tsmiParent == null)
                        {
                            tsmi.Add(newSessionTSMI);
                        }
                        else
                        {
                            tsmiParent.DropDownItems.Add(newSessionTSMI);
                        }
                    }
                    else
                    {
                        if (tsmiParent == null)
                        {
                            tsmiParent = tsmi.FirstOrDefault((item) => string.Equals(item.Name, part));
                            if (tsmiParent == null)
                            {
                                tsmiParent = new ToolStripMenuItem(part)
                                {
                                    Name = part
                                };
                                tsmi.Add(tsmiParent);
                            }
                        }
                        else
                        {
                            if (tsmiParent.DropDownItems.ContainsKey(part))
                            {
                                tsmiParent = (ToolStripMenuItem)tsmiParent.DropDownItems[part];
                            }
                            else
                            {
                                ToolStripMenuItem newSessionFolder = new ToolStripMenuItem(part)
                                {
                                    Name = part
                                };
                                tsmiParent.DropDownItems.Add(newSessionFolder);
                                tsmiParent = newSessionFolder;
                            }
                        }
                    }
                }
            }

            if (InvokeRequired)
            {
                Invoke(new Action(() => {
                    if (newSessionToolStripMenuItem.DropDownItems.Count == 0)
                    {
                        newSessionToolStripMenuItem.DropDownItems.AddRange(tsmi.ToArray());
                    }
                }));
            }
            else
            if (newSessionToolStripMenuItem.DropDownItems.Count == 0)
            {
                newSessionToolStripMenuItem.DropDownItems.AddRange(tsmi.ToArray());
            }
        }