private void OnMovePrevious(object sender, EventArgs e) { if ((_ribbonLabel != null) && (_ribbonLabel.Ribbon != null)) { // Get access to the parent collection of items TypedRestrictCollection <KryptonRibbonGroupItem> items = ParentItems; // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupLabel MovePrevious"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonLabel.RibbonContainer)["Items"]; RaiseComponentChanging(propertyItems); // Move position of the triple int index = items.IndexOf(_ribbonLabel) - 1; index = Math.Max(index, 0); items.Remove(_ribbonLabel); items.Insert(index, _ribbonLabel); UpdateVerbStatus(); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it transaction?.Commit(); } } }
private void OnMoveLast(object sender, EventArgs e) { if ((_ribbonCheckBox != null) && (_ribbonCheckBox.Ribbon != null)) { // Get access to the parent collection of items TypedRestrictCollection <KryptonRibbonGroupItem> items = ParentItems; // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupCheckBox MoveLast"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonCheckBox.RibbonContainer)["Items"]; RaiseComponentChanging(propertyItems); // Move position of the triple items.Remove(_ribbonCheckBox); items.Insert(items.Count, _ribbonCheckBox); UpdateVerbStatus(); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it if (transaction != null) { transaction.Commit(); } } } }