我应该用 GTK+ 而不是 WinForms 为 Mono 重写 GUI 吗?

Should I rewrite GUI with GTK+ instead of WinForms for Mono?(我应该用 GTK+ 而不是 WinForms 为 Mono 重写 GUI 吗?)
本文介绍了我应该用 GTK+ 而不是 WinForms 为 Mono 重写 GUI 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio、winforms 制作应用程序,并且正在使用 openTK.最近我想让它跨平台.我将使用 Mono,因为我不知道其他类似的东西.而且我完全没有使用 GTK+ 的经验.在我的应用程序中,目前有 4 个窗口(当然以后还会有更多).我想让应用程序在 Windows、Linux 和 OS X 中快速运行.我读过 GTK+ 比 WinForms 更好,但仍然不确定该选择哪个.那么,我应该为 GTK+ 重新制作所有内容还是继续使用 WinForms 以及为什么?另外,是否有任何工具可以为我完成这项工作?

I was making an application with Visual Studio, winforms and I'm using openTK. Recently I thought about making it cross-platform. I'm going to use Mono, because I don't know anything else similar. And I have totally no experience with GTK+. In my application, currently there are 4 windows(of course there will be more in future). I want to make application fast in Windows, Linux and OS X. I have read, that GTK+ is better than WinForms, but still not sure which to choose. So, should I remake everything for GTK+ or stay with WinForms and why? Also, is there any tool, which would do this work for me?

推荐答案

老实说,您需要告诉我们更多关于您的受众/预期市场的信息,以提供一个很好的答案,但我的0.02 美元的开发经验表明,如果您想正确"地在桌面上进行 Mono 的 GUI 开发是一个多目标的事情.您将需要非常模块化地开发共享后端,然后为每个平台编写一次 UI.

Honestly, you're going to need to tell us more about your audience/intended market to provide a great answer, but my $0.02 from some experience developing there is that GUI development for Mono on the desktop is a multi-target affair if you want to do it "Right". You're going to need to develop the shared backend exceptionally modularly, and then write UI once per platform.

Windows

如果您的应用还处于起步阶段,那么在 Mono 上实现的 Windows.Forms 是一个很好的支持,它允许您立即以 Windows 为目标并在 OS X 和 Linux 上以一种有点残缺的方式进行部署.但是请注意,我在 IRC 上被告知 Mono 上的 Windows.Forms 开发基本上已经死了.旧的错误没有得到更新,例如,我在测试的几分钟内遇到了 SelectionBackColor 无法在 OS X 上的 RichTextBox 中工作(这是 Mono 在 OS X 上用于 Windows.Forms 的库中的一个问题).很好,它就在那里,也许对于快速实用程序很有用,您可以在其中编写代码以绕过其限制(有关示例,请参阅问题此处).

Windows.Forms as implemented on Mono is a great crutch if your app's in its infancy, allowing you to target Windows immediately and deploy in a somewhat crippled fashion on OS X and Linux. Note, however, that I've been told on IRC that Windows.Forms development on Mono is essentially dead. Old bugs don't get updated, and, as a for instance, I ran into SelectionBackColor not working in RichTextBox on OS X (it's a problem in a lib Mono uses for Windows.Forms on OS X) within a few minutes of testing. Neat that it's there, perhaps good for quick utilities where you can code around its limitations (see question here for an example).

OS X

针对 OS X,如果你有一个真正的、商业的、最终用户的应用程序,你需要习惯,嗯,与 界面生成器.我应该在此明确说明,使用 XCode 和 Interface Builder绝对要求您可以访问运行 OS X 的机器.否则,您将无法使用 Windows.Forms,或者,我认为最好是 Gtk#.

For targeting OS X, if you have a real, commercial, end-user app, you're going to need to get used to, um, interfacing with Interface Builder. I should make clear here that using XCode and Interface Builder absolutely requires that you have access to a box running OS X. Otherwise, you're stuck with Windows.Forms or, preferably, I think, Gtk#.

Xamarin 在将其 IDE 存根连接到 XCode 中内置的本机 UI 方面做得很好.这也是他们为 iOS 开发所做的方式.它工作得很好,尽管文档很弱.Michael Hutchinson 2011 年的精彩视频描述了这个过程,但我想它正在长在牙齿上(即老").(直接链接到视频)

Xamarin has done a great job making its IDE stub out connections to native UIs built in XCode. That's how they do it for iOS development as well. It works fairly well, though the documentation is weak. There's a great video from 2011 from Michael Hutchingson describing this process, though I suppose it's getting long in the tooth (ie, "old"). (Direct link to video)

如果您想瞄准 Mac App Store,我假设 Interface Builder 也是您唯一真正的选择.但是你看,它是一个原生 UI,被存根到你的 C# 代码中,从所有方面考虑,这是一个很好的折衷方案.

I'm assuming Interface Builder is also your only real choice if you want to target the Mac App Store. But look, it's a native UI that's stubbed to your C# code, which is, all things considered, a great compromise.

Linux

我并没有真正针对 Linux.似乎 Gtk# 很自然,但我没有太多的动手帮助.我的东西是在 Windows.Forms 中构建的,并且有一些粗糙的边缘,就像在 OS X 中一样.如果我更认真,我会从 Gtk# 开始,这也是 MonoDevelop 的 GUI RAD 所在.

I haven't really targeted Linux. Seems like Gtk# would be a natural fit, but I'm not much hands-on help there. My stuff builds in Windows.Forms, and there are rough edges, just like in OS X. If I got more serious, I would start with Gtk#, and that's where MonoDevelop has its GUI RAD as well.

严肃、成熟、跨平台的 Gtk# 应用示例

快速说明:Banshee 使用 Gtk# 以 OS X、Windows (alpha) 和 Linux 为目标.您可以通过查看 它的邮件列表 和其他资源.

Quick note: Banshee uses Gtk# to target OS X, Windows (alpha), and Linux. You can get some great context for how difficult it is to use Gtk# on a large application cross-platform by checking out its mailing list and other resources.

很抱歉,这个消息并不容易.没有灵丹妙药/唯一正确答案.

Sorry the news isn't any easier. There is no silver bullet/single right answer.

201607 更新:我认为答案正在慢慢变成使用 Xamarin.Forms 来定位跨平台.您现在可能仍然无法编写单独的 Mac 界面,但有理由相信它也会在某个时候获得 Xamarin.Forms 支持;见下文.

201607 UPDATE: I think the answer is slowly becoming to use Xamarin.Forms to target cross-platform. You might still be stuck writing a separate Mac interface for now, but there's reason to believe that'll have Xamarin.Forms support at some point too; see below.

不幸的是,如果你的目标是 Linux,我认为你现在仍然和以前一样.

Unfortunately, if you're targeting Linux, I think you're still in the same boat as you were before for now.

  • Windows:您现在可以使用 Xamarin.Forms 和 UWP.
  • macOS:你基本上还是在同一个地方,但我有一个 Xamarin 员工上周末告诉我 Xamarin.Forms 是非官方的 OS X 开发.我相信 这是 GitHub 上的存储库.(甚至还有一个 tvOS 分支.)
  • Windows: You can now use Xamarin.Forms and UWP.
  • macOS: You're still in essentially the same place, but I had a Xamarin employee tell me last weekend that Xamarin.Forms is unofficially in development for OS X. I believe this is the repo on GitHub. (There's even a branch for tvOS.)

这篇关于我应该用 GTK+ 而不是 WinForms 为 Mono 重写 GUI 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

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子句?)