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

IsTranslationOrNoteNext() private method

Determines if a visible translation or note is the next line in the indicated direction (up or down).
private IsTranslationOrNoteNext ( int paragraphInd, ISegment seg, bool moveUp ) : bool
paragraphInd int The index of the current paragraph in the text.
seg ISegment The current segment in the paragraph.
moveUp bool true if moving up and left, false otherwise
return bool
		private bool IsTranslationOrNoteNext(int paragraphInd, ISegment seg, bool moveUp)
		{
			var para = (IStTxtPara)RootStText.ParagraphsOS[paragraphInd];
			Debug.Assert(para != null, "Tried to move to a null paragraph ind=" + paragraphInd);
			Debug.Assert(seg != null, "Tried to move to a null segment ind=" + seg.IndexInOwner + " in para " + paragraphInd);
			// get the "next" segment with a real analysis or real translation or note
			var lines = LineChoices.m_specs as IEnumerable<InterlinLineSpec>; // so we can use linq
			while (true)
			{
				AnalysisOccurrence realAnalysis;
				seg = GetNextSegment(para, seg, moveUp, out realAnalysis);
				if (seg == null)
					return false;
				bool hasVisibleAnnotations = HasVisibleTranslationOrNote(seg, lines);
				bool hasRealAnalysis = realAnalysis != null;
				if (moveUp)
				{
					if (hasVisibleAnnotations) // check translation or note first
						return true;
					if (hasRealAnalysis) // then analyses
						return false; // if there is a real one, don't go to an annotation
				}
				else
				{   // moving down
					if (hasRealAnalysis) // check analyses first
						return false; // if there is a real one, don't go to a translation or note
					if (hasVisibleAnnotations) // then check translations and notes
						return true;
				}
				// no translation or note, no real analyses, try the next segment
			}
		}
InterlinDocForAnalysis