Example #1
0
        /// <summary>
        /// Event that is triggered when a nod in the TreeView get's selected
        /// If the nod is a different than the currently selected one (and not a folder)
        /// all running animations will be halted and all TabControls will be made invisible.
        /// Afterwards the needed TabControl will again be made visible and the forms size will be adjusted to it.
        /// </summary>
        /// <param name="sender">The object to trigger the event</param>
        /// <param name="e">the event args containing the node that was selected</param>
        private void tvwEffects_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //saves the name of the selected node
            string hdmaEffect = tvwEffects.SelectedNode.Name;

            if (!Tabs.ContainsKey(hdmaEffect))              // \  if the name is not in the dictionary
            {
                return;                                     //  | for example one of the folders
            }
            if (ActiveTab == hdmaEffect)                    //  | or the same tab is selected twice
            {
                return;                                     // /  return
            }
            //the label at the beginning telling you to select a node.
            lblNoSelect.Visible = false;

            //makes al the TabControls invisible and stops the animation
            foreach (ITab GUI in Tabs.Values)
            {
                GUI.GetTabControl().Visible = false;
                IAnimated AnimatedGUI       = GUI as IAnimated;
                if (AnimatedGUI != null)
                {
                    AnimatedGUI.StopAnimation();
                }
            }

            //save the active node's name and make the tabcontrol visible
            TabControl T = Tabs[hdmaEffect].GetTabControl();

            T.Visible = true;
            ActiveTab = hdmaEffect;

            //adjust size
            using (Graphics g = this.CreateGraphics())
            {
                this.Width  = (int)Math.Ceiling((_splitterDistance + _widthAdd) * (g.DpiX / 96)) + T.Width;
                this.Height = (int)Math.Ceiling((T.Height + _heightAdder) * (g.DpiY / 96));                    // setzt die Weite der Main-control auf die der TabControl
                splitContainer1.SplitterDistance = (int)Math.Ceiling(_splitterDistance * (g.DpiX / 96));       // der Splitter würde dabei prozentuel verschoben werden, deswegen wird er wieder rückgesetzt.
            }
        }