private void OnMovePrevious(object sender, EventArgs e)
        {
            if ((_ribbonNumericUpDown != null) && (_ribbonNumericUpDown.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("KryptonRibbonGroupNumericUpDown MovePrevious");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonNumericUpDown.RibbonContainer)["Items"];

                    RaiseComponentChanging(propertyItems);

                    // Move position of the numeric up-down
                    int index = items.IndexOf(_ribbonNumericUpDown) - 1;
                    index = Math.Max(index, 0);
                    items.Remove(_ribbonNumericUpDown);
                    items.Insert(index, _ribbonNumericUpDown);
                    UpdateVerbStatus();

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Esempio n. 2
0
        private void OnMoveNext(object sender, EventArgs e)
        {
            if (_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 MoveNext");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonCheckBox.RibbonContainer)["Items"];

                    RaiseComponentChanging(propertyItems);

                    // Move position of the triple
                    int index = items.IndexOf(_ribbonCheckBox) + 1;
                    index = Math.Min(index, items.Count - 1);
                    items.Remove(_ribbonCheckBox);
                    items.Insert(index, _ribbonCheckBox);
                    UpdateVerbStatus();

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }