当前位置: 首页>>代码示例>>C#>>正文


C# SelectionHelper.GetLevelForTag方法代码示例

本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.GetLevelForTag方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.GetLevelForTag方法的具体用法?C# SelectionHelper.GetLevelForTag怎么用?C# SelectionHelper.GetLevelForTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SIL.FieldWorks.Common.RootSites.SelectionHelper的用法示例。


在下文中一共展示了SelectionHelper.GetLevelForTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshDiffViewHighlighting

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Refresh highlighted text in diff view.
		/// </summary>
		/// <param name="selHelper">selection used to get hvo of paragraph to notify for
		/// refreshing diff highlight</param>
		/// ------------------------------------------------------------------------------------
		private void RefreshDiffViewHighlighting(SelectionHelper selHelper)
		{
			if (selHelper != null)
			{
				int paraIndex = selHelper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
				NotifyParagraph(selHelper.LevelInfo[paraIndex].hvo);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:DiffDialog.cs

示例2: MoveToNextTranslation

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find and select the next translation meeting a given condition
		/// </summary>
		/// <param name="selection">The selection where to start the search.
		/// NOTE: The selection must have all of the info set in the LevelInfo (hvo, ihvo)</param>
		/// <param name="condition">Condition the cack translation must meet</param>
		/// ------------------------------------------------------------------------------------
		private void MoveToNextTranslation(SelectionHelper selection,
			Func<ICmTranslation, bool> condition)
		{
			SelLevInfo bookInfo;
			SelLevInfo paraInfo;
			SelLevInfo sectionInfo;
			bool fFoundBookLevel = selection.GetLevelInfoForTag(BookFilter.Tag, out bookInfo);
			bool fFoundSectionLevel = selection.GetLevelInfoForTag(
				ScrBookTags.kflidSections, out sectionInfo);
			int secLev = selection.GetLevelForTag(ScrBookTags.kflidSections);
			bool fFoundParaLevel = selection.GetLevelInfoForTag(
				StTextTags.kflidParagraphs, out paraInfo);

			if (!fFoundBookLevel || !fFoundParaLevel)
				return;

			// Look through all the books in the book filter
			int bookStartIndex = bookInfo.ihvo;
			int sectionStartIndex = 0;
			int sectionTag;
			int paraStartIndex = paraInfo.ihvo + 1;
			int paraIndex;

			if (fFoundSectionLevel)
			{
				// start with current section
				sectionStartIndex = sectionInfo.ihvo;
				sectionTag = selection.LevelInfo[secLev - 1].tag;
			}
			else
			{
				// no section, so this must be the title - Look through the title paragraphs
				IScrBook checkBook = BookFilter.GetBook(bookStartIndex);
				paraIndex = FindNextTranslationInText(checkBook.TitleOA, paraStartIndex, condition);
				if (paraIndex >= 0)
				{
					// select the title paragraph
					SetInsertionPoint(ScrBookTags.kflidTitle, bookStartIndex, 0, paraIndex);
					return;
				}
				// continue the search with the current book
				sectionTag = ScrSectionTags.kflidHeading;
				paraStartIndex = 0;
			}

			for (int bookIndex = bookStartIndex; bookIndex < BookFilter.BookCount; bookIndex++)
			{
				IScrBook checkBook = BookFilter.GetBook(bookIndex);
				if (bookIndex > bookStartIndex)
				{
					// Look through the title paragraphs
					paraIndex = FindNextTranslationInText(checkBook.TitleOA, 0, condition);
					if (paraIndex >= 0)
					{
						// select the title paragraph
						SetInsertionPoint(ScrBookTags.kflidTitle, bookIndex, 0, paraIndex);
						return;
					}
				}

				// Look through the sections in order.
				for (int sectionIndex = sectionStartIndex;
					sectionIndex < checkBook.SectionsOS.Count; sectionIndex++)
				{
					IScrSection checkSection = checkBook.SectionsOS[sectionIndex];

					// Look in the paragraphs (could be either content or heading)
					IStText text = (sectionTag == ScrSectionTags.kflidHeading) ?
						checkSection.HeadingOA : checkSection.ContentOA;
					paraIndex = FindNextTranslationInText(text, paraStartIndex, condition);
					if (paraIndex >= 0)
					{
						// select the paragraph
						SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
						return;
					}

					// Look in the content paragraphs, if we haven't already
					if (sectionTag == ScrSectionTags.kflidHeading)
					{
						sectionTag = ScrSectionTags.kflidContent;
						paraIndex = FindNextTranslationInText(checkSection.ContentOA, 0, condition);
						if (paraIndex >= 0)
						{
							// select the content paragraph
							SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
							return;
						}
					}

					sectionTag = ScrSectionTags.kflidHeading;
					paraStartIndex = 0;
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DraftView.cs

示例3: MoveToPrevTranslation

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find and select the previous translation with a given state
		/// </summary>
		/// <param name="selection">The selection where to start the search.
		/// NOTE: The selection must have all of the info set in the LevelInfo (hvo, ihvo)</param>
		/// <param name="searchStatus">Back translation status to search for</param>
		/// ------------------------------------------------------------------------------------
		private void MoveToPrevTranslation(SelectionHelper selection,
			BackTranslationStatus searchStatus)
		{
			SelLevInfo bookInfo;
			SelLevInfo paraInfo;
			SelLevInfo sectionInfo;
			bool fFoundBookLevel = selection.GetLevelInfoForTag(BookFilter.Tag, out bookInfo);
			bool fFoundSectionLevel = selection.GetLevelInfoForTag(
				ScrBookTags.kflidSections, out sectionInfo);
			int secLev = selection.GetLevelForTag(ScrBookTags.kflidSections);
			bool fFoundParaLevel = selection.GetLevelInfoForTag(
				StTextTags.kflidParagraphs, out paraInfo);

			if (!fFoundBookLevel || !fFoundParaLevel)
				return;

			// Look through all the books in the book filter
			int bookStartIndex = bookInfo.ihvo;
			int sectionStartIndex = -1;
			int sectionTag = ScrSectionTags.kflidContent;
			int paraStartIndex = paraInfo.ihvo - 1;
			int paraIndex;

			if (fFoundSectionLevel)
			{
				// start with current section
				sectionStartIndex = sectionInfo.ihvo;
				sectionTag = selection.LevelInfo[secLev - 1].tag;
			}
			else
			{
				// no section, so this must be the title - Look through the title paragraphs
				IScrBook checkBook = BookFilter.GetBook(bookStartIndex);
				paraIndex = FindPrevTranslationInText(checkBook.TitleOA, searchStatus,
					paraStartIndex);
				if (paraIndex >= 0)
				{
					// select the title paragraph
					SetInsertionPoint(ScrBookTags.kflidTitle, bookStartIndex, 0, paraIndex);
					return;
				}
				// continue the search with the previous book
				bookStartIndex--;
				paraStartIndex = -2;
			}

			for (int bookIndex = bookStartIndex; bookIndex >= 0 ; bookIndex--)
			{
				IScrBook checkBook = BookFilter.GetBook(bookIndex);
				if (sectionStartIndex == -1)
				{
					sectionStartIndex = checkBook.SectionsOS.Count - 1;
					sectionTag = ScrSectionTags.kflidContent;
				}

				// Look through the sections in reverse order.
				for (int sectionIndex = sectionStartIndex; sectionIndex >= 0; sectionIndex--)
				{
					IScrSection checkSection = checkBook.SectionsOS[sectionIndex];

					if (paraStartIndex == -2)
					{
						paraStartIndex = checkSection.ContentOA.ParagraphsOS.Count - 1;
						sectionTag = ScrSectionTags.kflidContent;
					}

					// Look in the paragraphs (could be either content or heading)
					IStText text = (sectionTag == ScrSectionTags.kflidHeading) ?
						checkSection.HeadingOA : checkSection.ContentOA;
					paraIndex = FindPrevTranslationInText(text, searchStatus, paraStartIndex);
					if (paraIndex >= 0)
					{
						// select the paragraph
						SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
						return;
					}

					// Look in the heading paragraphs, if we haven't already
					if (sectionTag == ScrSectionTags.kflidContent)
					{
						sectionTag = ScrSectionTags.kflidHeading;
						int startHeadPara = checkSection.HeadingOA.ParagraphsOS.Count - 1;
						paraIndex = FindPrevTranslationInText(checkSection.HeadingOA, searchStatus,
							startHeadPara);
						if (paraIndex >= 0)
						{
							// select the heading paragraph
							SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
							return;
						}
					}
					paraStartIndex = -2;
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DraftView.cs

示例4: IsMultiSectionContentSelection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine whether this is a selection that goes from the content of one section to
		/// the content of another.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="topInfo"></param>
		/// <param name="bottomInfo"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private bool IsMultiSectionContentSelection(SelectionHelper helper, SelLevInfo[] topInfo,
			SelLevInfo[] bottomInfo)
		{
			bool multiSectionSelection = false;
			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			int sectionTag = (int)ScrSection.ScrSectionTags.kflidContent;
			int clev = tracker.GetLevelCount(sectionTag);

			if (topInfo.Length == clev && bottomInfo.Length == clev)
			{
				int paraTag = (int)StText.StTextTags.kflidParagraphs;
				// if selection starts in content of section in one book and goes to content
				// of another section in the same book
				int sectionLevelTop = helper.GetLevelForTag(sectionTag, SelectionHelper.SelLimitType.Top);
				if (sectionLevelTop == -1)
					return false;

				if (tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Top) ==
					tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Bottom) &&
					tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Top) <
					tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Bottom) &&
					sectionLevelTop ==
					helper.GetLevelForTag(sectionTag, SelectionHelper.SelLimitType.Bottom) &&
					helper.GetLevelForTag(paraTag, SelectionHelper.SelLimitType.Top) ==
					helper.GetLevelForTag(paraTag, SelectionHelper.SelLimitType.Bottom))
				{
					multiSectionSelection = true;
				}
			}

			return multiSectionSelection;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:TeEditingHelper.cs

示例5: IsSectionHeadDeletion

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines if the selection starts at the beginning of the section head and ends at
		/// the beginning of the section content.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="topInfo"></param>
		/// <param name="bottomInfo"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private bool IsSectionHeadDeletion(SelectionHelper helper, SelLevInfo[] topInfo,
			SelLevInfo[] bottomInfo)
		{
			int levelText = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent);
			if (levelText < 0)
				levelText = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidHeading);
			if (levelText < 0)
				return false;

			bool sectionHeadDeletion = false;
			int levelPara = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			int clev = tracker.GetLevelCount((int)ScrSection.ScrSectionTags.kflidContent);

			if (topInfo.Length == clev && bottomInfo.Length == clev && levelPara >= 0)
			{
				if (tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Top) ==
					tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Bottom) &&
					tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Top) ==
					tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Bottom) &&
					topInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidHeading &&
					bottomInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidContent &&
					topInfo[levelText].ihvo == 0 &&
					bottomInfo[levelText].ihvo == 0 &&
					topInfo[levelPara].tag == (int)StText.StTextTags.kflidParagraphs &&
					bottomInfo[levelPara].tag == (int)StText.StTextTags.kflidParagraphs &&
					topInfo[levelPara].ihvo == 0 &&
					bottomInfo[levelPara].ihvo == 0)
				{
					sectionHeadDeletion = (helper.IchAnchor == 0 && helper.IchEnd == 0);
					if (sectionHeadDeletion)
					{
						StTxtPara para = new StTxtPara(m_cache, bottomInfo[levelPara].hvo);
						sectionHeadDeletion = (para.Contents.Text != null);
					}
				}
			}

			return sectionHeadDeletion;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:50,代码来源:TeEditingHelper.cs

示例6: IsSectionDeletion

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If a single section is wholly selected or the selection goes from the top of one
		/// section to the top of the following section, then the selected section may be
		/// deleted.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="topInfo"></param>
		/// <param name="bottomInfo"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private bool IsSectionDeletion(SelectionHelper helper, SelLevInfo[] topInfo,
			SelLevInfo[] bottomInfo)
		{
			bool sectionDeletion = false;
			ILocationTracker tracker = ((ITeView)Control).LocationTracker;

			int clev = tracker.GetLevelCount((int)ScrSection.ScrSectionTags.kflidContent);
			int levelText = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent);
			if (levelText < 0)
				levelText = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidHeading);
			int levelPara = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
			// the selection must be the right number of levels deep.
			if (topInfo.Length == clev && bottomInfo.Length == clev && levelText >= 0 && levelPara >= 0)
			{
				// if the selection is in the same scripture and the same book...
				if (tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Top) ==
					tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Bottom) &&
					// not selecting something weird
					topInfo[levelText - 1].tag == (int)StText.StTextTags.kflidParagraphs &&
					bottomInfo[levelText - 1].tag == (int)StText.StTextTags.kflidParagraphs)
				{
					// Selection top is in one section and bottom is in a following one
					if (tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Top) <=
						tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Bottom) - 1 &&
						// if the selection begins and ends in section heading
						topInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidHeading &&
						bottomInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidHeading &&
						topInfo[levelText].ihvo == 0 &&
						bottomInfo[levelText].ihvo == 0 &&
						// and the selection begins and ends in the first paragraph of those headings
						topInfo[levelPara].ihvo == 0 &&
						bottomInfo[levelPara].ihvo == 0)
					{
						// Does selection go from the beginning of one heading to the beginning of another?
						sectionDeletion = (helper.IchAnchor == 0 && helper.IchEnd == 0);
					}
					// Selection starts at beginning of one section heading and ends
					// at end of content of another section.
					else if (tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Top) <=
						tracker.GetSectionIndexInBook(helper, SelectionHelper.SelLimitType.Bottom) &&
						// Selection top is in section heading and bottom is in content
						topInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidHeading &&
						bottomInfo[levelText].tag == (int)ScrSection.ScrSectionTags.kflidContent &&
						topInfo[levelText].ihvo == 0 &&
						bottomInfo[levelText].ihvo == 0 &&
						// Top of selection is in first heading paragraph
						topInfo[levelPara].ihvo == 0)
					{
						int ichTop = helper.GetIch(SelectionHelper.SelLimitType.Top);
						sectionDeletion =
							ichTop == 0 && IsSelectionAtEndOfSection(helper, bottomInfo, clev);
					}
				}
			}
			return sectionDeletion;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:67,代码来源:TeEditingHelper.cs

示例7: IsSelectionAtEndOfSection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Selections at end of section.
		/// </summary>
		/// <param name="helper">The helper.</param>
		/// <param name="bottomInfo">The bottom info.</param>
		/// <param name="clev">The clev.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private bool IsSelectionAtEndOfSection(SelectionHelper helper, SelLevInfo[] bottomInfo,
			int clev)
		{
			bool atEndOfSection = false;
			// Is the bottom of the selection in the last para of the section?
			ScrSection bottomSection = new ScrSection(m_cache,
				((ITeView)Control).LocationTracker.GetSectionHvo(
				helper, SelectionHelper.SelLimitType.Bottom));

			IStText bottomContent = bottomSection.ContentOA;
			int levelPara = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
			if (bottomInfo[levelPara].ihvo == bottomContent.ParagraphsOS.Count - 1)
			{
				StTxtPara lastPara = new StTxtPara(m_cache, bottomInfo[levelPara].hvo);
				ITsString lastParaContents = lastPara.Contents.UnderlyingTsString;
				int ichBottom = helper.GetIch(SelectionHelper.SelLimitType.Bottom);
				atEndOfSection = ichBottom == lastParaContents.Length;
			}
			return atEndOfSection;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:29,代码来源:TeEditingHelper.cs

示例8: SurvivorParagraphHvo

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the Hvo of the surviving paragraph. This will be either the paragraph before
		/// the selected paragraph if we have an IP or the paragraph at the top of a range
		/// selection.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private int SurvivorParagraphHvo(SelectionHelper selHelper, IStText text, int ihvo, bool fMergeNext)
		{
			if (!selHelper.IsRange)
			{
				int iSurvivor = fMergeNext ? ihvo + 1 : ihvo - 1;
				return (iSurvivor >= 0 && iSurvivor < text.ParagraphsOS.Count ?
					text.ParagraphsOS.HvoArray[iSurvivor] : -1);
			}

			int paraLev = selHelper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs, SelectionHelper.SelLimitType.Top);
			SelLevInfo[] rgSelLevInfo = selHelper.GetLevelInfo(SelectionHelper.SelLimitType.Top);
			return rgSelLevInfo[paraLev].hvo;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:20,代码来源:TeEditingHelper.cs

示例9: HandleBsOrDelAtTextBoundary

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Try to do something about an IP selection deletion that is at the start or end of an
		/// StText. If successful return true, otherwise false.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="dpt"></param>
		/// <returns><c>true</c> if we successfully handled the deletion.</returns>
		/// ------------------------------------------------------------------------------------
		internal bool HandleBsOrDelAtTextBoundary(SelectionHelper helper, VwDelProbType dpt)
		{
			CheckDisposed();

			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);

			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			// bail out if we are not in a paragraph within a scripture section
			if (levInfo.Length !=
				tracker.GetLevelCount((int)ScrSection.ScrSectionTags.kflidContent) ||
				tracker.GetSectionIndexInView(helper, SelectionHelper.SelLimitType.Anchor) < 0 ||
				levInfo[0].tag != (int)StText.StTextTags.kflidParagraphs)
			{
				// Assume we are in a book title
				SelLevInfo dummyInfo;
				if (helper.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidTitle, out dummyInfo))
					return MergeParasInTable(helper, dpt);
				return false;
			}

			// Level 1 will have tags showing which field of section is selected
			int iLevelSection = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidHeading);
			if (iLevelSection >= 0)
			{
				if (levInfo[0].ihvo == 0 && dpt == VwDelProbType.kdptBsAtStartPara)
				{
					// first paragraph of section head
					return HandleBackspaceAfterEmptyContentParagraph(helper);
				}
				else if (levInfo[0].ihvo == 0 && helper.IchAnchor == 0)
				{
					// Delete was pressed in an empty section head - try to combine with previous
					// return DeleteSectionHead(helper, false, false);
					if (dpt == VwDelProbType.kdptBsAtStartPara)
						return HandleBackspaceAfterEmptySectionHeadParagraph(helper);
					return HandleDeleteBeforeEmptySectionHeadParagraph(helper);
				}
				// NOTE: we check the vector size for the parent of the paragraph (levInfo[1].hvo)
				// but with our own tag (levInfo[0].tag)!
				else if (levInfo[0].ihvo == m_cache.GetVectorSize(levInfo[iLevelSection].hvo,
					levInfo[0].tag) - 1
					&& dpt == VwDelProbType.kdptDelAtEndPara)
				{
					// last paragraph of section head
					return HandleDeleteBeforeEmptySectionContentParagraph(helper);
				}
				else
				{
					// other problem deletion: e.g. delete in BT side-by-side view. Because
					// we're displaying the paragraphs in a table with two columns, the views
					// code can't handle that. We have to merge the two paragraphs manually.
					return MergeParasInTable(helper, dpt);
				}
			}
			else if (helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent) >= 0)
			{
				iLevelSection = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent);
				if (levInfo[0].ihvo == 0 && dpt == VwDelProbType.kdptBsAtStartPara)
				{
					// first paragraph of section
					return HandleBackspaceAfterEmptySectionHeadParagraph(helper);
				}
				else if (levInfo[0].ihvo == 0 && helper.IchAnchor == 0)
				{
					// Delete was pressed in an empty section content - try to combine with previous
					if (dpt == VwDelProbType.kdptBsAtStartPara)
						return HandleBackspaceAfterEmptyContentParagraph(helper);
					return HandleDeleteBeforeEmptySectionContentParagraph(helper);
				}
				// NOTE: we check the vector size for the parent of the paragraph (levInfo[1].hvo)
				// but with our own tag (levInfo[0].tag)!
				else if (levInfo[0].ihvo == m_cache.GetVectorSize(levInfo[iLevelSection].hvo,
					levInfo[0].tag) - 1 && dpt == VwDelProbType.kdptDelAtEndPara)
				{
					// last paragraph of section
					return HandleDeleteBeforeEmptySectionHeadParagraph(helper);
				}
				else
				{
					// other problem deletion: e.g. delete in BT side-by-side view. Because
					// we're displaying the paragraphs in a table with two columns, the views
					// code can't handle that. We have to merge the two paragraphs manually.
					return MergeParasInTable(helper, dpt);
				}
			}
			return false;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:96,代码来源:TeEditingHelper.cs

示例10: GetSelectionReference

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets Scripture reference for a selection
		/// </summary>
		/// <param name="helper">The selection helper that represents the selection</param>
		/// <param name="fInclusive"><c>true</c> if the reference returned should include the
		/// reference of the text of the verse where the selection is, even if that selection
		/// is not at the start of the verse; <c>false</c> if the reference should be that of
		/// the first full verse at or following the selection</param>
		/// <param name="scriptureRef">returns the scripture reference found</param>
		/// <returns>A TsString representing the reference of the selection, or null if the
		/// selection represents a book title or something weird.</returns>
		/// ------------------------------------------------------------------------------------
		private ITsString GetSelectionReference(SelectionHelper helper, bool fInclusive,
			out BCVRef scriptureRef)
		{
			scriptureRef = new BCVRef();
			if (helper != null && m_page.Publication != null && m_page.Publication is ScripturePublication)
			{
				ScripturePublication scrPub = m_page.Publication as ScripturePublication;
				int iParaLevel = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
				if (iParaLevel >= 0)
				{
					ScrTxtPara para = new ScrTxtPara(m_cache, helper.LevelInfo[iParaLevel].hvo);
					// Look through the verses of the paragraph until we pass the location
					// where the page break occurs. This verse reference will then be the
					// first one on the page.
					ScrVerse firstVerseOnPage = null;
					int ichPageBreak = helper.IchAnchor;
					foreach (ScrVerse verse in para)
					{
						if (!fInclusive)
							firstVerseOnPage = verse;
						if (verse.VerseStartIndex > ichPageBreak ||
							(verse.VerseStartIndex == ichPageBreak && !fInclusive))
							break;
						if (fInclusive)
							firstVerseOnPage = verse;
					}

					ITsString tssBookName = GetBookName(helper);
					if (tssBookName != null)
					{
						ITsStrBldr bldr = tssBookName.GetBldr();
						int cch = bldr.Length;
						if (firstVerseOnPage != null)
						{
							if (firstVerseOnPage.StartRef.Verse != 0)
							{
								bldr.Replace(cch, cch, " " +
									((Scripture)m_scr).ChapterVerseRefAsString(firstVerseOnPage.StartRef, m_wsDefault), null);
							}
							scriptureRef = firstVerseOnPage.StartRef;
						}
						return bldr.GetString();
					}
					//else
					//{
					//    // Probably no verses were found in the paragraph
					//    IVwSelection sel = FindNextPara(helper);
					//    helper = SelectionHelper.Create(sel, helper.RootSite);

					//    return GetSelectionReference(helper, fInclusive, out scriptureRef);
					//}
				}
			}
			return null;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:68,代码来源:TeHeaderFooterVc.cs

示例11: FindFootnoteNearSelection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finds the nearest footnote before the given selection.
		/// </summary>
		/// <param name="helper">The selection helper.</param>
		/// <param name="book">The book that owns the footnote collection.</param>
		/// <param name="fSearchForward">True to also search forward within the current paragraph</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private StFootnote FindFootnoteNearSelection(SelectionHelper helper, IScrBook book,
			bool fSearchForward)
		{
			CheckDisposed();

			if (helper == null)
				helper = CurrentSelection;
			if (helper == null || book == null)
				return null;

			SelLevInfo[] levels = helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);

			int iParagraph = -1;
			int tag = 0;
			int ich = helper.IchAnchor;
			int paraLev = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
			int contentLev = helper.GetLevelForTag((int)StTxtPara.StTxtParaTags.kflidContents);

			Debug.Assert(paraLev != -1, "Need a paragraph for this method");
			iParagraph = levels[paraLev].ihvo;

			int iSection = ((ITeView)Control).LocationTracker.GetSectionIndexInBook(
				helper, SelectionHelper.SelLimitType.Anchor);

			if (iSection < 0)
				tag = (int)ScrBook.ScrBookTags.kflidTitle;
			else
			{
				tag = (helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent) >= 0 ?
					(int)ScrSection.ScrSectionTags.kflidContent :
					(int)ScrSection.ScrSectionTags.kflidHeading);
			}

			// Special case: if we're in the caption of a picture, get the ich from
			// the first level instead of the anchor. (TE-4696)
			if (contentLev >= 0 && levels[contentLev].ihvo == -1)
				ich = levels[contentLev].ich;

			ScrFootnote prevFootnote = null;
			if (fSearchForward) // look first at our current position, if we are searching foward
			{
				prevFootnote = ScrFootnote.FindCurrentFootnote(m_cache, book, iSection,
					iParagraph, ich, tag);
			}

			if (prevFootnote == null)
			{
				StTxtPara para = new StTxtPara(m_cache, levels[paraLev].hvo);
				ITsString tss = para.Contents.UnderlyingTsString;
				if (ich != 0)
				{
					// look backwards in our current paragraph
					prevFootnote = ScrFootnote.FindLastFootnoteInString(m_cache, tss, ref ich, true);
				}
				else if (iParagraph > 0)
				{
					// look at the previous paragraph for a footnote at the end
					StText text = new StText(m_cache, levels[paraLev + 1].hvo);
					StTxtPara prevPara = (StTxtPara)text.ParagraphsOS[iParagraph - 1];
					ITsString prevTss = prevPara.Contents.UnderlyingTsString;
					int ichTmp = -1;
					prevFootnote = ScrFootnote.FindLastFootnoteInString(m_cache, prevTss, ref ichTmp, false);
					if (prevFootnote != null)
					{
						if (ichTmp == prevTss.Length - 1)
							ich = ichTmp;
						else
							prevFootnote = null;
					}
					// ENHANCE: Look across contexts.
				}
			}
			if (prevFootnote == null && fSearchForward)
			{
				// look ahead in the same paragraph
				StTxtPara para = new StTxtPara(m_cache, levels[paraLev].hvo);
				ITsString tss = para.Contents.UnderlyingTsString;
				prevFootnote = ScrFootnote.FindFirstFootnoteInString(m_cache, tss, ref ich, true);
			}
			if (prevFootnote == null)
			{
				// just go back until we find one
				prevFootnote = ScrFootnote.FindPreviousFootnote(m_cache,
					book, ref iSection, ref iParagraph, ref ich, ref tag);
			}

			return prevFootnote;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:97,代码来源:TeEditingHelper.cs

示例12: GetSectionLevel

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the level for the section tag.
		/// </summary>
		/// <param name="selHelper">The selection helper.</param>
		/// <param name="selLimitType">Which end of the selection</param>
		/// <returns>The level for the section, or -1 if there is no section tag (e.g. in a
		/// title)</returns>
		/// ------------------------------------------------------------------------------------
		private int GetSectionLevel(SelectionHelper selHelper,
			SelectionHelper.SelLimitType selLimitType)
		{
			int sectionTag = -1;
			if (selHelper == TeEditingHelper.CurrentSelection && FocusedDivision != null)
			{
				TePrintLayoutConfig configurer =
					((DivisionLayoutMgr)FocusedDivision).Configurer as TePrintLayoutConfig;
				if (configurer != null)
					sectionTag = GetSectionTag(configurer);
			}

			if (sectionTag < 0 && selHelper.Selection != null && selHelper.Selection.RootBox != null)
			{
				int iDiv = DivisionIndexForMainStream(selHelper.Selection.RootBox as IVwLayoutStream);
				if (iDiv >= 0)
					sectionTag = GetSectionTag((TePrintLayoutConfig)Divisions[iDiv].Configurer);
			}

			if (sectionTag < 0)
				return -1;
			return selHelper.GetLevelForTag(sectionTag, selLimitType);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:32,代码来源:TePrintLayout.cs

示例13: FindFootnoteNearSelection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finds the nearest footnote before the given selection.
		/// </summary>
		/// <param name="helper">The selection helper.</param>
		/// <param name="book">The book that owns the footnote collection.</param>
		/// <param name="fSearchForward">True to also search forward within the current paragraph</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private IStFootnote FindFootnoteNearSelection(SelectionHelper helper, IScrBook book,
			bool fSearchForward)
		{
			CheckDisposed();

			if (helper == null)
				helper = CurrentSelection;
			if (helper == null || book == null)
				return null;

			SelLevInfo[] levels = helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);

			int iParagraph = -1;
			int tag = 0;
			int ich = helper.IchAnchor;
			int paraLev = helper.GetLevelForTag(StTextTags.kflidParagraphs);
			int contentLev = helper.GetLevelForTag(StTxtParaTags.kflidContents);

			Debug.Assert(paraLev != -1, "Need a paragraph for this method");
			iParagraph = levels[paraLev].ihvo;

			int iSection = ((ITeView)Control).LocationTracker.GetSectionIndexInBook(
				helper, SelectionHelper.SelLimitType.Anchor);

			if (iSection < 0)
				tag = ScrBookTags.kflidTitle;
			else
			{
				tag = (helper.GetLevelForTag(ScrSectionTags.kflidContent) >= 0 ?
					ScrSectionTags.kflidContent : ScrSectionTags.kflidHeading);
			}

			// Special case: if we're in the caption of a picture, get the ich from
			// the first level instead of the anchor. (TE-4696)
			if (contentLev >= 0 && levels[contentLev].ihvo == -1)
				ich = levels[contentLev].ich;

			IScrFootnote prevFootnote = null;
			if (fSearchForward) // look first at our current position, if we are searching foward
				prevFootnote = book.FindCurrentFootnote(iSection, iParagraph, ich, (int)tag);

			if (prevFootnote == null)
			{
				IScrTxtPara para = m_repoScrTxtPara.GetObject(levels[paraLev].hvo);
				ITsString tss = para.Contents;
				if (ich != 0)
				{
					// look backwards in our current paragraph - skip the current run, except when
					// at the end of the text.
					prevFootnote = para.FindPrevFootnoteInContents(ref ich, ich < tss.Length);
				}
				else if (iParagraph > 0)
				{
					// look at the previous paragraph for a footnote at the end
					IStText text = m_repoStText.GetObject(levels[paraLev + 1].hvo);
					IScrTxtPara prevPara = (IScrTxtPara)text[iParagraph - 1];
					ITsString prevTss = prevPara.Contents;
					int ichTmp = -1;
					prevFootnote = prevPara.FindPrevFootnoteInContents(ref ichTmp, false);
					if (prevFootnote != null)
					{
						if (ichTmp == prevTss.Length - 1)
							ich = ichTmp;
						else
							prevFootnote = null;
					}
					// ENHANCE: Look across contexts.
				}
			}
			if (prevFootnote == null && fSearchForward)
			{
				// look ahead in the same paragraph
				IScrTxtPara para = m_repoScrTxtPara.GetObject(levels[paraLev].hvo);
				ITsString tss = para.Contents;
				prevFootnote = para.FindNextFootnoteInContents(ref ich, true);
			}
			if (prevFootnote == null)
			{
				// just go back until we find one
				prevFootnote = book.FindPrevFootnote(ref iSection, ref iParagraph, ref ich, ref tag);
			}

			return prevFootnote;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:93,代码来源:TeEditingHelper.cs

示例14: GetPara

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets an StTxtPara representing the paragraph of the given selection.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private IStTxtPara GetPara(SelectionHelper helper, out IStText text, out int iPara, out int tag)
		{
			SelLevInfo paraLevInfo;
			if (!helper.GetLevelInfoForTag(StTextTags.kflidParagraphs, out paraLevInfo))
			{
				text = null;
				iPara = tag = -1;
				return null;
			}
			iPara = paraLevInfo.ihvo;

			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			IScrBook book = tracker.GetBook(helper, SelectionHelper.SelLimitType.Top);

			IScrSection section = tracker.GetSection(helper, SelectionHelper.SelLimitType.Top);

			if (section == null)
			{
				text = book.TitleOA;
				tag = ScrBookTags.kflidTitle;
			}
			else
			{
				tag = (helper.GetLevelForTag(ScrSectionTags.kflidContent) >= 0 ?
					ScrSectionTags.kflidContent : ScrSectionTags.kflidHeading);
				text = (tag == ScrSectionTags.kflidHeading ? section.HeadingOA : section.ContentOA);
			}

			return text[iPara];
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:35,代码来源:TeEditingHelper.cs

示例15: RefreshDiffViewHighlighting

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Refresh highlighted text in diff view.
		/// </summary>
		/// <param name="selHelper">selection used to get hvo of paragraph to notify for
		/// refreshing diff highlight</param>
		/// ------------------------------------------------------------------------------------
		private void RefreshDiffViewHighlighting(SelectionHelper selHelper)
		{
			if (selHelper != null)
			{
				int paraIndex = selHelper.GetLevelForTag(StTextTags.kflidParagraphs);
				IScrTxtPara para = m_cache.ServiceLocator.GetInstance<IScrTxtParaRepository>()
					.GetObject(selHelper.LevelInfo[paraIndex].hvo);
				NotifyParagraph(para, selHelper.RootSite.RootBox);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:DiffDialog.cs


注:本文中的SIL.FieldWorks.Common.RootSites.SelectionHelper.GetLevelForTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。