private void OnMoveNext(object sender, EventArgs e)
{
if ((_ribbonCluster != null) && (_ribbonCluster.Ribbon != null))
{
// Cast container to the correct type
KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupCluster MoveNext");
try
{
// Get access to the Items property
MemberDescriptor propertyItems = TypeDescriptor.GetProperties(lines)["Items"];
RaiseComponentChanging(propertyItems);
// Move position of the cluster
int index = lines.Items.IndexOf(_ribbonCluster) + 1;
index = Math.Min(index, lines.Items.Count - 1);
lines.Items.Remove(_ribbonCluster);
lines.Items.Insert(index, _ribbonCluster);
UpdateVerbStatus();
RaiseComponentChanged(propertyItems, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}