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