KeePass.UI.CustomListViewEx.GetNextLvi C# (CSharp) Method

GetNextLvi() private method

private GetNextLvi ( System.Windows.Forms.ListViewGroup gBaseExcl, bool bUp ) : System.Windows.Forms.ListViewItem
gBaseExcl System.Windows.Forms.ListViewGroup
bUp bool
return System.Windows.Forms.ListViewItem
        private ListViewItem GetNextLvi(ListViewGroup gBaseExcl, bool bUp)
        {
            if(gBaseExcl == null) { Debug.Assert(false); return null; }

            int i = this.Groups.IndexOf(gBaseExcl);
            if(i < 0) { Debug.Assert(false); return null; }

            if(bUp)
            {
                --i;
                while(i >= 0)
                {
                    ListViewGroup g = this.Groups[i];
                    if(g.Items.Count > 0) return g.Items[g.Items.Count - 1];

                    --i;
                }
            }
            else // Down
            {
                ++i;
                int nGroups = this.Groups.Count;
                while(i < nGroups)
                {
                    ListViewGroup g = this.Groups[i];
                    if(g.Items.Count > 0) return g.Items[0];

                    ++i;
                }
            }

            return null;
        }