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

GetLineInfo() private method

Assumes the selection data belongs to a translation or note! Gets the InterlinLineChoices flid (id) and a meaningful interpretation of where the IP is in the translation or note text. If an empty translation note was selected, its tag is kTagUserPrompt.
private GetLineInfo ( ISegment curSeg, INote curNote, int tag, int ichAnchor, int ichEnd, int wid, int &id, int &lineNum, WhichEnd &where, bool &isRightToLeft, bool &hasPrompt ) : bool
curSeg ISegment The selected segment to get the translation or note text from.
curNote INote null or the selected note
tag int The SegmentTags or NoteTags or kTagUserPrompt selected.
ichAnchor int The start index of the text selection.
ichEnd int The end index of the text selection.
wid int Index of the writing system of the selection.
id int The returned InterlinLineChoices flid.
lineNum int Configured line number of the translation or note.
where WhichEnd The returned meaningful interpretation of where the IP is in the translation or note text.
isRightToLeft bool is set to true if the Configured line is right to left, false otherwise.
hasPrompt bool is set to true if the line is an empty translation.
return bool
		private bool GetLineInfo(ISegment curSeg, INote curNote, int tag, int ichAnchor, int ichEnd, int wid,
						out int id, out int lineNum, out WhichEnd where, out bool isRightToLeft, out bool hasPrompt)
		{
			isRightToLeft = false;
			hasPrompt = false;
			var wsf = Cache.WritingSystemFactory;
			var ws = wsf.get_EngineOrNull(wid);
			if (ws != null)
				isRightToLeft = ws.RightToLeftScript;

			id = 0;
			lineNum = -1;
			where = WhichEnd.Neither;
			switch (tag)
			{
				case SegmentTags.kflidFreeTranslation:
					id = InterlinLineChoices.kflidFreeTrans;
					where = ExtremePositionInString(ichAnchor, ichEnd, curSeg.FreeTranslation.get_String(wid).Length, isRightToLeft);
					break;
				case SegmentTags.kflidLiteralTranslation:
					id = InterlinLineChoices.kflidLitTrans;
					where = ExtremePositionInString(ichAnchor, ichEnd, curSeg.LiteralTranslation.get_String(wid).Length, isRightToLeft);
					break;
				case NoteTags.kflidContent:
					Debug.Assert(curNote != null, "Moving from a non-exisiting note in interlinear Doc.");
					id = InterlinLineChoices.kflidNote;
					where = ExtremePositionInString(ichAnchor, ichEnd, curNote.Content.get_String(wid).Length, isRightToLeft);
					break;
				case kTagUserPrompt: // user prompt property for empty translation annotations
					// Is this free or literal?
					hasPrompt = true;
					id = m_vc.ActiveFreeformFlid;
					id = (id == SegmentTags.kflidLiteralTranslation) ?
						InterlinLineChoices.kflidLitTrans : InterlinLineChoices.kflidFreeTrans;
					if (wid == 0)
						wid = m_vc.ActiveFreeformWs;
					where = WhichEnd.Both;
					break;
				default: // not expected
					return false;
			}
			if (wid > 0)
				lineNum = LineChoices.IndexOf(id, wid);
			if (lineNum == -1)
				lineNum = LineChoices.IndexOf(id);
			return true;
		}
InterlinDocForAnalysis