当前位置: 首页>>代码示例>>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;未经允许,请勿转载。