Mono是否支持System.Drawing和System.Drawing.Printing?

时间:2020-03-05 18:43:09  来源:igfitidea点击:

我试图使用Mono加载位图并在Linux上打印它,但出现异常。 Mono支持在Linux上打印吗?代码/异常如下:

编辑:不再得到例外,但我仍然很好奇有什么样的支持。留下后代代码。

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;
}

解决方案

回答

从Mono文档中,我认为是:

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

如果首先运行Mono迁移分析器,它也很有用。

回答

根据

System.Drawing现在已经完成,并且除了作为Windows.Forms的基础呈现引擎之外,还已经测试过使用高度依赖它的第三方控件。