private void initOpenButton() { btn_open = new Label(); btn_open.Text = "+"; btn_open.Font = new Font("Arial", 14.0f); btn_open.ForeColor = Color.Gray; btn_open.BackColor = Color.Transparent; btn_open.MouseEnter += (o, i) => { btn_open.ForeColor = Color.DarkGray; }; btn_open.MouseLeave += (o, i) => { btn_open.ForeColor = Color.Gray; }; btn_open.MouseUp += (o, i) => { if (Tabs.Count < MaxTabs) { SlickTab LastSelectedItem = SelectedItem; Add(DefaultCaption); SelectedIndex = Tabs.Count - 1; SelectedItem = Tabs[SelectedIndex]; Update(); if (OnSelect != null) { OnSelect.DynamicInvoke(SelectedItem, LastSelectedItem); } } }; Parent.Controls.Add(btn_open); }
public void Remove(int index) { if (SelectedIndex == index) { SlickTab LastSelectedItem = SelectedItem; SelectedItem = Tabs[--SelectedIndex]; Update(); if (OnSelect != null) { OnSelect.DynamicInvoke(SelectedItem, LastSelectedItem); } } Parent.Controls.Remove(Tabs[index].btn_x); Parent.Controls.Remove(Tabs[index].lbl_caption); Parent.Controls.Remove(Tabs[index].tab_bg); Tabs[index].Active = false; Tabs.RemoveAt(index); }
public void Remove(SlickTab tab) { if (SelectedItem == tab) { SlickTab LastSelectedItem = SelectedItem; SelectedItem = Tabs[--SelectedIndex]; Update(); if (OnSelect != null) { OnSelect.DynamicInvoke(SelectedItem, LastSelectedItem); } } Parent.Controls.Remove(tab.btn_x); Parent.Controls.Remove(tab.lbl_caption); Parent.Controls.Remove(tab.tab_bg); tab.Active = false; Tabs.Remove(tab); }
private SlickTab CreateBlankTab() { SlickTab slicktab = new SlickTab(); slicktab.btn_x.Font = new Font("Arial", 9.75f, FontStyle.Regular); slicktab.btn_x.Text = "x"; slicktab.btn_x.Size = new Size(18, 18); slicktab.btn_x.ForeColor = Color.White; slicktab.btn_x.MouseUp += (o, i) => { if (Tabs.Count > 1) { Remove(slicktab); Update(); } }; slicktab.btn_x.MouseEnter += (o, i) => { slicktab.btn_x.ForeColor = Color.Gray; }; slicktab.btn_x.MouseLeave += (o, i) => { slicktab.btn_x.ForeColor = Color.White; }; slicktab.lbl_caption.Font = new Font("Arial", 9.0f, FontStyle.Regular); slicktab.lbl_caption.ForeColor = Color.White; slicktab.lbl_caption.Size = new Size(80, 18); slicktab.SelectedColor = TabSelectedColor; slicktab.BackColor = TabBackColor; Parent.Controls.Add(slicktab.tab_bg); Parent.Controls.Add(slicktab.btn_x); Parent.Controls.Add(slicktab.lbl_caption); int current_index = Tabs.Count; if (current_index == 0) { SlickTab LastSelectedItem = SelectedItem; SelectedItem = slicktab; SelectedIndex = 0; if (OnSelect != null) { OnSelect.DynamicInvoke(slicktab, LastSelectedItem); } } slicktab.lbl_caption.BringToFront(); slicktab.btn_x.BringToFront(); slicktab.Update(X, Y); Tabs.Add(slicktab); slicktab.lbl_caption.MouseUp += (o, i) => { if (SelectedItem != slicktab) { SlickTab LastSelectedItem = SelectedItem; SelectedIndex = current_index; SelectedItem = slicktab; Update(); if (OnSelect != null) { OnSelect.DynamicInvoke(slicktab, LastSelectedItem); } } }; slicktab.tab_bg.MouseUp += (o, i) => { if (SelectedItem != slicktab) { SlickTab LastSelectedItem = SelectedItem; SelectedIndex = current_index; SelectedItem = slicktab; Update(); if (OnSelect != null) { OnSelect.DynamicInvoke(slicktab, LastSelectedItem); } } }; return(slicktab); }