ComponentFactory.Krypton.Ribbon.KryptonRibbonDesigner.OnClearTabs C# (CSharp) Method

OnClearTabs() private method

private OnClearTabs ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnClearTabs(object sender, EventArgs e)
        {
            // Use a transaction to support undo/redo actions
            DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbon ClearTabs");

            try
            {
                // Get access to the tabs property
                MemberDescriptor propertyPages = TypeDescriptor.GetProperties(_ribbon)["RibbonTabs"];

                RaiseComponentChanging(propertyPages);

                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all the tabs from the ribbon
                for (int i = _ribbon.RibbonTabs.Count - 1; i >= 0; i--)
                {
                    KryptonRibbonTab tab = _ribbon.RibbonTabs[i];
                    _ribbon.RibbonTabs.Remove(tab);
                    host.DestroyComponent(tab);
                }

                RaiseComponentChanged(propertyPages, null, null);
            }
            finally
            {
                // If we managed to create the transaction, then do it
                if (transaction != null)
                    transaction.Commit();

                UpdateVerbStatus();
            }
        }