/// <summary> /// When items are added to the tabs collection, we need to ensure that the <see cref="_parentWindow" />'s minimum width is set so that we can display at /// least each tab and its close buttons. /// </summary> /// <param name="sender">List of tabs in the <see cref="_parentWindow" />.</param> /// <param name="e">Arguments associated with the event.</param> private void Tabs_CollectionModified(object sender, ListModificationEventArgs e) { ListWithEvents <TitleBarTab> tabs = (ListWithEvents <TitleBarTab>)sender; if (tabs.Count == 0) { return; } int minimumWidth = tabs.Sum( tab => GetTabLeftImage(tab).Width + GetTabRightImage(tab).Width + (tab.ShowCloseButton ? tab.CloseButtonArea.Width + CloseButtonMarginLeft : 0)); minimumWidth += OverlapWidth; minimumWidth += (_parentWindow.ControlBox ? SystemInformation.CaptionButtonSize.Width : 0) - (_parentWindow.MinimizeBox ? SystemInformation.CaptionButtonSize.Width : 0) - (_parentWindow.MaximizeBox ? SystemInformation.CaptionButtonSize.Width : 0) + (ShowAddButton ? _addButtonImage.Width + AddButtonMarginLeft + AddButtonMarginRight : 0); _parentWindow.MinimumSize = new Size(minimumWidth, 0); }