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


C# SelectionHelper.SetLevelInfo方法代码示例

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


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

示例1: SetupSelectionForRangeAcrossBooks

        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetupSelectionForRangeAcrossBooks()
        {
            SelectionHelper selHelper = new SelectionHelper();
            selHelper.AssocPrev = true;
            selHelper.NumberOfLevels = 3;

            SelLevInfo[] anchorLevInfo = new SelLevInfo[3];
            anchorLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
            anchorLevInfo[2].ihvo = 1;
            anchorLevInfo[1].tag = ScrBookTags.kflidFootnotes;
            anchorLevInfo[1].ihvo = 31;
            anchorLevInfo[0].tag = StTextTags.kflidParagraphs;
            anchorLevInfo[0].ihvo = 0;
            selHelper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
            selHelper.IchAnchor = 1;

            SelLevInfo[] endLevInfo = new SelLevInfo[3];
            endLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
            endLevInfo[2].ihvo = 2;
            endLevInfo[1].tag = ScrBookTags.kflidFootnotes;
            endLevInfo[1].ihvo = 1;
            endLevInfo[0].tag = StTextTags.kflidParagraphs;
            endLevInfo[0].ihvo = 0;
            selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, endLevInfo);
            selHelper.IchEnd = 3;

            // Now that all the preparation to set the selection is done, set it.
            selHelper.SetSelection(m_footnoteView, true, true);
            Application.DoEvents();
        }
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:35,代码来源:FootnoteViewTests.cs

示例2: MergeParasInTable

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges the paras in table.
		/// </summary>
		/// <param name="helper">The helper.</param>
		/// <param name="dpt">The problem deletion type.</param>
		/// <returns><c>true</c> if we merged the paras, otherwise <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		internal protected bool MergeParasInTable(SelectionHelper helper, VwDelProbType dpt)
		{
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Top);
			if (levInfo[0].tag != (int)StText.StTextTags.kflidParagraphs)
				return false;

			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			IScrBook book = new ScrBook(m_cache, tracker.GetBookHvo(
				helper, SelectionHelper.SelLimitType.Anchor));

			SelLevInfo tmpInfo;
			IStText text;
			if (helper.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidTitle, out tmpInfo))
				text = book.TitleOA;
			else
			{
				IScrSection section = book.SectionsOS[tracker.GetSectionIndexInBook(
					helper,	SelectionHelper.SelLimitType.Anchor)];

				text = (levInfo[1].tag == (int)ScrSection.ScrSectionTags.kflidHeading ?
					section.HeadingOA :	text = section.ContentOA);
			}

			int iPara = helper.GetLevelInfoForTag((int)StText.StTextTags.kflidParagraphs).ihvo;
			StTxtPara currPara = (StTxtPara)text.ParagraphsOS[iPara];
			ITsStrBldr bldr;

			// Backspace at beginning of paragraph
			if (dpt == VwDelProbType.kdptBsAtStartPara)
			{
				if (iPara <= 0)
				{
					MiscUtils.ErrorBeep();
					return false;
				}

				StTxtPara prevPara = (StTxtPara)text.ParagraphsOS[iPara - 1];
				int prevParaLen = prevPara.Contents.Length;

				// Need to make sure we move the back translations
				AboutToDelete(helper, currPara.Hvo, text.Hvo,
					(int)StText.StTextTags.kflidParagraphs, iPara, false);

				bldr = prevPara.Contents.UnderlyingTsString.GetBldr();
				bldr.ReplaceTsString(prevPara.Contents.Length, prevPara.Contents.Length,
					currPara.Contents.UnderlyingTsString);
				prevPara.Contents.UnderlyingTsString = bldr.GetString();
				text.ParagraphsOS.RemoveAt(iPara);
				helper.SetIch(SelectionHelper.SelLimitType.Top, prevParaLen);
				helper.SetIch(SelectionHelper.SelLimitType.Bottom, prevParaLen);
				levInfo[0].ihvo = iPara - 1;
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Top, levInfo);
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Bottom, levInfo);
				helper.SetSelection(true);
				return true;
			}
			// delete at end of a paragraph
			int cParas = text.ParagraphsOS.Count;
			if (iPara + 1 >= cParas)
				return false; // We don't handle merging across StTexts

			StTxtPara nextPara = (StTxtPara)text.ParagraphsOS[iPara + 1];

			// Need to make sure we move the back translations
			AboutToDelete(helper, nextPara.Hvo, text.Hvo,
				(int)StText.StTextTags.kflidParagraphs, iPara + 1, false);

			bldr = currPara.Contents.UnderlyingTsString.GetBldr();
			bldr.ReplaceTsString(currPara.Contents.Length, currPara.Contents.Length,
				nextPara.Contents.UnderlyingTsString);
			currPara.Contents.UnderlyingTsString = bldr.GetString();
			text.ParagraphsOS.RemoveAt(iPara + 1);
			helper.SetSelection(true);
			return true;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:83,代码来源:TeEditingHelper.cs

示例3: MergeContentWithPreviousSection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges content of given section into the content of the previous section and then
		/// deletes the given section.
		/// </summary>
		/// <param name="helper"> </param>
		/// <param name="book"></param>
		/// <param name="section"></param>
		/// <param name="ihvoSection"></param>
		/// <param name="fPositionAtEnd">If true position of Selection is placed at end of
		/// paragraph, else at the beginning.</param>
		/// ------------------------------------------------------------------------------------
		private void MergeContentWithPreviousSection(SelectionHelper helper, ScrBook book,
			IScrSection section, int ihvoSection, bool fPositionAtEnd)
		{
			//REVIEW: Can the methods that call this be refactored
			//to use (a refactored?) ScrSection.MergeWithPreviousSection?
			//
			// Get the previous section and move the paragraphs.
			IScrSection sectionPrev = book.SectionsOS[ihvoSection - 1];
			IStText textPrev = sectionPrev.ContentOA;
			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			int iBook = tracker.GetBookIndex(helper, SelectionHelper.SelLimitType.Top);
			int cparaPrev = 0;
			if (textPrev == null)
			{
				// Prevent crash when dealing with corrupt database (TE-4869)
				// Since the previous section doesn't have a text, we simply move the entire text
				// object from the current section to the previous section.
				m_cache.ChangeOwner(section.ContentOAHvo, sectionPrev.Hvo,
					(int)ScrSection.ScrSectionTags.kflidContent);
			}
			else
			{
				cparaPrev = textPrev.ParagraphsOS.Count;
				IStText textOldContents = section.ContentOA;
				m_cache.MoveOwningSequence(textOldContents.Hvo, (int)StText.StTextTags.kflidParagraphs,
					0, textOldContents.ParagraphsOS.Count - 1,
					textPrev.Hvo, (int)StText.StTextTags.kflidParagraphs, cparaPrev);
			}
			// protected for some reason...textPrev.ParagraphsOS.Append(text.ParagraphsOS.HvoArray);
			book.SectionsOS.RemoveAt(ihvoSection);
			// Now we have to re-establish a selection. Whatever happens, it will be in the
			// same book as before, and the previous section, and in the body.
			if (InSectionHead || !fPositionAtEnd)
			{
				tracker.SetBookAndSection(helper, SelectionHelper.SelLimitType.Top, iBook,
					ihvoSection - 1);
				helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[1].tag =
					(int)ScrSection.ScrSectionTags.kflidContent;
			}
			Debug.Assert(helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[1].tag ==
				(int)ScrSection.ScrSectionTags.kflidContent);

			if (fPositionAtEnd)
			{
				// we want selection at end of last paragraph of old previous section.
				// (That is, at the end of paragraph cparaPrev - 1.)
				Debug.Assert(cparaPrev > 0);
				helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[0].ihvo = cparaPrev - 1;
				StTxtPara paraPrev = (StTxtPara)(textPrev.ParagraphsOS[cparaPrev - 1]);

				int cchParaPrev = paraPrev.Contents.Length;
				helper.IchAnchor = cchParaPrev;
				helper.IchEnd = cchParaPrev;
				helper.AssocPrev = true;
			}
			else
			{
				// want selection at start of old first paragraph of deleted section.
				// (That is, at the start of paragraph cparaPrev.)
				helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[0].ihvo = cparaPrev;
				helper.IchAnchor = 0;
				helper.IchEnd = 0;
				helper.AssocPrev = false;
			}
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Bottom,
				helper.GetLevelInfo(SelectionHelper.SelLimitType.Top));
			helper.SetSelection(true);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:80,代码来源:TeEditingHelper.cs

示例4: SelectRangeOfChars

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is the actual workhorse for all the above methods that allows a selection to
		/// be created.
		/// </summary>
		/// <param name="iBook">The 0-based index of the Scripture book in which to put the
		/// selection</param>
		/// <param name="iSection">The 0-based index of the Scripture section in which to put the
		/// selection</param>
		/// <param name="tag">Indicates whether selection should be made in the section
		/// Heading or Content or in the book title</param>
		/// <param name="isegment">If ContentType == segmentBT, the index of the segment
		/// in which to place the selection; otherwise ignored.</param>
		/// <param name="iPara">The 0-based index of the paragraph in which to put the insertion
		/// point</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <param name="fInstall"></param>
		/// <param name="fMakeVisible"></param>
		/// <param name="fAssocPrev">If an insertion point, does it have the properties of the
		/// previous character?</param>
		/// <param name="scrollOption">Where to scroll the selection</param>
		/// <returns>The selection helper</returns>
		/// ------------------------------------------------------------------------------------
		public SelectionHelper SelectRangeOfChars(int iBook, int iSection, int tag,
			int iPara, int isegment, int startCharacter, int endCharacter, bool fInstall, bool fMakeVisible,
			bool fAssocPrev, VwScrollSelOpts scrollOption)
		{
			CheckDisposed();

			if (Callbacks == null || Callbacks.EditedRootBox == null)
				return null;  // can't make a selection

			Debug.Assert(tag == (int)ScrSection.ScrSectionTags.kflidHeading ||
				tag == (int)ScrSection.ScrSectionTags.kflidContent ||
				tag == (int)ScrBook.ScrBookTags.kflidTitle);

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = ((ITeView)Control).LocationTracker.GetLevelCount(tag);
			int levelForPara = LocationTrackerImpl.GetLevelIndexForTag((int)StText.StTextTags.kflidParagraphs,
				m_contentType);

			selHelper.LevelInfo[levelForPara].ihvo = iPara;
			selHelper.LevelInfo[levelForPara + 1].tag = tag;

			((ITeView)Control).LocationTracker.SetBookAndSection(selHelper,
				SelectionHelper.SelLimitType.Anchor, iBook,
				tag == (int)ScrBook.ScrBookTags.kflidTitle ? -1 : iSection);

			if (ContentType == StVc.ContentTypes.kctSimpleBT)
			{
				int levelForBT = LocationTrackerImpl.GetLevelIndexForTag((int)StTxtPara.StTxtParaTags.kflidTranslations,
					m_contentType);
				selHelper.LevelInfo[levelForBT].tag = -1;
				selHelper.LevelInfo[levelForBT].ihvo = 0;
				selHelper.LevelInfo[levelForPara].tag = (int)StText.StTextTags.kflidParagraphs;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					(int)CmTranslation.CmTranslationTags.kflidTranslation);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					(int)CmTranslation.CmTranslationTags.kflidTranslation);
			}
			else if (ContentType == StVc.ContentTypes.kctSegmentBT)
			{
				// In all segment BT views, under the paragraph there is a segment, and under that
				// an object which is the free translation itself.
				selHelper.LevelInfo[2].tag = (int) StText.StTextTags.kflidParagraphs; // JohnT: why don't we need this for non-BT??
				selHelper.LevelInfo[1].ihvo = isegment;
				selHelper.LevelInfo[1].tag = StTxtPara.SegmentsFlid(Cache);
				selHelper.LevelInfo[0].ihvo = 0; // not a sequence.
				selHelper.LevelInfo[0].tag = StTxtPara.SegmentFreeTranslationFlid(Cache);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					(int)CmAnnotation.CmAnnotationTags.kflidComment);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					(int)CmAnnotation.CmAnnotationTags.kflidComment);
			}
			// else	selHelper.LevelInfo[0].tag is set automatically by SelectionHelper class

			selHelper.AssocPrev = fAssocPrev;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, fInstall,
				fMakeVisible, scrollOption);

			// If the selection fails, then try selecting the user prompt.
			if (vwsel == null)
			{
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, SimpleRootSite.kTagUserPrompt);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, SimpleRootSite.kTagUserPrompt);
				vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, fInstall, fMakeVisible,
					scrollOption);
			}

			if (vwsel == null)
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:TeEditingHelper.cs

示例5: MakeSelectionInPictureCaption

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Makes a selection in a picture caption.
		/// </summary>
		/// <param name="iBook">The 0-based index of the Scripture book in which to put the
		/// insertion point</param>
		/// <param name="iSection">The 0-based index of the Scripture section in which to put the
		/// insertion point</param>
		/// <param name="tag">Indicates whether the picture ORC is in the section
		/// Heading or Content, the book title</param>
		/// <param name="iPara">The 0-based index of the paragraph containing the ORC</param>
		/// <param name="ichOrcPos">The character position of the orc in the paragraph.</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <exception cref="Exception">Requested selection could not be made in the picture
		/// caption.</exception>
		/// ------------------------------------------------------------------------------------
		public void MakeSelectionInPictureCaption(int iBook, int iSection, int tag,
			int iPara, int ichOrcPos, int startCharacter, int endCharacter)
		{
			CheckDisposed();

			if (Callbacks == null || Callbacks.EditedRootBox == null)
				throw new Exception("Requested selection could not be made in the picture caption.");

			Debug.Assert(tag == (int)ScrSection.ScrSectionTags.kflidHeading ||
				tag == (int)ScrSection.ScrSectionTags.kflidContent ||
				tag == (int)ScrBook.ScrBookTags.kflidTitle);
			Debug.Assert(!IsBackTranslation, "ENHANCE: This code not designed to make a selection in the BT of a picture caption");

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = ((ITeView)Control).LocationTracker.GetLevelCount(tag) + 1;
			int levelForPara = LocationTrackerImpl.GetLevelIndexForTag(
				(int)StText.StTextTags.kflidParagraphs, StVc.ContentTypes.kctNormal) + 1;
			int levelForCaption = LocationTrackerImpl.GetLevelIndexForTag(
				(int)CmPicture.CmPictureTags.kflidCaption, StVc.ContentTypes.kctNormal);
			selHelper.LevelInfo[levelForCaption].ihvo = -1;
			selHelper.LevelInfo[levelForCaption].ich = ichOrcPos;
			selHelper.LevelInfo[levelForCaption].tag = (int)StTxtPara.StTxtParaTags.kflidContents;
			selHelper.Ws = m_cache.DefaultVernWs;
			selHelper.LevelInfo[levelForPara].tag = (int)StText.StTextTags.kflidParagraphs;
			selHelper.LevelInfo[levelForPara].ihvo = iPara;
			selHelper.LevelInfo[levelForPara + 1].tag = tag;

			((ITeView)Control).LocationTracker.SetBookAndSection(selHelper,
				SelectionHelper.SelLimitType.Anchor, iBook,
				tag == (int)ScrBook.ScrBookTags.kflidTitle ? -1 : iSection);

			selHelper.AssocPrev = true;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, (int)CmPicture.CmPictureTags.kflidCaption);
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, (int)CmPicture.CmPictureTags.kflidCaption);

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, true,
				true, VwScrollSelOpts.kssoDefault);

			if (vwsel == null)
				throw new Exception("Requested selection could not be made in the picture caption.");

			Application.DoEvents(); // REVIEW: Do we need this? Why?
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:68,代码来源:TeEditingHelper.cs

示例6: CanInsertNumberInElement_TrueAtStartOfScripture

		public void CanInsertNumberInElement_TrueAtStartOfScripture()
		{
			IScrBook book = AddBookToMockedScripture(1, "Gen");
			IScrSection section = AddSectionToMockedBook(book);
			IStTxtPara para = AddParaToMockedSectionContent(section, "bla");
			// Simulate IP in section content
			// TODO (TE-2740): Don't allow numbers to be inserted in intro material
			SelLevInfo[] levInfo = new SelLevInfo[2];
			levInfo[0].tag = ScrSectionTags.kflidContent;
			levInfo[0].hvo = para.Owner.Hvo; // arbitrary HVO to prevent assert in production code
			SelectionHelper helper = new SelectionHelper();
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, levInfo);
			helper.TextPropId = StTxtParaTags.kflidContents;

			m_TeEditingHelper.SelectionForTesting = helper;

			Assert.IsTrue(m_TeEditingHelper.CanInsertNumberInElement,
				"CanInsertNumberInElement should be true at the start of Scripture.");
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:19,代码来源:TeEditingHelperTests.cs

示例7: SelectRangeOfChars

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a range selection (adapted from TePrintLayout.cs).
		/// </summary>
		/// <param name="rootbox">The rootbox.</param>
		/// <param name="iPara">The 0-based index of the paragraph in which to put the insertion
		/// point</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <returns>The selection helper</returns>
		/// ------------------------------------------------------------------------------------
		private SelectionHelper SelectRangeOfChars(IVwRootBox rootbox, int iPara,
			int startCharacter, int endCharacter)
		{
			if (rootbox == null)
				return null;  // can't make a selection

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 1;

			selHelper.LevelInfo[0].ihvo = iPara;
			selHelper.LevelInfo[0].tag = (int)StText.StTextTags.kflidParagraphs;
			selHelper.AssocPrev = true;

			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(rootbox.Site, true, false,
				VwScrollSelOpts.kssoDefault);

			Assert.IsNotNull(vwsel);
			Application.DoEvents();

			return selHelper;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:41,代码来源:TePrintLayoutTests.cs

示例8: CanInsertNumberInElement_TrueAtStartOfScripture

		public void CanInsertNumberInElement_TrueAtStartOfScripture()
		{
			CheckDisposed();

			// Simulate IP in section content
			// TODO (TE-2740): Don't allow numbers to be inserted in intro material
			SelLevInfo[] levInfo = new SelLevInfo[2];
			levInfo[0].tag = (int)ScrSection.ScrSectionTags.kflidContent;
			levInfo[0].hvo = Cache.LangProject.Hvo; // arbitrary HVO to prevent assert in production code
			SelectionHelper helper = new SelectionHelper();
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, levInfo);
			m_TeEditingHelper.SelectionForTesting = helper;

			Assert.IsTrue(m_TeEditingHelper.CanInsertNumberInElement,
				"CanInsertNumberInElement should be true at the start of Scripture.");
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:16,代码来源:TeEditingHelperTests.cs

示例9: CanInsertNumberInElement_FalseInSectionHeading

		public void CanInsertNumberInElement_FalseInSectionHeading()
		{
			CheckDisposed();

			// Simulate IP in a section heading
			SelLevInfo[] levInfo = new SelLevInfo[2];
			levInfo[0].tag = (int)ScrSection.ScrSectionTags.kflidHeading;
			levInfo[0].hvo = Cache.LangProject.Hvo; // arbitrary HVO to prevent assert in production code
			SelectionHelper helper = new SelectionHelper();
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, levInfo);
			m_TeEditingHelper.SelectionForTesting = helper;

			Assert.IsFalse(m_TeEditingHelper.CanInsertNumberInElement,
				"CanInsertNumberInElement should be false in a section heading");
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:TeEditingHelperTests.cs

示例10: GetDisplayedTextForFootnote

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the displayed text for a footnote.
		/// </summary>
		/// <param name="iBook">Index of the book the footnote is in</param>
		/// <param name="iFootnote">Index of the footnote</param>
		/// <param name="footnote">The footnote object</param>
		/// <returns>The TsString representing the text of the footnote, including any displayed
		/// marker, reference, etc.</returns>
		/// ------------------------------------------------------------------------------------
		public ITsString GetDisplayedTextForFootnote(int iBook, int iFootnote,
			StFootnote footnote)
		{
			SelectionHelper helper = new SelectionHelper();

			// Create selection in footnote marker
			SelLevInfo[] anchorLevInfo = new SelLevInfo[4];
			anchorLevInfo[3].tag = BookFilter.Tag;
			anchorLevInfo[3].ihvo = iBook;
			anchorLevInfo[2].tag = (int)ScrBook.ScrBookTags.kflidFootnotes;
			anchorLevInfo[2].ihvo = iFootnote;
			anchorLevInfo[1].tag = (int)StText.StTextTags.kflidParagraphs;
			anchorLevInfo[1].ihvo = 0;
			anchorLevInfo[0].tag = -1;
			anchorLevInfo[0].ihvo = 0;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
			helper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
				(int)VwSpecialAttrTags.ktagGapInAttrs);
			helper.IchAnchor = 0;

			SelLevInfo[] endLevInfo = new SelLevInfo[3];
			endLevInfo[2].tag = BookFilter.Tag;
			endLevInfo[2].ihvo = iBook;
			endLevInfo[1].tag = (int)ScrBook.ScrBookTags.kflidFootnotes;
			endLevInfo[1].ihvo = iFootnote;
			endLevInfo[0].tag = (int)StText.StTextTags.kflidParagraphs;
			endLevInfo[0].ihvo = 0;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.End, endLevInfo);
			helper.SetTextPropId(SelectionHelper.SelLimitType.End,
				(int)StTxtPara.StTxtParaTags.kflidContents);
			string footnoteText = ((StTxtPara)footnote.ParagraphsOS[0]).Contents.Text;
			helper.IchEnd = footnoteText.Length;

			helper.SetSelection(this, true, true);

			IVwSelection sel = RootBox.Selection;
			ITsString tss;
			sel.GetSelectionString(out tss, string.Empty);
			return tss;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:50,代码来源:DummyFootnoteViewForm.cs

示例11: DeleteFootnoteFromContextMenuRangeSelection

		public void DeleteFootnoteFromContextMenuRangeSelection()
		{
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.AssocPrev = true;
			selHelper.NumberOfLevels = 3;

			SelLevInfo[] anchorLevInfo = new SelLevInfo[3];
			anchorLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
			anchorLevInfo[2].ihvo = 1;
			anchorLevInfo[1].tag = ScrBookTags.kflidFootnotes;
			anchorLevInfo[1].ihvo = 2;
			anchorLevInfo[0].tag = StTextTags.kflidParagraphs;
			anchorLevInfo[0].ihvo = 0;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
			selHelper.IchAnchor = 1;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, StTxtParaTags.kflidContents);

			SelLevInfo[] endLevInfo = new SelLevInfo[3];
			endLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
			endLevInfo[2].ihvo = 1;
			endLevInfo[1].tag = ScrBookTags.kflidFootnotes;
			endLevInfo[1].ihvo = 6;
			endLevInfo[0].tag = StTextTags.kflidParagraphs;
			endLevInfo[0].ihvo = 0;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, endLevInfo);
			selHelper.IchEnd = 7;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, StTxtParaTags.kflidContents);

			// Now that all the preparation to set the selection is done, set it.
			selHelper.SetSelection(m_footnoteView, true, true);
			Application.DoEvents();

			// First get the footnotes we're deleting.
			IScrFootnote[] footnotes = new IScrFootnote[5];
			Guid[] guidFootnotes = new Guid[5];
			IStTxtPara[] paras = new IStTxtPara[5];
			for (int i = 0; i < 5; i++)
			{
				footnotes[i] = Cache.ServiceLocator.GetInstance<IScrFootnoteRepository>().GetObject(m_Jude.FootnotesOS[i + 2].Hvo);
				guidFootnotes[i] = footnotes[i].Guid;
				paras[i] = footnotes[i].ParaContainingOrcRA;
			}

			m_footnoteView.DeleteFootnote();

			foreach (IScrFootnote footnote in footnotes)
				Assert.IsFalse(footnote.IsValidObject);

			// now make sure that we don't find the footnote markers
			for (int i = 0; i < 5; i++)
			{
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i]);
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i], m_wsEn);
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i], m_wsDe);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:56,代码来源:FootnoteViewTests.cs

示例12: MergeParasInTable

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges the paras in table.
		/// </summary>
		/// <param name="helper">The helper.</param>
		/// <param name="dpt">The problem deletion type.</param>
		/// <returns><c>true</c> if we merged the paras, otherwise <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		protected internal bool MergeParasInTable(SelectionHelper helper, VwDelProbType dpt)
		{
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Top);
			if (levInfo[0].tag != StTextTags.kflidParagraphs)
				return false;
			IStText text;
			int iPara;
			int tag;
			IStTxtPara currPara = GetPara(helper, out text, out iPara, out tag);

			// Backspace at beginning of paragraph
			ITsStrBldr bldr;
			if (dpt == VwDelProbType.kdptBsAtStartPara)
			{
				if (iPara <= 0)
				{
					MiscUtils.ErrorBeep();
					return false;
				}

				IStTxtPara prevPara = text[iPara - 1];
				int prevParaLen = prevPara.Contents.Length;

				prevPara.MergeParaWithNext();

				helper.SetIch(SelectionHelper.SelLimitType.Top, prevParaLen);
				helper.SetIch(SelectionHelper.SelLimitType.Bottom, prevParaLen);
				levInfo[0].ihvo = iPara - 1;
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Top, levInfo);
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Bottom, levInfo);
				if (DeferSelectionUntilEndOfUOW)
				{
					// We are within a unit of work, so setting the selection will not work now.
					// we request that a selection be made after the unit of work.
					Debug.Assert(!helper.IsRange,
						"Currently, a selection made during a unit of work can only be an insertion point.");
					helper.SetIPAfterUOW(EditedRootBox.Site);
				}
				else
				{
					helper.SetSelection(true);
				}
				return true;
			}
			// delete at end of a paragraph
			int cParas = text.ParagraphsOS.Count;
			if (iPara + 1 >= cParas)
				return false; // We don't handle merging across StTexts

			currPara.MergeParaWithNext();

			if (DeferSelectionUntilEndOfUOW)
			{
				// We are within a unit of work, so setting the selection will not work now.
				// we request that a selection be made after the unit of work.
				Debug.Assert(!helper.IsRange,
					"Currently, a selection made during a unit of work can only be an insertion point.");
				helper.SetIPAfterUOW(EditedRootBox.Site);
			}
			else
			{
				helper.SetSelection(true);
			}
			return true;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:73,代码来源:TeEditingHelper.cs

示例13: RequestSelectionAtEndOfUow

		/// --------------------------------------------------------------------------------
		/// <summary>
		/// In this simple implementation, we just record the information about the requested
		/// selection.
		/// </summary>
		/// <param name="rootb">The rootbox</param>
		/// <param name="ihvoRoot">Index of root element</param>
		/// <param name="cvlsi">count of levels</param>
		/// <param name="rgvsli">levels</param>
		/// <param name="tagTextProp">tag or flid of property containing the text (TsString)</param>
		/// <param name="cpropPrevious">number of previous occurrences of the text property</param>
		/// <param name="ich">character offset into the text</param>
		/// <param name="wsAlt">The id of the writing system for the selection.</param>
		/// <param name="fAssocPrev">Flag indicating whether to associate the insertion point
		/// with the preceding character or the following character</param>
		/// <param name="selProps">The selection properties.</param>
		/// --------------------------------------------------------------------------------
		public override void RequestSelectionAtEndOfUow(IVwRootBox rootb, int ihvoRoot,
			int cvlsi, SelLevInfo[] rgvsli, int tagTextProp, int cpropPrevious, int ich, int wsAlt,
			bool fAssocPrev, ITsTextProps selProps)
		{
			Assert.AreEqual(RootBox, rootb);
			Assert.IsNull(RequestedSelectionAtEndOfUow);

			RequestedSelectionAtEndOfUow = new SelectionHelper();
			RequestedSelectionAtEndOfUow.RootSite = this;
			RequestedSelectionAtEndOfUow.IhvoRoot = ihvoRoot;
			RequestedSelectionAtEndOfUow.NumberOfLevels = cvlsi;
			RequestedSelectionAtEndOfUow.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, rgvsli);
			RequestedSelectionAtEndOfUow.TextPropId = tagTextProp;
			RequestedSelectionAtEndOfUow.NumberOfPreviousProps = cpropPrevious;
			RequestedSelectionAtEndOfUow.IchAnchor = ich;
			RequestedSelectionAtEndOfUow.Ws = wsAlt;
			RequestedSelectionAtEndOfUow.AssocPrev = fAssocPrev;

			RootBox.DestroySelection(); // Need to act like real program in this regard
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:DummyDraftView.cs

示例14: ConvertBookTagAndIndex

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Convert the scripture book tag to a filter tag.  Also, convert book indices to
		/// filtered book indices.  This is done when loading a selection to make it work
		/// in the context of the book filter.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="selType"></param>
		/// ------------------------------------------------------------------------------------
		private void ConvertBookTagAndIndex(SelectionHelper helper,
			SelectionHelper.SelLimitType selType)
		{
			SelLevInfo[] info = helper.GetLevelInfo(selType);
			int bookPos = info.Length - 1;
			if (info[bookPos].tag == (int)Scripture.ScriptureTags.kflidScriptureBooks)
			{
				info[bookPos].tag = BookFilter.Tag;
				info[bookPos].ihvo = BookFilter.GetBookIndex(info[bookPos].hvo);
				helper.SetLevelInfo(selType, info);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:21,代码来源:DraftView.cs

示例15: ConvertBookTagAndIndex

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Convert the scripture book tag to a filter tag.  Also, convert book indices to
		/// filtered book indices.  This is done when loading a selection to make it work
		/// in the context of the book filter.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="selType"></param>
		/// ------------------------------------------------------------------------------------
		private void ConvertBookTagAndIndex(SelectionHelper helper,
			SelectionHelper.SelLimitType selType)
		{
			SelLevInfo[] info = helper.GetLevelInfo(selType);
			int bookPos = info.Length - 1;
			if (info[bookPos].tag == ScriptureTags.kflidScriptureBooks)
			{
				info[bookPos].tag = BookFilter.Tag;
				info[bookPos].ihvo = BookFilter.GetBookIndex(
					m_fdoCache.ServiceLocator.GetInstance<IScrBookRepository>().GetObject(info[bookPos].hvo));
				helper.SetLevelInfo(selType, info);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:22,代码来源:DraftView.cs


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