示例#1
0
        /// <summary>
        /// Updates a TabControl to reflect all loaded items.
        /// </summary>
        /// <typeparam name="T">The type of element that is loaded.</typeparam>
        /// <param name="loaded">A list of all loaded elements.</param>
        /// <param name="tabControl">The TabControl to be updated.</param>
        /// <param name="onChange">Callback function when the Tabs where updates.</param>
        private void UpdateTabs <T>(List <T> loaded, TabControl tabControl, Action <object, EventArgs> onChange)
        {
            // save the current selected index
            int prevIndex = tabControl.SelectedIndex;

            TabControl.TabPageCollection pageCollection = tabControl.TabPages;

            // remove all pages
            while (pageCollection.Count != 0)
            {
                pageCollection.RemoveAt(0);
            }

            // readd all pages
            for (int i = 0; i < loaded.Count; i++)
            {
                pageCollection.Add(loaded[i].ToString());
            }

            // is the index still valid?
            if (prevIndex >= pageCollection.Count)
            {
                prevIndex = pageCollection.Count - 1;
            }
            if (prevIndex < 0)
            {
                prevIndex = 0;
            }

            // restore the index
            tabControl.SelectedIndex = prevIndex;

            onChange.Invoke(null, null);
        }
示例#2
0
        protected void OnNewButtonClick(object sender, EventArgs e)
        {
            while (ScriptTabs.Count > 1)
            {
                ScriptTabs.RemoveAt(ScriptTabs.Count - 1);
            }

            NameText.Text   = "";
            KeyText.Text    = "C5";
            BpmText.Text    = "120";
            VolumeText.Text = "100";

            ScriptTabList.SelectedTab.ToolTipText = ScriptText.Text = "";
            ScriptTabList.SelectedTab.ImageKey    = VolumeText.Text = "100";

            MusicList.SelectedIndex = -1;

            ScriptText.Select();
        }
示例#3
0
 public void Destroy()
 {
     lManager.Enter(Logs.Sender.MANAGER, Logs.Level.NOTICE, "Tab: {0} has been closed.", Page.Text);
     pages.RemoveAt(RightClick_TabIdx);
     tabs.SelectedIndex = pages.Count - 1;
 }