lw_common.ui.note_ctrl.find_note_id_above_selection C# (CSharp) Method

find_note_id_above_selection() private method

private find_note_id_above_selection ( ) : string
return string
        private string find_note_id_above_selection() {
            if (notesCtrl.SelectedIndex < 0) {
                // nothing was selected
                if (notesCtrl.GetItemCount() > 0)
                    return (notesCtrl.GetItem(notesCtrl.GetItemCount() - 1).RowObject as note_item).note_id;
                return "";
            }

            var sel_note = notesCtrl.SelectedItem.RowObject as note_item;
            for ( int i = 0; i < notesCtrl.GetItemCount() - 1; ++i)
                if (notesCtrl.GetItem(i + 1).RowObject == sel_note)
                    return (notesCtrl.GetItem(i).RowObject as note_item).note_id ;

            if (notesCtrl.GetItemCount() > 0)
                return (notesCtrl.GetItem(notesCtrl.GetItemCount() - 1).RowObject as note_item).note_id;
            else
                return "";
        }