ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupClusterDesigner.OnDeleteCluster C# (CSharp) Method

OnDeleteCluster() private method

private OnDeleteCluster ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnDeleteCluster(object sender, EventArgs e)
        {
            if ((_ribbonCluster != null) && (_ribbonCluster.Ribbon != null))
            {
                // Cast container to the correct type
                KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;

                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupTriple DeleteTriple");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(lines)["Items"];

                    // Remove the ribbon group from the ribbon tab
                    RaiseComponentChanging(null);
                    RaiseComponentChanging(propertyItems);

                    // Remove the cluster from the lines
                    lines.Items.Remove(_ribbonCluster);

                    // Get designer to destroy it
                    _designerHost.DestroyComponent(_ribbonCluster);

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