当前位置: 首页>>代码示例>>C#>>正文


C# PrinterSettings.CreateMeasurementGraphics方法代码示例

本文整理汇总了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;
        }
开发者ID:jalil1408,项目名称:LOGEMENT,代码行数:38,代码来源:UtlGen.cs

示例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;
 }
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:11,代码来源:PrintTarget.cs


注:本文中的System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。