Beispiel #1
0
        /// <summary>
        /// Creates the session menu to a given parent tool strip menu item.
        /// </summary>
        /// <param name="parent">The parent tool strip menu item to create the session menu to.</param>
        /// <param name="currentSession">The currently active session.</param>
        public static void CreateSessionMenu(ToolStripMenuItem parent, FileSession currentSession)
        {
            // first dispose the previous menu..
            DisposeSessionMenu();

            foreach (var session in ScriptNotepadDbContext.DbContext.FileSessions)
            {
                var item = new ToolStripMenuItem
                {
                    Text    = session.SessionName,
                    Tag     = session, CheckOnClick = true,
                    Checked = session.SessionName == currentSession.SessionName,
                };

                item.Click  += SessionMenuItem_Click;
                item.Checked = session.SessionName == currentSession.SessionName;

                CurrentMenu.Add(item);

                parent.DropDownItems.Add(item);
            }
        }