ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupDesigner.OnAddTriple C# (CSharp) Method

OnAddTriple() private method

private OnAddTriple ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnAddTriple(object sender, EventArgs e)
        {
            if ((_ribbonGroup != null) &&
                (_ribbonGroup.Ribbon != null) &&
                 _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup AddTriple");

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

                    RaiseComponentChanging(propertyItems);

                    // Get designer to create the new triple component
                    KryptonRibbonGroupTriple triple = (KryptonRibbonGroupTriple)_designerHost.CreateComponent(typeof(KryptonRibbonGroupTriple));
                    _ribbonGroup.Items.Add(triple);

                    // Get access to the Triple.Items property
                    MemberDescriptor propertyTripleItems = TypeDescriptor.GetProperties(triple)["Items"];

                    RaiseComponentChanging(propertyTripleItems);

                    // Get designer to create three new button components
                    KryptonRibbonGroupButton button1 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton));
                    KryptonRibbonGroupButton button2 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton));
                    KryptonRibbonGroupButton button3 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton));
                    triple.Items.Add(button1);
                    triple.Items.Add(button2);
                    triple.Items.Add(button3);

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