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

OnAddGallery() private method

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

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

                    RaiseComponentChanging(propertyItems);

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

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