简体   繁体   English

在OS X上使用MonoDevelop创建GUI应用程序

[英]Create a GUI Application using MonoDevelop on OS X

I just installed the latest Mono framework and MonoDevelop. 我刚刚安装了最新的Mono框架和MonoDevelop。

When I create a new solution under C# there is no GUI based application. 当我在C#下创建新的解决方案时,没有基于GUI的应用程序。

How do I create an app that has a GUI and buttons etc 如何创建具有GUI和按钮等的应用程序

you can create GUI by mono in mac follow these steps: 您可以通过mono in mac创建GUI,请按照以下步骤操作:

  • File->New->Solution. 文件 - >新建 - >解决方案。
  • Select C# and then select Gtk# enter a name for your project then click Forward. 选择C#,然后选择Gtk#输入项目名称,然后单击Forward。
  • in the solution window at the left side of the window click the arrow next to your project name, then right-click on the MainWindow.cs click open. 在窗口左侧的解决方案窗口中,单击项目名称旁边的箭头,然后右键单击MainWindow.cs单击打开。
  • after it opened at the bottom of the window there is (Source code and Designer) click on the Designer, enjoy it you can see a form now. 在窗口底部打开后,有(源代码和设计师)点击设计器,享受它,你现在可以看到一个表格。

so if want to add buttons, textboxes, lables,... etc there is a toolbox window at the right of the window. 因此,如果要添加按钮,文本框,标签等...窗口右侧有一个工具箱窗口。

If you are on Linux or Windows, the project type is called "Gtk# 2.0 Project". 如果您使用的是Linux或Windows,则项目类型称为“Gtk#2.0 Project”。 If you are on Mac, there is no visual designer for Gtk#, you will have to code it by hand. 如果你在Mac上,没有Gtk#的视觉设计师,你必须手动编码。

If you're already familiar with WinForms and C# development using Visual Studio--and if you don't mind developing a GUI without a visual editor--then you can develop a WinForms application in MonoDevelop. 如果您已经熟悉使用Visual Studio的WinForms和C#开发 - 如果您不介意在没有可视化编辑器的情况下开发GUI,那么您可以在MonoDevelop中开发WinForms应用程序。

This tutorial should get you started: http://zetcode.com/tutorials/monowinformstutorial/firststeps/ 本教程应该可以帮助您入门:http: //zetcode.com/tutorials/monowinformstutorial/firststeps/

After creating a new C# solution (File|New > Solution...), add references to System.Drawing and System.Windows.Forms (Project|Edit References...). 创建新的C#解决方案(文件|新建>解决方案...)后,添加对System.Drawing和System.Windows.Forms(项目|编辑引用...)的引用。 In the constructor for your Form subclass you can define buttons and other controls. 在Form子类的构造函数中,您可以定义按钮和其他控件。 That should get you on your way. 这应该会让你在路上。

There may still be bugs and odd quirks in MonoDevelop. MonoDevelop中可能仍然存在漏洞和奇怪的怪癖。 For example, autocomplete for adding an event handler (such as MyButton.Click += HandleMyButtonClick) works if I insert a space after "+=", but not if I tab. 例如,如果我在“+ =”之后插入空格,则添加事件处理程序(例如MyButton.Click + = HandleMyButtonClick)的自动完成功能会起作用,但如果我选项卡则不会。 Otherwise the environment should feel familiar. 否则环境应该让人感到熟悉。

Just install Xcode together with MonoFramework and MonoDevelop, then you can use the native iOS interface builder! 只需将Xcode与MonoFramework和MonoDevelop一起安装,即可使用本机iOS界面构建器!

MonoDevelop works perfectly (although a little buggy on some functions) with xcode. MonoDevelop与xcode完美配合(虽然在某些功能上有点小问题)。 During development of say, an iPhone-app, I switch between Monodevelop and Xcode, MonoDevelop for writing all code-behind/delegates etc., and Xcode for designing using the native interface-builder for Mac OSX and iOS apps... 在开发一个iPhone应用程序期间,我在Monodevelop和Xcode之间切换,MonoDevelop用于编写所有代码隐藏/代理等,而Xcode用于使用Mac OSX和iOS应用程序的原生界面构建器进行设计......

You need: 你需要:

MonoDevelop http://monodevelop.com/ MonoDevelop http://monodevelop.com/

MonoTouch (UI framework to interface with CocaoTouch on iOS) http://xamarin.com/monotouch MonoTouch(与iOS上的CocaoTouch接口的UI框架) http://xamarin.com/monotouch

And of course the actual mono-framework (C# to Obj-C) http://www.mono-project.com/ 当然还有实际的单一框架(C#到Obj-C) http://www.mono-project.com/

MonoDevelop supports MonoDevelop支持

There are a number of bindings for Mono and Cocoa which allow you to build OS X apps using Mono with native looking interfaces. Mono和Cocoa有许多绑定,允许您使用具有本机外观的Mono构建OS X应用程序。

Some time ago there was the Cocoa# project, which is still shipped with Mono, but is now dead on the water and no longer updated. 前段时间有一个Cocoa#项目,它仍然随Mono一起提供,但现在已经死了,不再更新了。

However, just a few days ago, I myself asked about the state of Cocoa# and other solutions were highlighted. 然而,就在几天前,我自己也询问了Cocoa#的状态,并强调了其他解决方案。 The best (IMHO) is Monobj , which also has Monodevelop/IB templates. 最好的(恕我直言)是Monobj ,它也有Monodevelop / IB模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM