private void OnMoveToGroup(object sender, EventArgs e)
{
if ((_ribbonLines != null) &&
(_ribbonLines.Ribbon != null) &&
_ribbonLines.RibbonGroup.Items.Contains(_ribbonLines))
{
// 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("KryptonRibbonGroupLines MoveLinesToGroup");
try
{
// Get access to the Groups property
MemberDescriptor oldItems = TypeDescriptor.GetProperties(_ribbonLines.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
_ribbonLines.RibbonGroup.Items.Remove(_ribbonLines);
// Append to the new destination group
destination.Items.Add(_ribbonLines);
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();
}
}
}