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


C# IVwSelection.Location方法代码示例

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


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

示例1: GetSelectionRectangle

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the selection rectangle (in printer pixels).
		/// </summary>
		/// <param name="vwsel">The selection.</param>
		/// <param name="vg">The VwGraphics object.</param>
		/// <param name="fEndBeforeAnchor"><c>true</c> if the end of the selection is before
		/// the anchor.</param>
		/// <returns>The rectangle of the selection in printer pixels.</returns>
		/// ------------------------------------------------------------------------------------
		internal Rectangle GetSelectionRectangle(IVwSelection vwsel, IVwGraphics vg,
			out bool fEndBeforeAnchor)
		{
			Rectangle rcSelPrinter;

			if (vwsel == null)
				vwsel = FocusedRootBox.Selection;

			if (vwsel == null)
			{
				Debug.Fail("Couldn't find a selection");
				fEndBeforeAnchor = false;
				return Rectangle.Empty;
			}

			// We pass this as source AND destination rectangle to get the selection
			// location relative to the whole document in printer coordinates.
			Rect rcSrc = new Rect(0, 0, (int)DpiXPrinter, (int)DpiYPrinter);
			// Main or only place the selection is (in printer coords,
			// relative to the rootbox!)
			// Secondary place if the selection is a split cursor.
			// true if it is split (if false, do NOT use rcSecondary, it is meaningless).

			// true if end of selection comes before anchor, so the BOTTOM is what
			// we want to be sure to see.
			Rect rcPrimary, rcSecondary;
			bool fSplit;
			vwsel.Location(vg, rcSrc, rcSrc, out rcPrimary, out rcSecondary, out fSplit,
				out fEndBeforeAnchor);
			rcSelPrinter = Rectangle.FromLTRB(rcPrimary.left, rcPrimary.top,
				rcPrimary.right, rcPrimary.bottom);
			int clientWidthPrinter = ConvertScreenDistanceToPrinterX(
				ClientRectangle.Width, DpiXScreen);
			int clientHeightPrinter = ConvertScreenDistanceToPrinterY(
				ClientRectangle.Height, DpiYScreen);
			if (fSplit)
			{
				// try to get the secondary in there also
				Rectangle rcSel2Printer = Rectangle.FromLTRB(
					Math.Min(rcSelPrinter.Left, rcSecondary.left),
					Math.Min(rcSelPrinter.Top, rcSecondary.top),
					Math.Max(rcSelPrinter.Right, rcSecondary.right),
					Math.Max(rcSelPrinter.Bottom, rcSecondary.bottom));
				if (rcSel2Printer.Width <= clientWidthPrinter &&
					rcSel2Printer.Height <= clientHeightPrinter)
					rcSelPrinter = rcSel2Printer;
			}

			return rcSelPrinter;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:60,代码来源:PublicationControl.cs

示例2: SetContextButtonPosition

		private void SetContextButtonPosition(IVwSelection sel, int ilineChoice)
		{
			Debug.Assert(sel != null || !sel.IsValid, "No selection!");
			//sel.GrowToWord();
			Rect rcPrimary;
			Rectangle rcSrcRoot;
			using (new HoldGraphics(this))
			{
				Rect rcSec;
				bool fSplit, fEndBeforeAnchor;
				Rectangle rcDstRoot;
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out rcPrimary,
					out rcSec, out fSplit, out fEndBeforeAnchor);
			}
			CalculateHorizContextButtonPosition(rcPrimary, rcSrcRoot);
			m_iLineChoice = ilineChoice;
			if (!Controls.Contains(m_contextButton))
				Controls.Add(m_contextButton);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:20,代码来源:InterlinDocRootSiteBase.cs

示例3: GetPrimarySelRect

		/// <summary>
		/// Get the primary rectangle occupied by a selection (relative to the top left of the client rectangle).
		/// </summary>
		public Rect GetPrimarySelRect(IVwSelection sel)
		{
			Rect rcPrimary;
			using (new HoldGraphics(this))
			{
				Rectangle rcSrcRoot, rcDstRoot;
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				Rect rcSec;
				bool fSplit, fEndBeforeAnchor;
				sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out rcPrimary,
							 out rcSec, out fSplit, out fEndBeforeAnchor);
			}
			return rcPrimary;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:SimpleRootSite.cs

示例4: ScrollSelectionToLocation

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Scroll the selection in to the given client position.
		/// </summary>
		/// <param name="sel">The selection</param>
		/// <param name="dyPos">Position from top of client window where sel should be scrolled</param>
		/// <returns>True if the selection was scrolled into view, false if this function did
		/// nothing</returns>
		/// ------------------------------------------------------------------------------------
		public bool ScrollSelectionToLocation(IVwSelection sel, int dyPos)
		{
			CheckDisposed();
			if (m_rootb == null)
				return false;

			if (sel == null)
				sel = m_rootb.Selection;
			if (sel == null)
				return false;

			using (new HoldGraphics(this))
			{
				// Put IP at top of window.
				MakeSelectionVisible(sel);

				Rectangle rcSrcRoot;
				Rectangle rcDstRoot;

				// Expand the lazy boxes 1 screen up
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				rcDstRoot.Offset(0, -ClientRectangle.Height);
				PrepareToDraw(rcSrcRoot, rcDstRoot);

				// Expand the lazy boxes 1 screen down
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				rcDstRoot.Offset(0, ClientRectangle.Height);
				PrepareToDraw(rcSrcRoot, rcDstRoot);

				// Get the difference between where we want the selection to be and its
				// current position
				Rect rcPrimary;
				Rect rcSecondary;
				bool fSplit;
				bool fEndBeforeAnchor;
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out rcPrimary,
					out rcSecondary, out fSplit, out fEndBeforeAnchor);
				int difference = dyPos - rcPrimary.top;

				// Now move the scroll position so the IP will be where we want it.
				ScrollPosition = new Point(-ScrollPosition.X, -ScrollPosition.Y - difference);
			}

			// 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(sel) && dyPos >= 0 && dyPos <= ClientHeight)
				MakeSelectionVisible(sel);
			//Update();
			return true;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:61,代码来源:SimpleRootSite.cs

示例5: SelectionRectangle

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the rectangle of the selection. If it is a split selection we combine the
		/// two rectangles.
		/// </summary>
		/// <param name="vwsel">Selection</param>
		/// <param name="rcIdeal">Contains the rectangle of the selection on return</param>
		/// <param name="fEndBeforeAnchor">[Out] <c>true</c> if the end is before the anchor,
		/// otherwise <c>false</c>.</param>
		/// ------------------------------------------------------------------------------------
		protected internal void SelectionRectangle(IVwSelection vwsel, out Rectangle rcIdeal,
			out bool fEndBeforeAnchor)
		{
			Debug.Assert(vwsel != null);
			Debug.Assert(m_graphicsManager.VwGraphics != null);

			Rect rcPrimary;
			Rect rcSecondary;
			bool fSplit;
			Rectangle rcSrcRoot;
			Rectangle rcDstRoot;
			GetCoordRects(out rcSrcRoot, out rcDstRoot);

			vwsel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out rcPrimary, out rcSecondary,
				out fSplit, out fEndBeforeAnchor);
			rcIdeal = rcPrimary;

			if (fSplit)
			{
				rcIdeal = Rectangle.Union(rcIdeal, rcSecondary);
				if ((AutoScroll && VScroll && rcIdeal.Height > ClientHeight) ||
					(DoAutoHScroll && rcIdeal.Width > ClientRectangle.Width))
				{
					rcIdeal = rcPrimary; // Revert to just showing main IP.
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:SimpleRootSite.cs

示例6: IPDistanceFromWindowTop

		// We don't need AfVwScrollWnd::ScrollBy - can be done directly in .NET

		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Finds the distance between the scroll position and the IP (i.e. the distance
		/// between the top of the window and the IP).
		/// </summary>
		/// <param name="sel">The selection used to get the IP's location. If
		/// this value is null, the rootsite's current selection will be used.</param>
		/// -----------------------------------------------------------------------------------
		public int IPDistanceFromWindowTop(IVwSelection sel)
		{
			CheckDisposed();
			if (sel == null && m_rootb != null)
				sel = m_rootb.Selection;

			if (sel == null)
				return 0;

			using (new HoldGraphics(this))
			{
				Rectangle rcSrcRoot;
				Rectangle rcDstRoot;
				GetCoordRects(out rcSrcRoot, out rcDstRoot);

				Rect rcPrimary;
				Rect rcSecondary;
				bool fSplit;
				bool fEndBeforeAnchor;

				sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot,
					out rcPrimary, out rcSecondary, out fSplit, out fEndBeforeAnchor);

				return rcPrimary.top;
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:36,代码来源:SimpleRootSite.cs


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