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