예제 #1
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            if (hoveredIndex != -1)
            {
                if (hoveringOverClose)
                {
                    DocumentTabClosingEventArgs args = new DocumentTabClosingEventArgs(tabs[hoveredIndex]);

                    TabClosing?.Invoke(this, args);

                    if (!args.Cancel)
                    {
                        RemoveTab(hoveredIndex);
                    }
                }
                else
                {
                    Select(hoveredIndex);
                }

                Invalidate();
            }
        }
예제 #2
0
        /// <summary>
        /// Trys clearing all tabs while checking if each one can be closed without interuption
        /// </summary>
        /// <returns>Weither there was an interuption</returns>
        public bool TryClearTabs()
        {
            while (tabs.Count != 0)
            {
                DocumentTabClosingEventArgs args = new DocumentTabClosingEventArgs(tabs[selectedIndex]);
                TabClosing?.Invoke(this, args);

                if (args.Cancel)
                {
                    return(false);
                }

                RemoveTab(selectedIndex);
            }

            return(true);
        }