我应该用 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 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1173

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1071

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this->id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:808

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this->id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:900

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:931

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:879

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:865

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:834

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1734

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1309