當前位置: 首頁>>代碼示例>>C#>>正文


C# PointF.Scale方法代碼示例

本文整理匯總了C#中System.Drawing.PointF.Scale方法的典型用法代碼示例。如果您正苦於以下問題:C# PointF.Scale方法的具體用法?C# PointF.Scale怎麽用?C# PointF.Scale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Scale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetZoomAndStartLocation

		/// <summary>
		/// Get the scale factor and the start location of an docoment onto a page.
		/// </summary>
		/// <param name="PageBounds">Bounds of the page in 1/100 inch.</param>
		/// <param name="MarginBounds">Margins of the page in 1/100 inch.</param>
		/// <param name="graphSize">Size of the document in 1/72 inch.</param>
		/// <param name="zoom">Returns the zoom factor to use for the document.</param>
		/// <param name="startLocationOnPage">Returns the start location onto the page in 1/100 inch.</param>
		/// <param name="usePrintingUnits">If <c>true</c> use printing units (1/100 inch) instead of points.</param>
		public void GetZoomAndStartLocation(RectangleF PageBounds, RectangleF MarginBounds, SizeF graphSize, out float zoom, out PointF startLocationOnPage, bool usePrintingUnits)
		{
			// First the size of the graph
			// if a fixed zoom factor is set, we use that

			if (usePrintingUnits) // recalculate everything in units of points (1/72 inch)
			{
				PageBounds = PageBounds.Scale(72.0 / 100);
				MarginBounds = MarginBounds.Scale(72.0 / 100);
			}

			zoom = 1;
			if (this.UseFixedZoomFactor)
			{
				zoom = (float)this.ZoomFactor;
			}
			else if (this.FitGraphToPrintIfSmaller || this.FitGraphToPrintIfLarger)
			{
				float zoomx = MarginBounds.Width / graphSize.Width;
				float zoomy = MarginBounds.Height / graphSize.Height;
				if (zoomx > 1 && zoomy > 1 && this.FitGraphToPrintIfSmaller)
				{
					zoom = Math.Min(zoomx, zoomy);
				}
				else if ((zoomx < 1 || zoomy < 1) && this.FitGraphToPrintIfLarger)
				{
					zoom = Math.Min(zoomx, zoomy);
				}
			}
			graphSize.Width *= zoom;
			graphSize.Height *= zoom;

			// First the location where to start from
			startLocationOnPage = PointF.Empty;
			switch (this.PrintLocation)
			{
				case SingleGraphPrintLocation.PrintableAreaLeftUpper:
					startLocationOnPage = MarginBounds.Location;
					break;

				case SingleGraphPrintLocation.PageLeftUpper:
					startLocationOnPage = new PointF(0, 0);
					break;

				case SingleGraphPrintLocation.PrintableAreaCenter:
					startLocationOnPage = MarginBounds.Center() - graphSize.Half();
					break;

				case SingleGraphPrintLocation.PageCenter:
					startLocationOnPage = PageBounds.Center() - graphSize.Half();
					break;
			}

			if (usePrintingUnits)
			{
				startLocationOnPage = startLocationOnPage.Scale(100.0 / 72);
			}
		}
開發者ID:Altaxo,項目名稱:Altaxo,代碼行數:67,代碼來源:SingleGraphPrintOptions.cs


注:本文中的System.Drawing.PointF.Scale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。