Exemple #1
0
 void TabPage_TextChanged(object sender, EventArgs e)
 {
     if (sender is Control)
     {
         TabItem ti = TabBar.GetItemByTag(sender);
         if (ti != null)
         {
             ti.Text = ((Control)sender).Text;
         }
     }
 }
Exemple #2
0
        public MyTabControl()
        {
            TabBar = new TabBar();
            TabBar.SelectedItemChanged += TabBar_SelectedItemChanged;
            TabBar.Font = SystemFonts.MessageBoxFont;
            Controls.Add(TabBar);

            //ControlContainer = new Panel();
            //Controls.Add(ControlContainer);

            TabPages              = new XList <Control>();
            TabPages.ItemAdded   += new XListEventHandler <Control>(TabPages_ItemAdded);
            TabPages.ItemRemoved += new XListEventHandler <Control>(TabPages_ItemRemoved);
        }
Exemple #3
0
        void Initialize(TabBar tabBar, TabItem item)
        {
            Selected = tabBar.SelectedItem == item;
            Hover    = tabBar.HoverItem == item;
            Enabled  = item.Enabled;

            Bar         = tabBar;
            Item        = item;
            Padding     = tabBar.ItemPadding;
            IconSize    = tabBar.IconSize;
            HalfDisplay = tabBar.IsHalfDisplay(item);
            Font        = tabBar.Font;

            if (!Enabled)
            {
                Status = UIControlStatus.Disabled;
            }
            else if (Selected)
            {
                if (tabBar.Focused)
                {
                    Status = UIControlStatus.Focused;
                }
                else
                {
                    Status = UIControlStatus.Selected;
                }
            }
            else if (Hover)
            {
                Status = UIControlStatus.Hover;
            }

            //
            CloseButtonStatus = UIControlStatus.Normal;
            if (item.CanClose)
            {
                if (tabBar.DownHitResult.Item == item && tabBar.DownHitResult.InCloseButton)
                {
                    CloseButtonStatus = UIControlStatus.Selected;
                }
                else if (tabBar.HoverHitResult.Item == item && tabBar.HoverHitResult.InCloseButton)
                {
                    CloseButtonStatus = UIControlStatus.Hover;
                }
            }
        }
Exemple #4
0
        void TabPages_ItemRemoved(object sender, XListEventArgs <Control> e)
        {
            if (e.Item != null)
            {
                TabItem item = TabBar.GetItemByTag(e.Item);
                if (item != null)
                {
                    TabBar.Items.Remove(item);
                }

                //
                if (Controls.Contains(e.Item))
                {
                    Controls.Remove(e.Item);
                }
                SelectNextPage(e.Index);
            }
        }
Exemple #5
0
        public TabsBox()
        {
            TabBar      = new TabBar();
            TabBar.Dock = DockStyle.Top;
            TabBar.ShowDropDownButton   = false;
            TabBar.ItemMinimumSize      = 50;
            TabBar.SelectedItemChanged += new EventHandler(TabBar_SelectedItemChanged);
            TabBar.ItemClose           += new TabItemEventHandler(TabBar_ItemClose);
            TabBar.ItemClosing         += new TabItemCancelEventHandler(TabBar_ItemClosing);
            Controls.Add(TabBar);

            ControlContainer         = new Panel();
            ControlContainer.Layout += new LayoutEventHandler(ControlContainer_Layout);
            Controls.Add(ControlContainer);

            TabPages              = new XList <Page>();
            TabPages.ItemAdded   += new XListEventHandler <Page>(TabPages_ItemAdded);
            TabPages.ItemRemoved += new XListEventHandler <Page>(TabPages_ItemRemoved);
        }
Exemple #6
0
        public void ActivePage(Control page)
        {
            if (page == null)
            {
                return;
            }

            TabBar.SelectByTag(page);
            SelectedIndex = ControlContainer.Controls.IndexOf(page);
            if (page.Bounds != ControlContainer.ClientRectangle)
            {
                page.Bounds = ControlContainer.ClientRectangle;
            }
            //page.Dock = DockStyle.Fill;

            foreach (Control control in ControlContainer.Controls)
            {
                control.Visible = control == page;
            }
        }
Exemple #7
0
        public void ActivePage(Control page)
        {
            if (page == null)
            {
                return;
            }

            if (TabBar.SelectByTag(page))
            {
                //HidePages();

                // 注意一下操作的顺序, 可以减少切换闪烁

                if (!Controls.Contains(page))
                {
                    page.Dock   = DockStyle.Fill;
                    page.Bounds = DisplayRectangle;
                    Controls.Add(page);
                }

                foreach (Control ctrl in Controls)
                {
                    if (ctrl != page && ctrl != TabBar)
                    {
                        Controls.Remove(ctrl);
                    }
                }

                if (this.ContainsFocus && !page.ContainsFocus && page.CanFocus)
                {
                    page.Focus();
                }

                SelectedIndex = TabPages.IndexOf(page);
            }
        }
 public TabItemCancelEventArgs(TabBar bar, TabItem item)
 {
     Bar  = bar;
     Item = item;
 }
Exemple #9
0
 public TabBarRenderer(TabBar bar)
 {
     Bar = bar;
 }
Exemple #10
0
 public TaskBarRenderer(TabBar bar)
     : base(bar)
 {
 }
Exemple #11
0
 public TabItemPaintEventArgs(Graphics graphics, TabBar tabBar, TabItem item)
     : base(graphics, Rectangle.Empty)
 {
     Initialize(tabBar, item);
 }
Exemple #12
0
 public TabItemPaintEventArgs(PaintEventArgs e, TabBar tabBar, TabItem item)
     : base(e.Graphics, e.ClipRectangle)
 {
     Initialize(tabBar, item);
 }
Exemple #13
0
 public NormalTabBarRenderer(TabBar bar)
     : base(bar)
 {
 }
Exemple #14
0
 public ColorTabBarRenderer(TabBar bar)
     : base(bar)
 {
 }