private void OnDeleteGallery(object sender, EventArgs e)
{
if ((_ribbonGallery != null) &&
(_ribbonGallery.Ribbon != null) &&
_ribbonGallery.RibbonGroup.Items.Contains(_ribbonGallery))
{
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupGallery DeleteGallery");
try
{
// Get access to the Items property
MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonGallery.RibbonGroup)["Items"];
// Remove the ribbon group from the ribbon tab
RaiseComponentChanging(null);
RaiseComponentChanging(propertyItems);
// Remove the gallery from the group
_ribbonGallery.RibbonGroup.Items.Remove(_ribbonGallery);
// Get designer to destroy it
_designerHost.DestroyComponent(_ribbonGallery);
RaiseComponentChanged(propertyItems, null, null);
RaiseComponentChanged(null, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}