ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupLinesDesigner.OnMovePrevious C# (CSharp) Method

OnMovePrevious() private method

private OnMovePrevious ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnMovePrevious(object sender, EventArgs e)
        {
            if ((_ribbonLines != null) &&
                (_ribbonLines.Ribbon != null) &&
                 _ribbonLines.RibbonGroup.Items.Contains(_ribbonLines))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupLines MovePrevious");

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

                    RaiseComponentChanging(propertyItems);

                    // Move position of the triple
                    KryptonRibbonGroup ribbonGroup = _ribbonLines.RibbonGroup;
                    int index = ribbonGroup.Items.IndexOf(_ribbonLines) - 1;
                    index = Math.Max(index, 0);
                    ribbonGroup.Items.Remove(_ribbonLines);
                    ribbonGroup.Items.Insert(index, _ribbonLines);
                    UpdateVerbStatus();

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