private bool DetectUpMove(KeyEventArgs e, IEnumerable<InterlinLineSpec> lines, int lineNum,
ISegment curSeg, int curNoteIndex, WhichEnd where, bool isRightToLeft,
out bool isUpNewSeg)
{
var linesBefore = lines.Take(lineNum);
var annotationsBefore = linesBefore;
bool hasPreviousAnalysis = false;
if (linesBefore.Any()) // will have some lines if there are analyses
{
annotationsBefore = linesBefore.SkipWhile(line => line.WordLevel);
hasPreviousAnalysis = linesBefore.Any(line => line.WordLevel);
}
bool hasPrevAnnotation = false;
if (annotationsBefore.Any()) // if this is the first annotation, annotationsBefore is empty
{
bool hasNotesBefore = annotationsBefore.Any(line => line.Flid == InterlinLineChoices.kflidNote);
hasPrevAnnotation = HasVisibleTranslationOrNote(curSeg, annotationsBefore);
}
else
{ // this is the first translation or note and it can't be a null note because it was selected
bool noteIsFirstAnnotation = lines.ToArray()[lineNum].Flid == InterlinLineChoices.kflidNote;
hasPrevAnnotation = noteIsFirstAnnotation && curNoteIndex > 0; // can have notes or empty notes before it
}
bool hasUpMotion = (e.KeyCode == Keys.Up) ||
(TextIsRightToLeft ?
(e.KeyCode == Keys.Right && (where == WhichEnd.Right || where == WhichEnd.Both)) :
(e.KeyCode == Keys.Left && (where == WhichEnd.Left || where == WhichEnd.Both)));
bool isUpMove = hasUpMotion && !hasPrevAnnotation;
isUpNewSeg = isUpMove && !isThereRealAnalysisInSegment(curSeg); // no puctuation, or analysis ws
return isUpMove;
}