void TabPage_TextChanged(object sender, EventArgs e) { if (sender is Control) { TabItem ti = TabBar.GetItemByTag(sender); if (ti != null) { ti.Text = ((Control)sender).Text; } } }
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); }
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; } } }
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); } }
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); }
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; } }
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; }
public TabBarRenderer(TabBar bar) { Bar = bar; }
public TaskBarRenderer(TabBar bar) : base(bar) { }
public TabItemPaintEventArgs(Graphics graphics, TabBar tabBar, TabItem item) : base(graphics, Rectangle.Empty) { Initialize(tabBar, item); }
public TabItemPaintEventArgs(PaintEventArgs e, TabBar tabBar, TabItem item) : base(e.Graphics, e.ClipRectangle) { Initialize(tabBar, item); }
public NormalTabBarRenderer(TabBar bar) : base(bar) { }
public ColorTabBarRenderer(TabBar bar) : base(bar) { }