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

OnAddColorButton() private method

private OnAddColorButton ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnAddColorButton(object sender, EventArgs e)
        {
            if ((_ribbonCluster != null) && (_ribbonCluster.Ribbon != null))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupCluster AddColorButton");

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

                    RaiseComponentChanging(propertyItems);

                    // Get designer to create a cluster color button item
                    KryptonRibbonGroupClusterColorButton button = (KryptonRibbonGroupClusterColorButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupClusterColorButton));
                    _ribbonCluster.Items.Add(button);

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