ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupClusterDesigner.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 ((_ribbonCluster != null) && (_ribbonCluster.Ribbon != null))
            {
                // Cast container to the correct type
                KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;

                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupCluster MovePrevious");

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

                    RaiseComponentChanging(propertyItems);

                    // Move position of the cluster
                    int index = lines.Items.IndexOf(_ribbonCluster) - 1;
                    index = Math.Max(index, 0);
                    lines.Items.Remove(_ribbonCluster);
                    lines.Items.Insert(index, _ribbonCluster);
                    UpdateVerbStatus();

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