本文整理汇总了C#中System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics方法的典型用法代码示例。如果您正苦于以下问题:C# PrinterSettings.CreateMeasurementGraphics方法的具体用法?C# PrinterSettings.CreateMeasurementGraphics怎么用?C# PrinterSettings.CreateMeasurementGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Printing.PrinterSettings
的用法示例。
在下文中一共展示了PrinterSettings.CreateMeasurementGraphics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrinterMargins
public static Margins PrinterMargins(PrinterSettings ps, bool Landscape)
{
Margins m;
Graphics e = ps.CreateMeasurementGraphics();
float dpiX = e.DpiX;
float dpiY = e.DpiY;
int offsetx, offsety;
int horzres, vertres;
int physicalwidth, physicalheight;
IntPtr hDC = e.GetHdc();
offsetx = GetDeviceCaps(hDC, PHYSICALOFFSETX);
offsety = GetDeviceCaps(hDC, PHYSICALOFFSETY);
horzres = GetDeviceCaps(hDC, HORZRES);
vertres = GetDeviceCaps(hDC, VERTRES);
physicalwidth = GetDeviceCaps(hDC, PHYSICALWIDTH);
physicalheight = GetDeviceCaps(hDC, PHYSICALHEIGHT);
e.ReleaseHdc(hDC);
int left = (int)Math.Ceiling((float)offsetx * 100.0F / dpiX);
int top = (int)Math.Ceiling((float)offsety * 100.0F / dpiY);
int right = (int)Math.Ceiling((float)(physicalwidth - horzres - offsetx) * 100.0F / dpiX);
int bottom = (int)Math.Ceiling((float)(physicalheight - vertres - offsety) * 100.0F / dpiY);
if (Landscape && ps.LandscapeAngle == 90)
{
m = new System.Drawing.Printing.Margins(bottom, top, left, right);
}
else if (Landscape && ps.LandscapeAngle == 270)
{
m = new System.Drawing.Printing.Margins(top, bottom, right, left);
}
else
{
m = new System.Drawing.Printing.Margins(left, right, top, bottom);
}
return m;
}
示例2: PrinterPrintTarget
public PrinterPrintTarget(PrinterSettings settings)
{
m_settings = (PrinterSettings)settings.Clone();
m_settings.DefaultPageSettings.Landscape = false;
m_infoDC = m_settings.CreateMeasurementGraphics();
m_w0 = m_infoDC.VisibleClipBounds.Width;
m_h0 = m_infoDC.VisibleClipBounds.Height;
m_info = XGraphics.FromGraphics(m_infoDC, new XSize(m_w0, m_h0));
m_mmkx = m_w0 / 210.0f;
m_mmky = m_h0 / 297.0f;
}