本文整理汇总了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);
}
}