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

Does Mono support System.Drawing and System.Drawing.Printing?(Mono 是否支持 System.Drawing 和 System.Drawing.Printing?)
本文介绍了Mono 是否支持 System.Drawing 和 System.Drawing.Printing?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Mono 加载位图并在 Linux 上打印它,但我遇到了异常.Mono 是否支持在 Linux 上打印?代码/异常如下:

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:

不再出现异常,但我仍然很好奇有什么样的支持.留下代码供后代使用.

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

推荐答案

来自 Mono 文档,我认为是的:

Managed.Windows.Forms(又名System.Windows.Forms):一个完整​​且跨平台,基于 System.DrawingWinforms 实现.

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

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

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

这篇关于Mono 是否支持 System.Drawing 和 System.Drawing.Printing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)