private void OnMoveToTab(object sender, EventArgs e)
{
if ((_ribbonGroup != null) &&
(_ribbonGroup.Ribbon != null) &&
_ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup))
{
// Cast to correct type
ToolStripMenuItem tabMenuItem = (ToolStripMenuItem)sender;
// Get access to the destination tab
KryptonRibbonTab destination = (KryptonRibbonTab)tabMenuItem.Tag;
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup MoveTabTo");
try
{
// Get access to the Groups property
MemberDescriptor oldGroups = TypeDescriptor.GetProperties(_ribbonGroup.RibbonTab)["Groups"];
MemberDescriptor newGroups = TypeDescriptor.GetProperties(destination)["Groups"];
MemberDescriptor newGroupsTab = TypeDescriptor.GetProperties(_ribbonGroup.Ribbon)["RibbonTabs"];
// Remove the ribbon tab from the ribbon
RaiseComponentChanging(null);
RaiseComponentChanging(oldGroups);
RaiseComponentChanging(newGroups);
RaiseComponentChanging(newGroupsTab);
// Remove group from current group
_ribbonGroup.RibbonTab.Groups.Remove(_ribbonGroup);
// Append to the new destination group
destination.Groups.Add(_ribbonGroup);
RaiseComponentChanged(newGroupsTab, null, null);
RaiseComponentChanged(newGroups, null, null);
RaiseComponentChanged(oldGroups, null, null);
RaiseComponentChanged(null, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}