ComponentFactory.Krypton.Ribbon.KryptonRibbonTabDesigner.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 ((_ribbonTab != null) &&
                (_ribbonTab.Ribbon != null) &&
                 _ribbonTab.Ribbon.RibbonTabs.Contains(_ribbonTab))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonTab MoveNext");

                try
                {
                    // Get access to the RibbonTabs property
                    MemberDescriptor propertyTabs = TypeDescriptor.GetProperties(_ribbonTab.Ribbon)["RibbonTabs"];

                    RaiseComponentChanging(propertyTabs);

                    // Move position of the tab
                    KryptonRibbon ribbon = _ribbonTab.Ribbon;
                    int index = ribbon.RibbonTabs.IndexOf(_ribbonTab) - 1;
                    index = Math.Max(index, 0);
                    ribbon.RibbonTabs.Remove(_ribbonTab);
                    ribbon.RibbonTabs.Insert(index, _ribbonTab);
                    ribbon.SelectedTab = _ribbonTab;
                    UpdateVerbStatus();

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