コード例 #1
0
ファイル: FormMain.cs プロジェクト: FSofTlpz/GMExplorer
        /// <summary>
        /// erzeugt einen Clone der <see cref="dummytabpage"/> und hängt ihn an das TabControl an
        /// </summary>
        /// <param name="text"></param>
        /// <param name="path"></param>
        /// <returns>neue TabPage</returns>
        TabPageData AppendNewTabPage(string text, string path)
        {
            TabPage  newtabpage = new TabPage(text);
            TreeView newtv      = null;
            TextBox  newinfo    = null;
            HexWin   newhexwin  = null;

            foreach (var dummytabpagectrl in dummytabpage.Controls)
            {
                if (dummytabpagectrl is SplitContainer)
                {
                    SplitContainer sc    = dummytabpagectrl as SplitContainer;
                    SplitContainer newsc = sc.Clone();
                    newtabpage.Controls.Add(newsc);

                    foreach (var item in sc.Panel1.Controls)
                    {
                        if (item is TreeView)
                        {
                            newtv = (item as TreeView).Clone();
                            newsc.Panel1.Controls.Add(newtv);
                            newsc.SplitterDistance = newsc.Width / 3;

                            newtv.AfterSelect  += TreeView_AfterSelect;
                            newtv.BeforeExpand += TreeView_BeforeExpand;

                            newtv.Tag = new TreeViewData(newtv);
                        }
                    }

                    foreach (var item in sc.Panel2.Controls)
                    {
                        if (item is SplitContainer)
                        {
                            SplitContainer sc2    = item as SplitContainer;
                            SplitContainer newsc2 = sc2.Clone();
                            newsc.Panel2.Controls.Add(newsc2);
                            newsc2.SplitterDistance = newsc2.Height / 2;

                            foreach (var item2 in sc2.Panel1.Controls)
                            {
                                if (item2 is TextBox)
                                {
                                    newinfo = (item2 as TextBox).Clone();
                                    newsc2.Panel1.Controls.Add(newinfo);
                                }
                            }
                            foreach (var item3 in sc2.Panel2.Controls)
                            {
                                if (item3 is HexWin)
                                {
                                    newhexwin = (item3 as HexWin).Clone();
                                    newsc2.Panel2.Controls.Add(newhexwin);
                                }
                            }
                        }
                    }
                }
            }

            newtabpage.Tag        = new TabPageData(newtabpage, newtv, newinfo, newhexwin, path);
            newtabpage.ImageIndex = 0;
            tabControl1.TabPages.Add(newtabpage);

            return(TabPageData4Page(newtabpage));
        }