C# GTK# 和 Windows 窗体之间有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/796856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between GTK# and Windows Forms?
提问by Josh
What is the difference between GTK# and windows forms? Are they totally different?
GTK# 和 windows 窗体有什么区别?它们完全不同吗?
Thanks
谢谢
采纳答案by CSharper
Gtk#:
Gtk#:
GTK# is a .NET binding for the Gtk+ toolkit. The toolkit is written in C for speed and compatibility, while the GTK# binding provides an easy to use, object oriented API for managed use. It is in active development by the Mono project, and there are various real-world applications available that use it (Banshee, F-Spot, Beagle, MonoDevelop).
GTK# 是 Gtk+ 工具包的 .NET 绑定。该工具包是用 C 语言编写的,以提高速度和兼容性,而 GTK# 绑定提供了一个易于使用、面向对象的 API 以供托管使用。Mono 项目正在积极开发它,并且有各种可用的实际应用程序使用它(Banshee、F-Spot、Beagle、MonoDevelop)。
In general, GTK# applications are written using MonoDevelop, which provides a visual designer for creating GTK# GUIs.
通常,GTK# 应用程序是使用MonoDevelop编写的,MonoDevelop为创建 GTK# GUI 提供了可视化设计器。
Platforms: Unix, Windows, OSX
平台:Unix、Windows、OSX
Pros:
优点:
- Good support for accessibility through its Gtk+ heritage.
- Layout engine ideal for handling internationalized environments, and adapts to font-size without breaking applications.
- Applications integrate with the Gnome Desktop.
- API is familiar to Gtk+ developers.
- Large Gtk+ community.
- A Win32 port is available, with native look on Windows XP.
- The API is fairly stable at this point, and syntactic sugar is being added to improve it.
- Unicode support is exceptional.
- 通过其 Gtk+ 遗产很好地支持可访问性。
- 布局引擎非常适合处理国际化环境,并在不破坏应用程序的情况下适应字体大小。
- 应用程序与 Gnome 桌面集成。
- API 是 Gtk+ 开发人员所熟悉的。
- 大型 Gtk+ 社区。
- 可以使用 Win32 端口,在 Windows XP 上具有本机外观。
- API 在这一点上相当稳定,并且正在添加语法糖来改进它。
- Unicode 支持非常出色。
Cons:
缺点:
- Gtk+ apps run like foreign applications on MacOS X.
- Incomplete documentation.
- Gtk+ 应用程序在 MacOS X 上像外国应用程序一样运行。
- 文档不完整。
Windows.Forms is a binding developed by Microsoft to the Win32 toolkit. As a popular toolkit used by millions of Windows developers (especially for internal enterprise applications), the Mono project decided to produce a compatible implementation (Winforms) to allow these developers to easily port their applications to run on Linux and other Mono platforms.
Windows.Forms 是 Microsoft 开发的 Win32 工具包绑定。作为数百万 Windows 开发人员(尤其是内部企业应用程序)使用的流行工具包,Mono 项目决定生产一个兼容的实现(Winforms),以允许这些开发人员轻松地将他们的应用程序移植到 Linux 和其他 Mono 平台上运行。
Whereas the .Net implementation is a binding to the Win32 toolkit, the Mono implementation is written in C# to allow it to work on multiple platforms. Most of the Windows.Forms API will work on Mono, however some applications (and especially third party controls) occasionally bypass the API and P/Invoke straight to the Win32 API. These calls will likely have to changed to work on Mono.
.Net 实现是对 Win32 工具包的绑定,而 Mono 实现是用 C# 编写的,以允许它在多个平台上工作。大多数 Windows.Forms API 都可以在 Mono 上运行,但是一些应用程序(尤其是第三方控件)偶尔会绕过 API 并 P/Invoke 直接使用 Win32 API。这些调用可能必须更改才能在 Mono 上工作。
In general, Winforms applications are written using Microsoft's Visual Studio or SharpDevelop, which both provide a visual designer for creating Winforms GUIs.
通常,Winforms 应用程序是使用 Microsoft 的 Visual Studio 或SharpDevelop编写的,它们都提供了用于创建 Winforms GUI 的可视化设计器。
Platforms: Windows, Unix, OSX
平台:Windows、Unix、OSX
Pros:
优点:
- Extensive documentation exists for it (books, tutorials, online documents).
- Large community of active developers.
- Easiest route to port an existing Windows.Forms application.
- 存在大量的文档(书籍、教程、在线文档)。
- 大型活跃开发者社区。
- 移植现有 Windows.Forms 应用程序的最简单途径。
Cons:
缺点:
- Internationalization can be tricky with fixed layouts.
- Looks alien on non-Windows platforms.
- Code that calls the Win32 API is not portable.
- 固定布局的国际化可能很棘手。
- 在非 Windows 平台上看起来很陌生。
- 调用 Win32 API 的代码不可移植。
Source: Picking the Right Toolkit
资料来源:选择正确的工具包
回答by Xn0vv3r
In short: Yes
简而言之:是的
Both are GUI-Tookits, but WinForms (as the Name says) was mainly developed for windows. GTK has been developed for Gimp and is an approach for a multi os gui toolkit .
两者都是 GUI-Tookits,但 WinForms(顾名思义)主要是为 Windows 开发的。GTK 是为 Gimp 开发的,是一种用于多操作系统 gui 工具包的方法。
If your application only runs on windows, in most cases you should use WinForms.
如果您的应用程序仅在 Windows 上运行,则在大多数情况下您应该使用 WinForms。
If your application will run under different OS' (like linux, bsd, windows, macos,... ) you'll prefer GTK.
如果您的应用程序将在不同的操作系统(如 linux、bsd、windows、macos 等)下运行,您会更喜欢 GTK。
For a better explanation look here.
有关更好的解释,请看这里。
回答by David Suarez
They are different graphical toolkits for creting windowed applications, with different origins.
它们是用于创建窗口应用程序的不同图形工具包,具有不同的起源。
GTK# is a binding for the GTK library, primarily intended for linux/unix. It also works on windows, but it's not the native environment for which it was designed.
GTK# 是 GTK 库的绑定,主要用于 linux/unix。它也适用于 Windows,但它不是为它设计的本机环境。
Winforms is another toolkit, this one coming from microsoft.
Winforms 是另一个工具包,这个工具包来自微软。
They are totally different APIs for achieving the same results, but each better suited for a platform.
它们是完全不同的 API,用于实现相同的结果,但每个都更适合某个平台。
If you are looking for multiplatform windowing in .net, Qt may be an option now that it got LGPLed.
如果您正在 .net 中寻找多平台窗口,那么 Qt 可能是一个选择,因为它已获得 LGPL。
回答by dmitry_vk
They are both GUI toolkits, each having their strength and weaknesses. From my experience:
它们都是 GUI 工具包,各有优缺点。根据我的经验:
- Winforms does not require installation on windows, Gtk# does require installation on Windows.
- Winforms has a designer in Visual Studio, Gtk# has standalone designer and integrated designed in MonoDevelop.
- Winforms is bound to Windows, Gtk# is cross-platform.
- Winforms is slow and flickers. Gtk is faster.
- Most Winforms controls are wrappers around standard windows controls and offer very limited functionality. Gtk widgets are more feature-rich.
- Gtk allows creating forms and widgets with complex layout. Winforms offers only trivial variants of layout, and FlowLayout & TableLayout & AutoSize are too weak to be able to have complex forms that resize and automatically accomodate to different font sizes, different resolutions.
- Cairo is faster and has more features than Gdi+ (Cairo supports output and input from more types of files, e.g., svg, pdf)
- Gtk# is open-source, winforms is not
- Winforms and Gtk# have 3rd-party controls/widgets (however, with Gtk# there is less need for them because basic controls work really good).
- Winforms 不需要在 Windows 上安装,Gtk# 需要在 Windows 上安装。
- Winforms 在 Visual Studio 中有一个设计器,Gtk# 有独立设计器和 MonoDevelop 中的集成设计器。
- Winforms 绑定到 Windows,Gtk# 是跨平台的。
- Winforms 运行缓慢且闪烁。Gtk 更快。
- 大多数 Winforms 控件是标准 Windows 控件的包装器,并提供非常有限的功能。Gtk 小部件功能更丰富。
- Gtk 允许创建具有复杂布局的表单和小部件。Winforms 只提供一些简单的布局变体,而 FlowLayout & TableLayout & AutoSize 太弱了,无法拥有调整大小并自动适应不同字体大小、不同分辨率的复杂表单。
- Cairo 比 Gdi+ 更快并且具有更多功能(Cairo 支持来自更多类型文件的输出和输入,例如 svg、pdf)
- Gtk# 是开源的,winforms 不是
- Winforms 和 Gtk# 有 3rd-party 控件/小部件(但是,使用 Gtk# 不需要它们,因为基本控件工作得很好)。
In short, I would not recommend using Winforms (except when there is a strong reason not to have more dependencies than .NET FW), but using Gtk# or WPF.
简而言之,我不建议使用 Winforms(除非有充分的理由不比 .NET FW 具有更多的依赖项),而是使用 Gtk# 或 WPF。