mai*_*har 3 c# gtk# monodevelop
我有这样的一段简单的代码中C#有GTK#:
Main.cs:
using System;
using Gtk;
namespace Apu{
class MainClass{
public static void Main(string[] args){
Application.Init();
new ShowForm();
Application.Run();
}
}
}
Run Code Online (Sandbox Code Playgroud)
ShowForm.cs
public partial class ShowForm: Gtk.Window{
public ShowForm(): base(Gtk.WindowType.Toplevel){
MessageDialog md = new MessageDialog(
this,
DialogFlags.DestroyWithParent,
MessageType.Error,
ButtonsType.None,
"Test"
);
md.SetPosition(Gtk.WindowPosition.CenterAlways);
md.Title = "Test window";
md.AddButton("Don't stop", ResponseType.Ok);
md.AddButton("Stop", ResponseType.Cancel);
ResponseType result = (ResponseType)md.Run();
if (result.Equals(ResponseType.Cancel)) {
Console.WriteLine("Quit!");
md.DestroyEvent += delegate {
Application.Quit();
};
/*md.DeleteEvent += delegate {
Application.Quit();
};*/
}
md.Destroy();
}
}
Run Code Online (Sandbox Code Playgroud)
控制台输出Quit!,但程序不退出.既不工作DestroyEvent也不DeleteEvent工作.有谁能解释为什么?这是我c#第一次使用的应用程序gtk#.我使用monodevelop作为我的IDE.
编辑
Application.Exit()给出错误:Gtk.Application does not contain a definition for 'Exit'.
| 归档时间: |
|
| 查看次数: |
9414 次 |
| 最近记录: |