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

OnAddLines() private method

private OnAddLines ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnAddLines(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 AddLines");

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

                    RaiseComponentChanging(propertyItems);

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

                    // Get access to the Lines.Items property
                    MemberDescriptor propertyLinesItems = TypeDescriptor.GetProperties(lines)["Items"];

                    RaiseComponentChanging(propertyLinesItems);

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

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