SetIhvoRoot() public method

Sets the index of the root object for the given limit of the selection. This is 0 for views that don't display mutliple root objects).
public SetIhvoRoot ( SelLimitType type, int value ) : void
type SelLimitType
value int
return void
Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Navigate to the beginning of any Scripture element: Title, Section Head, or Section
		/// Content.
		/// </summary>
		/// <param name="tag">Indicates whether selection should be made in the title, section
		/// Heading or section Content</param>
		/// <param name="book">The 0-based index of the Scripture book in which to put the
		/// insertion point</param>
		/// <param name="section">The 0-based index of the Scripture section in which to put the
		/// insertion point. Ignored if tag is <see cref="ScrBook.ScrBookTags.kflidTitle"/></param>
		/// <param name="paragraph">The 0-based index of the paragraph which to put the
		/// insertion point.</param>
		/// <param name="character">index of character where insertion point will be set</param>
		/// <param name="fAssocPrev">True if the properties of the text entered at the new
		/// insertion point should be associated with the properties of the text before the new
		/// insertion point. False if text entered at the new insertion point should be
		/// associated with the text following the new insertion point.</param>
		/// <returns>True if it succeeded, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		public bool SetInsertionPoint(int tag, int book, int section, int paragraph, int character,
			bool fAssocPrev)
		{
			CheckDisposed();

			SelectionHelper selHelper = new SelectionHelper(); //SelectionHelper.Create(Callbacks.EditedRootBox.Site);// new SelectionHelper();
			int cLev;
			if (tag == (int)ScrBook.ScrBookTags.kflidTitle)
			{
				cLev = kBookTitleLevelCount;
				selHelper.NumberOfLevels = cLev;
				selHelper.LevelInfo[cLev - 1].tag = tag;
			}
			else
			{
				cLev = kSectionLevelCount;
				selHelper.NumberOfLevels = cLev;
				selHelper.LevelInfo[cLev - 1].tag = (int)ScrBook.ScrBookTags.kflidSections;
				selHelper.LevelInfo[cLev - 1].ihvo = section;
				selHelper.LevelInfo[cLev - 2].tag = tag;
			}
			selHelper.LevelInfo[0].ihvo = paragraph;
			selHelper.AssocPrev = fAssocPrev;

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

			selHelper.SetIhvoRoot(SelectionHelper.SelLimitType.Anchor, book);
			selHelper.SetIhvoRoot(SelectionHelper.SelLimitType.End, book);

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(this, true, true);

			// Now set the scroll position where the IP will be centered vertically.
			AutoScrollPosition = new Point(-AutoScrollPosition.X,
				-(AutoScrollPosition.Y - IPDistanceFromWindowTop(vwsel) + Height / 2));

			// If the selection is still not visible (which should only be the case if
			// we're at the end of the view), just take whatever MakeSelectionVisible()
			// gives us.
			if (!IsSelectionVisible(vwsel))
				ScrollSelectionIntoView(vwsel, VwScrollSelOpts.kssoDefault);

			if (vwsel == null)
				Debug.WriteLine("SetSelection failed in DiffView.SetInsertionPoint()");
			return (vwsel != null);
		}