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

GetFirstVisibleTranslationOrNoteFlid() private method

Gets the first visible (non-null and configured) translation or note line in the current segment.
private GetFirstVisibleTranslationOrNoteFlid ( ISegment segment, int &ws ) : int
segment ISegment The segment to get the translation or note flid from.
ws int The returned writing system for the line needed to identify it or -1.
return int
		internal int GetFirstVisibleTranslationOrNoteFlid(ISegment segment, out int ws)
		{
			var lines = LineChoices.m_specs as IEnumerable<InterlinLineSpec>;
			Debug.Assert(lines != null, "Interlinear line configurations not enumerable 2");
			var annotations = lines.SkipWhile(line => line.WordLevel);
			int tryAnnotationIndex = lines.Count() - annotations.Count();
			if (annotations.Count() > 0)
			{   // We want to select at the start of this translation or note if it is not a null note.
				bool isaNote = annotations.First().Flid == InterlinLineChoices.kflidNote;
				if (isaNote && segment.NotesOS.Count == 0)
				{   // this note is not visible - skip to the next non-note translation or note
					var otherAnnotations = annotations.SkipWhile(line => line.Flid == InterlinLineChoices.kflidNote);
					tryAnnotationIndex = lines.Count() - otherAnnotations.Count();
					if (otherAnnotations.Count() == 0)
						tryAnnotationIndex = -1; // no more translations or notes, go to an analysis in the next segment.
				}
			}
			else // no translations or notes to go to
				tryAnnotationIndex = -1;
			int tryAnnotationFlid = 0;
			ws = -1;
			if (tryAnnotationIndex > -1)
			{
				var lineSpec = lines.Skip(tryAnnotationIndex).First();
				tryAnnotationFlid = lineSpec.Flid;
				ws = lineSpec.WritingSystem;
			}
			return tryAnnotationFlid;
		}
InterlinDocForAnalysis