Let's say just for the joy of it, I decide that I don't want to write desktop applications in Java any more, instead want to switch to using C#. I want to be able to build an application that will run on some mainstream Linux distribution, and a recent release of MS Windows. It will have a GUI component.
让我们说只是为了它的乐趣,我决定不再用Java编写桌面应用程序,而是想切换到使用C#。我希望能够构建一个将在某些主流Linux发行版上运行的应用程序,以及最近发布的MS Windows。它将有一个GUI组件。
In Java I can build an application that uses Swing. Once I have it working, I can copy that jar file from Windows to Linux or vice versa, depending where I developed it. And it will generally run with java -jar myapp.jar
.
在Java中,我可以构建一个使用Swing的应用程序。一旦我有它工作,我可以将该jar文件从Windows复制到Linux,反之亦然,这取决于我开发它的位置。它通常会运行java -jar myapp.jar。
In C# is it possible to do this? Is there a functional equivalent to Swing or AWT in C#?
在C#中可以这样做吗?在C#中是否有与Swing或AWT相同的功能?
9 个解决方案
#1
There's Eto.Forms (on github), which is an abstraction layer on top of WPF, WinForms, GTK, and MonoMac/Cocoa - so you can get a native UI on all platforms without having to re-implement for each platform. You don't have to suffer from lowest common denominator, since you can implement specifics for each platform (if desired, but not required).
还有Eto.Forms(在github上),它是WPF,WinForms,GTK和MonoMac / Cocoa之上的抽象层 - 因此您可以在所有平台上获得本机UI,而无需为每个平台重新实现。您不必受最低公分母的影响,因为您可以为每个平台实现细节(如果需要,但不是必需的)。
It has an advantage that it is pure .NET and only relies on OS-supplied dependencies, as opposed to using GTK or WxWidgets where you'd have to bundle the native binaries for various platforms.
它的优势在于它是纯.NET并且仅依赖于操作系统提供的依赖性,而不是使用GTK或WxWidgets,您必须为各种平台捆绑本机二进制文件。
#2
Probably GTK# would be the closest.
GTK#可能是最接近的。
I know others have said mono, but that's not quite right. .Net is to mono as Microsoft's Java VM is to Sun's Java runtime. mono's not really in the same conceptual space as Swing. For that, GTK# is a closer match.
我知道其他人说单音,但那不太对。 .Net是单声道,因为微软的Java VM是Sun的Java运行时。 mono并不像Swing那样处于同一个概念空间。为此,GTK#是一个更接近的匹配。
#3
I believe a good portion of WinForms is implemented in Mono. You need to install Mono under Linux for that. You may have compatibility problems, though, since Mono is not a Microsoft effort and is not officially supported by them.
我相信WinForms的很大一部分是在Mono中实现的。你需要在Linux下安装Mono。但是,您可能遇到兼容性问题,因为Mono不是Microsoft的努力,也不是他们的正式支持。
#4
This page has a list of the GUI toolkits supported by Mono, including pros and cons for each of them. As others have suggested, WinForms, GTK#, and wxNet are all viable options.
此页面包含Mono支持的GUI工具包列表,包括每个工具包的优缺点。正如其他人所说,WinForms,GTK#和wxNet都是可行的选择。
#5
This is an older question, but as an update, a combination of Mono and Xamarin should work for your modern cross-platform needs.
这是一个较旧的问题,但作为更新,Mono和Xamarin的组合应该适用于您现代的跨平台需求。
http://www.mono-project.com/docs/gui/winforms/
Microsoft has just open-sourced .NET and is committing to bringing the .NET core to Linux and MacOS with their next version. Microsoft has also formed a close partnership with Mono and Xamarin, specifically to help with their Android and Linux libraries.
微软刚刚开源.NET,并承诺将.NET核心带到Linux和MacOS的下一个版本。微软还与Mono和Xamarin建立了密切的合作伙伴关系,专门帮助他们的Android和Linux库。
#6
The closest thing I've ever seen is Mono - though it doesn't support all the CLR libraries yet I believe, but it is cross-platform.
我见过的最接近的东西是Mono - 虽然它不支持所有的CLR库但我相信,但它是跨平台的。
#7
You can try WxWidgets. It has support for C#, among many other languages, and is cross-platform. The only downside being a recompile for each platform. Alternatively you can try Mono which is very good, but beware there are a couple snags with compatibility issues. There is no predefined "run anywhere" file for C# apps yet like Java has with jars though, you're best bet is to recompile for each platform if you want to ensure compatibility.
你可以试试WxWidgets。它支持C#,以及许多其他语言,并且是跨平台的。唯一的缺点是每个平台的重新编译。或者你可以尝试Mono这是非常好的,但要注意有一些兼容性问题的障碍。对于C#应用程序没有预定义的“随处运行”文件,但就像Java有jars一样,如果你想确保兼容性,你最好的选择是为每个平台重新编译。
#8
For iOS, Android, and Windows Mobile, there is Xamarin.Forms. http://xamarin.com/forms This is an abstraction layer that allows you to write cross-platform code, which binds to the native GUI toolkits under the hood.
对于iOS,Android和Windows Mobile,有Xamarin.Forms。 http://xamarin.com/forms这是一个抽象层,允许您编写跨平台代码,该代码绑定到引擎盖下的本机GUI工具包。
I am looking for more solutions like this - I care not only about mobile platforms, but also desktop platforms (windows, mac OSX, fedora/ubuntu/etc linux)
我正在寻找更多这样的解决方案 - 我不仅关心移动平台,还关心桌面平台(windows,mac OSX,fedora / ubuntu / etc linux)
#9
Windows.Forms is the standard library for developing GUI applications for .NET
Windows.Forms是用于开发.NET GUI应用程序的标准库
Despite of being very well supported on Windows, version 2.0 is fully implemented by Mono too, which makes it available on all platforms supported by Mono.
尽管在Windows上得到了很好的支持,但版本2.0也完全由Mono实现,这使得它可以在Mono支持的所有平台上使用。
WPF on the other hand is is conceptually new library, for now it is fully supported mainly on Windows only and just a subset of it supported by Mono by their Silverlight implementation - Moonlight.
另一方面,WPF是概念上的新库,目前它主要仅在Windows上得到完全支持,而Mono通过其Silverlight实现 - Moonlight仅支持它的一部分。
If you are building application for productive cross-platform use and/or have conservative performance constraints go Windows Forms.
如果您正在构建用于高效跨平台使用的应用程序和/或具有保守的性能限制,请转到Windows窗体。
If you want to experiment and learn something new or if you are developing new application for Windows go WPF. This is the new technology for client GUI applications.
如果您想尝试和学习新的东西,或者如果您正在开发Windows的新应用程序,请转到WPF。这是客户端GUI应用程序的新技术。
#1
There's Eto.Forms (on github), which is an abstraction layer on top of WPF, WinForms, GTK, and MonoMac/Cocoa - so you can get a native UI on all platforms without having to re-implement for each platform. You don't have to suffer from lowest common denominator, since you can implement specifics for each platform (if desired, but not required).
还有Eto.Forms(在github上),它是WPF,WinForms,GTK和MonoMac / Cocoa之上的抽象层 - 因此您可以在所有平台上获得本机UI,而无需为每个平台重新实现。您不必受最低公分母的影响,因为您可以为每个平台实现细节(如果需要,但不是必需的)。
It has an advantage that it is pure .NET and only relies on OS-supplied dependencies, as opposed to using GTK or WxWidgets where you'd have to bundle the native binaries for various platforms.
它的优势在于它是纯.NET并且仅依赖于操作系统提供的依赖性,而不是使用GTK或WxWidgets,您必须为各种平台捆绑本机二进制文件。
#2
Probably GTK# would be the closest.
GTK#可能是最接近的。
I know others have said mono, but that's not quite right. .Net is to mono as Microsoft's Java VM is to Sun's Java runtime. mono's not really in the same conceptual space as Swing. For that, GTK# is a closer match.
我知道其他人说单音,但那不太对。 .Net是单声道,因为微软的Java VM是Sun的Java运行时。 mono并不像Swing那样处于同一个概念空间。为此,GTK#是一个更接近的匹配。
#3
I believe a good portion of WinForms is implemented in Mono. You need to install Mono under Linux for that. You may have compatibility problems, though, since Mono is not a Microsoft effort and is not officially supported by them.
我相信WinForms的很大一部分是在Mono中实现的。你需要在Linux下安装Mono。但是,您可能遇到兼容性问题,因为Mono不是Microsoft的努力,也不是他们的正式支持。
#4
This page has a list of the GUI toolkits supported by Mono, including pros and cons for each of them. As others have suggested, WinForms, GTK#, and wxNet are all viable options.
此页面包含Mono支持的GUI工具包列表,包括每个工具包的优缺点。正如其他人所说,WinForms,GTK#和wxNet都是可行的选择。
#5
This is an older question, but as an update, a combination of Mono and Xamarin should work for your modern cross-platform needs.
这是一个较旧的问题,但作为更新,Mono和Xamarin的组合应该适用于您现代的跨平台需求。
http://www.mono-project.com/docs/gui/winforms/
Microsoft has just open-sourced .NET and is committing to bringing the .NET core to Linux and MacOS with their next version. Microsoft has also formed a close partnership with Mono and Xamarin, specifically to help with their Android and Linux libraries.
微软刚刚开源.NET,并承诺将.NET核心带到Linux和MacOS的下一个版本。微软还与Mono和Xamarin建立了密切的合作伙伴关系,专门帮助他们的Android和Linux库。
#6
The closest thing I've ever seen is Mono - though it doesn't support all the CLR libraries yet I believe, but it is cross-platform.
我见过的最接近的东西是Mono - 虽然它不支持所有的CLR库但我相信,但它是跨平台的。
#7
You can try WxWidgets. It has support for C#, among many other languages, and is cross-platform. The only downside being a recompile for each platform. Alternatively you can try Mono which is very good, but beware there are a couple snags with compatibility issues. There is no predefined "run anywhere" file for C# apps yet like Java has with jars though, you're best bet is to recompile for each platform if you want to ensure compatibility.
你可以试试WxWidgets。它支持C#,以及许多其他语言,并且是跨平台的。唯一的缺点是每个平台的重新编译。或者你可以尝试Mono这是非常好的,但要注意有一些兼容性问题的障碍。对于C#应用程序没有预定义的“随处运行”文件,但就像Java有jars一样,如果你想确保兼容性,你最好的选择是为每个平台重新编译。
#8
For iOS, Android, and Windows Mobile, there is Xamarin.Forms. http://xamarin.com/forms This is an abstraction layer that allows you to write cross-platform code, which binds to the native GUI toolkits under the hood.
对于iOS,Android和Windows Mobile,有Xamarin.Forms。 http://xamarin.com/forms这是一个抽象层,允许您编写跨平台代码,该代码绑定到引擎盖下的本机GUI工具包。
I am looking for more solutions like this - I care not only about mobile platforms, but also desktop platforms (windows, mac OSX, fedora/ubuntu/etc linux)
我正在寻找更多这样的解决方案 - 我不仅关心移动平台,还关心桌面平台(windows,mac OSX,fedora / ubuntu / etc linux)
#9
Windows.Forms is the standard library for developing GUI applications for .NET
Windows.Forms是用于开发.NET GUI应用程序的标准库
Despite of being very well supported on Windows, version 2.0 is fully implemented by Mono too, which makes it available on all platforms supported by Mono.
尽管在Windows上得到了很好的支持,但版本2.0也完全由Mono实现,这使得它可以在Mono支持的所有平台上使用。
WPF on the other hand is is conceptually new library, for now it is fully supported mainly on Windows only and just a subset of it supported by Mono by their Silverlight implementation - Moonlight.
另一方面,WPF是概念上的新库,目前它主要仅在Windows上得到完全支持,而Mono通过其Silverlight实现 - Moonlight仅支持它的一部分。
If you are building application for productive cross-platform use and/or have conservative performance constraints go Windows Forms.
如果您正在构建用于高效跨平台使用的应用程序和/或具有保守的性能限制,请转到Windows窗体。
If you want to experiment and learn something new or if you are developing new application for Windows go WPF. This is the new technology for client GUI applications.
如果您想尝试和学习新的东西,或者如果您正在开发Windows的新应用程序,请转到WPF。这是客户端GUI应用程序的新技术。