public void PerformCloseButtonClick(TabStripButton button) { if (button.CanClose) { OnCloseButtonClicked(new ToolStripItemEventArgs(button)); } }
private void SetSelectedTab(TabStripButton value, bool force) { if (force || (_selectedTab != value)) { if (!force) { var e = new CancelEventArgs(); OnSelectedTabChanging(e); if (e.Cancel) { return; } } _selectedIndex = -1; _selectedTab = value; int index = 0; foreach (var tab in ItemsOfType <TabStripButton>()) { if (tab == _selectedTab) { _selectedIndex = index; } tab.Checked = (tab == _selectedTab); ++index; } PerformLayout(); OnSelectedTabChanged(EventArgs.Empty); } }
private int GetDropTabIndex(TabStripButton tabOver, Point pt) { if (tabOver == null) { return(-1); } var tabPt = GetPointRelativeTo(tabOver, pt); var tabOverIndex = _owner.Items.IndexOf(tabOver); var draggedTabIndex = _owner.Items.IndexOf(_draggedTab); bool isOnFarSide = false; if (_owner.RightToLeft == RightToLeft.Yes) { isOnFarSide = (tabPt.X <= (tabOver.Width * (1 - LeftRightRatio))); } else { isOnFarSide = (tabPt.X > (tabOver.Width * LeftRightRatio)); } if (isOnFarSide && (_draggedTab != tabOver)) { return(tabOverIndex + 1); } else if (tabOverIndex == draggedTabIndex + 1) { return(draggedTabIndex); } return(tabOverIndex); }
private void AddRange(IList <AeroTabPage> pages) { //BeginUpdate(); //try //{ var buttons = new TabStripButton[pages.Count]; for (int i = 0; i < pages.Count; ++i) { pages[i].Visible = false; pages[i].Dock = DockStyle.Fill; buttons[i] = pages[i].TabStripButton; } _pages.AddRange(pages); _tabStrip.SuspendLayout(); _tabStrip.Items.AddRange(buttons); _tabStrip.ResumeLayout(); UpdateTabStripVisibility(); //} //finally //{ // EndUpdate(); //} }
private void EndDrag() { if (_draggedTab != null) { _draggedTab = null; _draggedTabIndex = -1; _owner.TabInsertionPoint = -1; _owner.Capture = false; Cursor.Current = Cursors.Default; } }
public TabListDropDownMenuItem(TabStripButton button) : base(button.Text) { _button = button; if (button == button.Owner.SelectedTab) { Checked = true; Font = new Font(Font, FontStyle.Bold); } else { Image = button.Image; } }
public CloseButtonAccessibleObject(TabStripButton owner) { _owner = owner; }
public TabStripButtonAccessibleObject(TabStripButton button) : base(button) { _owner = button; }
public void WmMouseMove(IntPtr wParam, Point pt) { const int MK_LBUTTON = 0x1; if ((wParam.ToInt32() & MK_LBUTTON) == 0) { EndDrag(); return; } var mouseOverTab = GetTabAt(pt); if (mouseOverTab != null) { if (_lastMouseDown.HasValue) { int dx = Math.Abs(_lastMouseDown.Value.X - pt.X); int dy = Math.Abs(_lastMouseDown.Value.Y - pt.Y); if ((dx > SystemInformation.DragSize.Width) || (dy > SystemInformation.DragSize.Height)) { _draggedTab = mouseOverTab; _draggedTabIndex = _owner.Items.IndexOf(mouseOverTab); _lastMouseDown = null; } } } if (_draggedTab != null) { _owner.Capture = true; if (mouseOverTab != null) { Cursor.Current = TabDragCursor; var dropTabIndex = GetDropTabIndex(mouseOverTab, pt); if (dropTabIndex == _owner.Items.Count) { if (_owner.RightToLeft == RightToLeft.Yes) { _owner.TabInsertionPoint = _owner.Items[dropTabIndex - 1].Bounds.Left; } else { _owner.TabInsertionPoint = _owner.Items[dropTabIndex - 1].Bounds.Right - TabStripLayoutEngine.TabOverlap; } } else { if (_owner.RightToLeft == RightToLeft.Yes) { _owner.TabInsertionPoint = _owner.Items[dropTabIndex].Bounds.Right - TabStripLayoutEngine.TabOverlap; } else { _owner.TabInsertionPoint = _owner.Items[dropTabIndex].Bounds.Left; } } } else { Cursor.Current = Resources.Images.TabDropNA; _owner.TabInsertionPoint = -1; } } }