Ejemplo n.º 1
0
        private void OnMoveLast(object sender, EventArgs e)
        {
            if ((_ribbonTextBox != null) && (_ribbonTextBox.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("KryptonRibbonGroupTextBox MoveLast");

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

                    RaiseComponentChanging(propertyItems);

                    // Move position of the textbox
                    items.Remove(_ribbonTextBox);
                    items.Insert(items.Count, _ribbonTextBox);
                    UpdateVerbStatus();

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateVerbStatus()
        {
            // Create verbs first time around
            if (_verbs == null)
            {
                _verbs             = new DesignerVerbCollection();
                _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers));
                _moveFirstVerb     = new DesignerVerb("Move TextBox First", new EventHandler(OnMoveFirst));
                _movePrevVerb      = new DesignerVerb("Move TextBox Previous", new EventHandler(OnMovePrevious));
                _moveNextVerb      = new DesignerVerb("Move TextBox Next", new EventHandler(OnMoveNext));
                _moveLastVerb      = new DesignerVerb("Move TextBox Last", new EventHandler(OnMoveLast));
                _deleteTextBoxVerb = new DesignerVerb("Delete TextBox", new EventHandler(OnDeleteTextBox));
                _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb,
                                                     _moveNextVerb, _moveLastVerb, _deleteTextBoxVerb });
            }

            bool moveFirst = false;
            bool movePrev  = false;
            bool moveNext  = false;
            bool moveLast  = false;

            if ((_ribbonTextBox != null) && (_ribbonTextBox.Ribbon != null))
            {
                TypedRestrictCollection <KryptonRibbonGroupItem> items = ParentItems;
                moveFirst = (items.IndexOf(_ribbonTextBox) > 0);
                movePrev  = (items.IndexOf(_ribbonTextBox) > 0);
                moveNext  = (items.IndexOf(_ribbonTextBox) < (items.Count - 1));
                moveLast  = (items.IndexOf(_ribbonTextBox) < (items.Count - 1));
            }

            _moveFirstVerb.Enabled = moveFirst;
            _movePrevVerb.Enabled  = movePrev;
            _moveNextVerb.Enabled  = moveNext;
            _moveLastVerb.Enabled  = moveLast;
        }
Ejemplo n.º 3
0
        private void OnMoveNext(object sender, EventArgs e)
        {
            if (_ribbonColorButton?.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("KryptonRibbonGroupColorButton MoveNext");

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

                    RaiseComponentChanging(propertyItems);

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

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Ejemplo n.º 4
0
        private void OnDeleteButton(object sender, EventArgs e)
        {
            if (_ribbonColorButton?.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("KryptonRibbonGroupColorButton DeleteButton");

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

                    // Remove the ribbon group from the ribbon tab
                    RaiseComponentChanging(null);
                    RaiseComponentChanging(propertyItems);

                    // Remove the button from the group
                    items.Remove(_ribbonColorButton);

                    // Get designer to destroy it
                    _designerHost.DestroyComponent(_ribbonColorButton);

                    RaiseComponentChanged(propertyItems, null, null);
                    RaiseComponentChanged(null, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Ejemplo n.º 5
0
        private void UpdateVerbStatus()
        {
            // Create verbs first time around
            if (_verbs == null)
            {
                _verbs             = new DesignerVerbCollection();
                _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", OnToggleHelpers);
                _moveFirstVerb     = new DesignerVerb("Move Color Button First", OnMoveFirst);
                _movePrevVerb      = new DesignerVerb("Move Color Button Previous", OnMovePrevious);
                _moveNextVerb      = new DesignerVerb("Move Color Button Next", OnMoveNext);
                _moveLastVerb      = new DesignerVerb("Move Color Button Last", OnMoveLast);
                _deleteButtonVerb  = new DesignerVerb("Delete Color Button", OnDeleteButton);
                _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb,
                                                     _moveNextVerb, _moveLastVerb, _deleteButtonVerb });
            }

            bool moveFirst = false;
            bool movePrev  = false;
            bool moveNext  = false;
            bool moveLast  = false;

            if (_ribbonColorButton?.Ribbon != null)
            {
                TypedRestrictCollection <KryptonRibbonGroupItem> items = ParentItems;
                moveFirst = (items.IndexOf(_ribbonColorButton) > 0);
                movePrev  = (items.IndexOf(_ribbonColorButton) > 0);
                moveNext  = (items.IndexOf(_ribbonColorButton) < (items.Count - 1));
                moveLast  = (items.IndexOf(_ribbonColorButton) < (items.Count - 1));
            }

            _moveFirstVerb.Enabled = moveFirst;
            _movePrevVerb.Enabled  = movePrev;
            _moveNextVerb.Enabled  = moveNext;
            _moveLastVerb.Enabled  = moveLast;
        }