private void OnMoveLast(object sender, EventArgs e) { if ((_ribbonDateTimePicker != null) && (_ribbonDateTimePicker.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("KryptonRibbonGroupDateTimePicker MoveLast"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonDateTimePicker.RibbonContainer)["Items"]; RaiseComponentChanging(propertyItems); // Move position of the date time picker items.Remove(_ribbonDateTimePicker); items.Insert(items.Count, _ribbonDateTimePicker); UpdateVerbStatus(); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it if (transaction != null) { transaction.Commit(); } } } }
private void OnMoveNext(object sender, EventArgs e) { if (_ribbonButton?.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("KryptonRibbonGroupButton MoveNext"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonButton.RibbonContainer)["Items"]; RaiseComponentChanging(propertyItems); // Move position of the triple int index = items.IndexOf(_ribbonButton) + 1; index = Math.Min(index, items.Count - 1); items.Remove(_ribbonButton); items.Insert(index, _ribbonButton); UpdateVerbStatus(); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it transaction?.Commit(); } } }
private void OnDeleteButton(object sender, EventArgs e) { if (_ribbonButton?.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("KryptonRibbonGroupButton DeleteButton"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonButton.RibbonContainer)["Items"]; // Remove the ribbon group from the ribbon tab RaiseComponentChanging(null); RaiseComponentChanging(propertyItems); // Remove the button from the group items.Remove(_ribbonButton); // Get designer to destroy it _designerHost.DestroyComponent(_ribbonButton); RaiseComponentChanged(propertyItems, null, null); RaiseComponentChanged(null, null, null); } finally { // If we managed to create the transaction, then do it transaction?.Commit(); } } }
private void OnMovePrevious(object sender, EventArgs e) { if ((_ribbonMaskedTextBox != null) && (_ribbonMaskedTextBox.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("KryptonRibbonGroupMaskedTextBox MovePrevious"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonMaskedTextBox.RibbonContainer)["Items"]; RaiseComponentChanging(propertyItems); // Move position of the textbox int index = items.IndexOf(_ribbonMaskedTextBox) - 1; index = Math.Max(index, 0); items.Remove(_ribbonMaskedTextBox); items.Insert(index, _ribbonMaskedTextBox); UpdateVerbStatus(); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it if (transaction != null) { transaction.Commit(); } } } }