SIL.FieldWorks.IText.InterlinDocForAnalysis.DetectDownMove C# (CSharp) Method

DetectDownMove() private method

Detect that downward movement out of this segment is needed. Considerations: Configured analysis lines preceed translation or note lines (currently). "Annotation" lines include translation lines (free and literal) and notes. Each translation or note in a diffeerent ws is a different line. Translations are stored in a segment as a multistring while notes are in a sequence of multistrings. Each note is repeated in each note line of a different ws. So, the IP may be in the last configured note, but not in the last note.
private DetectDownMove ( KeyEventArgs e, IEnumerable lines, int lineNum, ISegment curSeg, int curNoteIndex, bool isRightToLeft, WhichEnd where ) : bool
e System.Windows.Forms.KeyEventArgs The keyboard event being handled.
lines IEnumerable The configured interlinear lines in display order.
lineNum int The current line in lines that has the selection (or IP).
curSeg ISegment The segment that has the selection.
curNoteIndex int The note that is selected in the sequence.
isRightToLeft bool
where WhichEnd Indicates where the IP is in the selected text if any.
return bool
		private bool DetectDownMove(KeyEventArgs e, IEnumerable<InterlinLineSpec> lines, int lineNum,
			ISegment curSeg, int curNoteIndex, bool isRightToLeft, WhichEnd where)
		{
			var annotationsAfter = lines.Skip(lineNum + 1);
			bool hasFollowingAnnotation = false;
			if (annotationsAfter.Any()) // might not have any
			{
				bool hasNotesAfter = annotationsAfter.Any(line => line.Flid == InterlinLineChoices.kflidNote);
				hasFollowingAnnotation = HasVisibleTranslationOrNote(curSeg, annotationsAfter);
			}
			else
			{	// this is the last translation or note and it can't be a null note because it was selected
				bool noteIsLastAnnotation = LineChoices[LineChoices.Count - 1].Flid == InterlinLineChoices.kflidNote;
				hasFollowingAnnotation = noteIsLastAnnotation && curNoteIndex < curSeg.NotesOS.Count - 1;
			}
			bool hasDownMotion = (e.KeyCode == Keys.Down) ||
								 (TextIsRightToLeft ?
									(e.KeyCode == Keys.Left && (where == WhichEnd.Left || where == WhichEnd.Both)) :
									(e.KeyCode == Keys.Right && (where == WhichEnd.Right || where == WhichEnd.Both)));
			return hasDownMotion && !hasFollowingAnnotation;
		}
InterlinDocForAnalysis