Exemplo n.º 1
0
        /// <summary>
        ///     增加一个MultiTabControl
        /// </summary>
        /// <param name="key"></param>
        /// <param name="info"></param>
        /// <param name="tab"></param>
        public static void AddView(MultiTabControl view, string tabPageTitle)
        {
            var key = view.SelectObjectTag;

            if (ExistTabPage.ContainsKey(key))
            {
                ViewTabContain.SelectedTab = ExistTabPage[key];
                return;
            }
            var tabpage = new TabPage();

            if (view.IsFixedItem)
            {
                if (!BindingMenuItems.ContainsKey(key))
                {
                    BindingMenuItems.Add(key, view.BindingMenu);
                }
                if (FixItemCache.ContainsKey(key))
                {
                    tabpage = FixItemCache[key];
                }
                else
                {
                    FixItemCache.Add(key, tabpage);
                    //Fix项目的MenuItem事件的绑定
                    //注意,事件只能绑定一次
                    view.BindingMenu.Click += (x, y) =>
                    {
                        view.BindingMenu.Checked = !view.BindingMenu.Checked;
                        if (view.BindingMenu.Checked)
                        {
                            //加入
                            view.RefreshGui();
                            AddView(view, tabPageTitle);
                        }
                        else
                        {
                            //删除
                            RemoveView(view.SelectObjectTag);
                        }
                    };
                    //Close Event
                    view.CloseTab += (x, y) => { RemoveView(view.SelectObjectTag); };
                }
            }
            else
            {
                //Close Event
                view.CloseTab += (x, y) => { RemoveView(view.SelectObjectTag); };
            }
            tabpage.Text        = tabPageTitle;
            tabpage.Tag         = view.SelectObjectTag;
            tabpage.ToolTipText = view.SelectObjectTag;
            view.Dock           = DockStyle.Fill;
            tabpage.Controls.Add(view);
            ViewTabContain.TabPages.Add(tabpage);
            ViewTabContain.SelectTab(tabpage);
            ExistTabPage.Add(key, tabpage);
            RefreshMenuItem();
        }
Exemplo n.º 2
0
 /// <summary>
 ///     增加一个MultiTabControl
 /// </summary>
 /// <param name="key"></param>
 /// <param name="info"></param>
 /// <param name="tab"></param>
 public static void AddView(MultiTabControl view, string tabPageTitle,string SelectTagType)
 {
     var key = view.SelectObjectTag;
     if (ExistTabPage.ContainsKey(key))
     {
         ViewTabContain.SelectedTab = ExistTabPage[key];
         return;
     }
     var tabpage = new TabPage();
     if (SelectTagType == ConstMgr.GridFileSystemTag) tabpage.AllowDrop = true;
     if (view.IsFixedItem)
     {
         if (!BindingMenuItems.ContainsKey(key))
         {
             BindingMenuItems.Add(key, view.BindingMenu);
         }
         if (FixItemCache.ContainsKey(key))
         {
             tabpage = FixItemCache[key];
         }
         else
         {
             FixItemCache.Add(key, tabpage);
             //Fix项目的MenuItem事件的绑定
             //注意,事件只能绑定一次
             view.BindingMenu.Click += (x, y) =>
             {
                 view.BindingMenu.Checked = !view.BindingMenu.Checked;
                 if (view.BindingMenu.Checked)
                 {
                     //加入
                     view.RefreshGui();
                     AddView(view, tabPageTitle, SelectTagType);
                 }
                 else
                 {
                     //删除
                     RemoveView(view.SelectObjectTag);
                 }
             };
             //Close Event
             view.CloseTab += (x, y) => { RemoveView(view.SelectObjectTag); };
         }
     }
     else
     {
         //Close Event
         view.CloseTab += (x, y) => { RemoveView(view.SelectObjectTag); };
     }
     tabpage.Text = tabPageTitle;
     tabpage.Tag = view.SelectObjectTag;
     tabpage.ToolTipText = view.SelectObjectTag;
     view.Dock = DockStyle.Fill;
     tabpage.Controls.Add(view);
     ViewTabContain.TabPages.Add(tabpage);
     ViewTabContain.SelectTab(tabpage);
     ExistTabPage.Add(key, tabpage);
     RefreshMenuItem();
 }