private void OnAddGroup(object sender, EventArgs e)
{
if ((_ribbonTab != null) &&
(_ribbonTab.Ribbon != null) &&
_ribbonTab.Ribbon.RibbonTabs.Contains(_ribbonTab))
{
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonTab AddGroup");
try
{
// Get access to the Groups property
MemberDescriptor propertyGroups = TypeDescriptor.GetProperties(_ribbonTab)["Groups"];
RaiseComponentChanging(propertyGroups);
// Get designer to create the new group component
KryptonRibbonGroup group = (KryptonRibbonGroup)_designerHost.CreateComponent(typeof(KryptonRibbonGroup));
_ribbonTab.Groups.Add(group);
RaiseComponentChanged(propertyGroups, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}