单是否支持System.Drawing中和System.Drawing.Printing?System、Drawing、Printing

由网友(扛着王俊凯去民政局)分享简介:我试图用单声道加载一个位图,并打印在Linux上,但我发现一个例外。单是否支持打印在Linux上?下面的code /的例外是:编辑:不再变得异常,但我仍然好奇什么样的支持是有的。离开code留给后人什么的。私人无效btnPrintTest_Click(对象发件人,EventArgs的){_printDocTest.D...

我试图用单声道加载一个位图,并打印在Linux上,但我发现一个例外。单是否支持打印在Linux上?下面的code /的例外是:

编辑:不再变得异常,但我仍然好奇什么样的支持是有的。离开code留给后人什么的。

 私人无效btnPrintTest_Click(对象发件人,EventArgs的)
{
    _printDocTest.DefaultPageSettings.Landscape = TRUE;
    _printDocTest.DefaultPageSettings.Margins =新的页边距(50,50,50,50);
    _printDocTest.Print();
}

无效_printDocTest_PrintPage(对象发件人,PrintPageEventArgs E)
{
  VAR BMP =新位图(test.bmp);

  //确定图形的中心
  变种X中心值= e.MarginBounds.X +(e.MarginBounds.Width  -  bmp.Width)/ 2;
  变种yCenter = e.MarginBounds.Y +(e.MarginBounds.Height  -  bmp.Height)/ 2;

  e.Graphics.DrawImage(BMP,X中心值,yCenter);

  e.HasMorePages = FALSE;
}
 

解决方案

从黑白文档,我觉得是:

  

Managed.Windows.Forms(又名   System.Windows.Forms的):一个完整​​的,   跨平台,基于System.Drawing中   的WinForms实现。

这也是有用的,如果你运行单迁移分析器第一。

I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:

颜值性能双管齐下 Reno3 Pro搭配OPPO无线耳机,体验不输AirPods

EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something.

private void btnPrintTest_Click(object sender, EventArgs e)
{
    _printDocTest.DefaultPageSettings.Landscape = true;
    _printDocTest.DefaultPageSettings.Margins = new Margins(50,50,50,50);
    _printDocTest.Print();
}

void _printDocTest_PrintPage(object sender, PrintPageEventArgs e)
{
  var bmp = new Bitmap("test.bmp");

  // Determine center of graph
  var xCenter = e.MarginBounds.X + (e.MarginBounds.Width - bmp.Width) / 2;
  var yCenter = e.MarginBounds.Y + (e.MarginBounds.Height - bmp.Height) / 2;

  e.Graphics.DrawImage(bmp, xCenter, yCenter);

  e.HasMorePages = false;
}

解决方案

From the Mono docs, I think yes:

Managed.Windows.Forms (aka System.Windows.Forms): A complete and cross platform, System.Drawing based Winforms implementation.

It also useful if you run the Mono Migration Analyzer first.

阅读全文

相关推荐

最新文章