예제 #1
0
        void ExecuteAddTabPage(object sender, EventArgs e)
        {
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                System.Collections.ICollection selectedComps = selectionService.GetSelectedComponents();
                if (selectedComps != null && selectedComps.Count == 1)
                {
                    object[] comps = new object[selectedComps.Count];
                    int      i     = 0;
                    foreach (object obj in selectedComps)
                    {
                        comps[i] = obj;
                    }
                    TabControl tab = comps[0] as TabControl;
                    if (tab != null)
                    {
                        string title = "TabPage" + (tab.TabCount + 1).ToString();
                        tab.TabPages.Add(new TabPage(title));
                        tab.SelectedIndex = tab.TabPages.Count - 1;
                    }
                }
            }
        }
예제 #2
0
        void ExecuteRemoveTabPage(object sender, EventArgs e)
        {
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                System.Collections.ICollection selectedComps = selectionService.GetSelectedComponents();
                if (selectedComps != null && selectedComps.Count == 1)
                {
                    object[] comps = new object[selectedComps.Count];
                    selectedComps.CopyTo(comps, 0);
                    TabControl tab = comps[0] as TabControl;
                    if (tab != null && tab.TabPages.Count > 1)
                    {
                        tab.TabPages.Remove(tab.SelectedTab);
                    }
                }
            }
        }