//Resizes splitterpanels controls[0] to parent size
        private void splitContainer_Resize(object sender, EventArgs e)
        {
            NonFlickerSplitContainer tempContainer = (NonFlickerSplitContainer)sender;

            if (tempContainer.Panel1.Controls.Count > 0)
            {
                tempContainer.Panel1.Controls[0].Size = new Size(tempContainer.Panel1.Width, tempContainer.Panel1.Height);
            }
            if (tempContainer.Panel2.Controls.Count > 0)
            {
                tempContainer.Panel2.Controls[0].Size = new Size(tempContainer.Panel2.Width, tempContainer.Panel2.Height);
            }
        }
        private void createLayout()
        {
            //Splitcontainer background is set to transparent
            split1                = new NonFlickerSplitContainer();
            split2                = new NonFlickerSplitContainer();
            split1.BackColor      = Color.Transparent;
            split2.BackColor      = Color.Transparent;
            split1.Panel1.Paint  += Panel_Paint;
            split1.Panel2.Paint  += Panel_Paint;
            split2.Panel1.Paint  += Panel_Paint;
            split2.Panel2.Paint  += Panel_Paint;
            split1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer_SplitterMoved);
            split1.Resize        += new System.EventHandler(this.splitContainer_Resize);
            split2.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer_SplitterMoved);
            split2.Resize        += new System.EventHandler(this.splitContainer_Resize);


            //control_Load receives 1 module from selectMods and 1 splitterpanel
            //and adds the module to the splitterpanel
            //splitcontainers are later added to splitcontainers and/or a panel
            //orientation is set based on layout
            switch (layout)
            {
            case "1":
                UserControl temp        = modList[0].userControl;
                Panel       layoutPanel = new Panel();
                layoutPanel.BackColor = Color.Transparent;
                layoutPanel.Resize   += new System.EventHandler(this.layoutPanel_Resize);
                layoutPanel.Dock      = DockStyle.Fill;
                layoutPanel.Controls.Add(temp);
                splitContainer1.Panel2.Controls.Add(layoutPanel);
                temp.Show();
                break;

            case "2_1":
                control_Load(modList[0].userControl, split1.Panel1);
                control_Load(modList[1].userControl, split1.Panel2);
                split1.Orientation = Orientation.Horizontal;
                split1.Dock        = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                break;

            case "2_2":
                control_Load(modList[0].userControl, split1.Panel1);
                control_Load(modList[1].userControl, split1.Panel2);
                split1.Dock = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                break;

            case "3_1":
                control_Load(modList[0].userControl, split1.Panel1);
                control_Load(modList[1].userControl, split2.Panel1);
                control_Load(modList[2].userControl, split2.Panel2);
                split1.Dock        = DockStyle.Fill;
                split1.Orientation = Orientation.Horizontal;
                split1.Panel2.Controls.Add(split2);
                split2.Dock = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                split2.SplitterDistance = split2.Width / 2;
                break;

            case "3_2":
                control_Load(modList[0].userControl, split1.Panel2);
                control_Load(modList[1].userControl, split2.Panel1);
                control_Load(modList[2].userControl, split2.Panel2);
                split2.Dock        = DockStyle.Fill;
                split1.Orientation = Orientation.Horizontal;
                split1.Panel1.Controls.Add(split2);
                split1.Dock = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                split2.SplitterDistance = split2.Width / 2;
                break;

            case "3_3":
                control_Load(modList[0].userControl, split1.Panel2);
                control_Load(modList[1].userControl, split2.Panel1);
                control_Load(modList[2].userControl, split2.Panel2);
                split2.Dock        = DockStyle.Fill;
                split2.Orientation = Orientation.Horizontal;
                split1.Panel1.Controls.Add(split2);
                split1.Dock = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                split2.SplitterDistance = split2.Height / 2;
                break;

            case "3_4":
                control_Load(modList[0].userControl, split1.Panel1);
                control_Load(modList[1].userControl, split2.Panel1);
                control_Load(modList[2].userControl, split2.Panel2);
                split2.Dock        = DockStyle.Fill;
                split2.Orientation = Orientation.Horizontal;
                split1.Panel2.Controls.Add(split2);
                split1.Dock = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                split2.SplitterDistance = split2.Height / 2;
                break;

            case "4":
                control_Load(modList[0].userControl, split1.Panel1);
                control_Load(modList[1].userControl, split1.Panel2);
                control_Load(modList[2].userControl, split2.Panel1);
                control_Load(modList[3].userControl, split2.Panel2);
                split1.Width  = splitContainer1.Panel2.Width;
                split1.Height = splitContainer1.Panel2.Height / 2;
                split2.Dock   = DockStyle.Fill;
                splitContainer1.Panel2.Controls.Add(split1);
                splitContainer1.Panel2.Controls.Add(split2);
                split2.SplitterDistance = split2.Width / 2;
                break;
            }
        }