private void OnMoveToGroup(object sender, EventArgs e)
{
if ((_ribbonSeparator != null) &&
(_ribbonSeparator.Ribbon != null) &&
_ribbonSeparator.RibbonGroup.Items.Contains(_ribbonSeparator))
{
// Cast to correct type
ToolStripMenuItem groupMenuItem = (ToolStripMenuItem)sender;
// Get access to the destination tab
KryptonRibbonGroup destination = (KryptonRibbonGroup)groupMenuItem.Tag;
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupSeparator MoveSeparatorToGroup");
try
{
// Get access to the Groups property
MemberDescriptor oldItems = TypeDescriptor.GetProperties(_ribbonSeparator.RibbonGroup)["Items"];
MemberDescriptor newItems = TypeDescriptor.GetProperties(destination)["Items"];
// Remove the ribbon tab from the ribbon
RaiseComponentChanging(null);
RaiseComponentChanging(oldItems);
RaiseComponentChanging(newItems);
// Remove group from current group
_ribbonSeparator.RibbonGroup.Items.Remove(_ribbonSeparator);
// Append to the new destination group
destination.Items.Add(_ribbonSeparator);
RaiseComponentChanged(newItems, null, null);
RaiseComponentChanged(oldItems, null, null);
RaiseComponentChanged(null, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}