本文整理汇总了C#中MessageDialog.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# MessageDialog.AddButton方法的具体用法?C# MessageDialog.AddButton怎么用?C# MessageDialog.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.AddButton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartGame
public void StartGame(Config config)
{
game = new Game (this.createBoard (config.Width, config.Height));
game.GameWon += delegate(object sender, EventArgs e) {
MessageDialog dialog = new MessageDialog (
this,
DialogFlags.Modal,
MessageType.Info,
ButtonsType.None,
"Úroveň dokončena! Abyste zvládli víc nepřátel, dostanete další život."
);
dialog.AddButton ("Další kolo", ResponseType.Accept);
dialog.AddButton ("Konec hry", ResponseType.Cancel);
dialog.Response += delegate(object o, ResponseArgs args) {
if (args.ResponseId == ResponseType.Accept) {
NextLevel (config);
} else {
Application.Quit ();
}
};
dialog.Run ();
dialog.Destroy ();
};
game.GameLost += delegate(object sender, EventArgs e) {
MessageDialog dialog = new MessageDialog (
this,
DialogFlags.Modal,
MessageType.Info,
ButtonsType.None,
"Konec hry"
);
dialog.AddButton ("Nová hra", ResponseType.Accept);
dialog.AddButton ("Konec", ResponseType.Close);
dialog.Response += delegate(object o, ResponseArgs args) {
if (args.ResponseId == ResponseType.Accept) {
MainClass.ShowLauncher ();
this.Destroy ();
} else {
Application.Quit ();
}
};
dialog.Run ();
dialog.Destroy ();
};
game.FilledAreaChanged += delegate(object sender, int value) {
fillCounter.Text = String.Format ("Zaplněno: {0}%", value);
};
game.LivesChanged += delegate(object sender, int value) {
lifeCounter.Text = String.Format ("Životy: {0}", value);
};
game.RemainingTimeChanged += delegate(object sender, int value) {
remainingTimeCounter.Text = string.Format ("Zbývající čas: {0} sekund", value);
};
game.Start (config);
level = 1;
updateLevelCounter ();
}
示例2: Settings
static Settings()
{
String SettingsPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constants.PACKAGE_NAME);
SettingsFile = System.IO.Path.Combine(SettingsPath, "settings.xml");
StreamReader reader = null;
try {
Console.WriteLine("Using configfile: " + SettingsFile);
reader = new StreamReader(SettingsFile);
Instance = (Settings) settingsSerializer.Deserialize(reader);
} catch(Exception e) {
Console.WriteLine("Couldn't load configfile: " + e.Message);
Instance = new Settings();
} finally {
if(reader != null)
reader.Close();
}
if(!Instance.SupertuxData.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) {
Instance.SupertuxData += System.IO.Path.DirectorySeparatorChar;
}
Console.WriteLine("Supertux is run as: " + Instance.SupertuxExe);
Console.WriteLine("Data files are in: " + Instance.SupertuxData);
// if data path does not exist, prompt user to change it before we try continue initializing
if (!new DirectoryInfo(System.IO.Path.GetDirectoryName(Instance.SupertuxData)).Exists) {
Console.WriteLine("Data path does not exist.");
MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.None, "The current data path, \"" + Instance.SupertuxData + "\", does not exist.\n\nEdit the settings to set a valid data path.");
md.AddButton(Gtk.Stock.No, ResponseType.No);
md.AddButton(Gtk.Stock.Edit, ResponseType.Yes);
if (md.Run() == (int)ResponseType.Yes) {
new SettingsDialog(true);
}
md.Destroy();
}
Resources.ResourceManager.Instance = new Resources.DefaultResourceManager(Instance.SupertuxData + "/");
}
示例3: ChangeConfirm
/// <summary>
/// Ask if realy continue if unsaved changes.
/// </summary>
/// <param name="act">What we would do ("quit", "close", "open another file" or such)</param>
/// <returns>True if continue otherwise false</returns>
private bool ChangeConfirm(string act)
{
if( modified ) {
MessageDialog md = new MessageDialog (MainWindow,
DialogFlags.DestroyWithParent,
MessageType.Warning,
ButtonsType.None, "Continue without saving changes?\n\nIf you " + act + " without saving, changes since the last save will be discarded.");
md.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
md.AddButton("Discard Changes", Gtk.ResponseType.Yes);
ResponseType result = (ResponseType)md.Run ();
md.Destroy();
if (result != ResponseType.Yes){
return false;
}
}
return true;
}
示例4: QuerySave
/// <summary>
/// Queries the user if he or she wants to save the current map before continuing. Pressing "cancel" invokes no delegates, while answering "yes" or "no" invokes an action.
/// </summary>
/// <param name="yes">
/// The delegate to be invoked if the user answers yes
/// </param>
/// <param name="no">
/// The delegate to be invoked if the user answers no
/// </para>
private void QuerySave(VoidDelegate yes, VoidDelegate no)
{
MessageDialog dlg = new MessageDialog(this, DialogFlags.DestroyWithParent | DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, true,"The current map has been modified. Would you like to save before continuing?");
dlg.AddButton("Cancel", ResponseType.Cancel);
dlg.Response += delegate(object o, ResponseArgs args) {
switch (args.ResponseId)
{
case ResponseType.Yes:
yes();
break;
case ResponseType.No:
no();
break;
}
};
dlg.Run();
dlg.Destroy();
}
示例5: Settings
static Settings()
{
String SettingsPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constants.PACKAGE_NAME);
SettingsFile = System.IO.Path.Combine(SettingsPath, "settings.xml");
StreamReader reader = null;
try {
LogManager.Log(LogLevel.Info, "Using configfile: " + SettingsFile);
reader = new StreamReader(SettingsFile);
Instance = (Settings) settingsSerializer.Deserialize(reader);
} catch(Exception e) {
LogManager.Log(LogLevel.Error, "Couldn't load configfile: " + e.Message);
LogManager.Log(LogLevel.Info, "Creating new config from scratch");
Instance = new Settings();
} finally {
if(reader != null)
reader.Close();
}
LogManager.Log(LogLevel.Info, "Supertux is run as: " + Instance.SupertuxExe);
if (Instance.SupertuxData != null)
LogManager.Log(LogLevel.Info, "Data files are in: " + Instance.SupertuxData);
else
LogManager.Log(LogLevel.Info, "Unable to find data files when querying supertux.");
// If data path does not exist, prompt user to change it before we try continue initializing
if (Instance.SupertuxData == null
|| !new DirectoryInfo(System.IO.Path.GetDirectoryName(Instance.SupertuxData)).Exists) {
LogManager.Log(LogLevel.Error, "Data path does not exist.");
String bad_data_path_msg;
if (Instance.SupertuxData == null)
bad_data_path_msg = "The data path could not be calculated." + Environment.NewLine
+ Environment.NewLine
+ "You must install a newer version of Supertux to use this version of the editor or specify the correct path to the supertux2 binary.";
else
bad_data_path_msg = "The current data path, `"
+ Instance.SupertuxData + "', does not exist." + Environment.NewLine
+ Environment.NewLine
+ "This means that your supertux installation (`" + Instance.SupertuxExe + "') is corrupted or incomplete.";
MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.None, bad_data_path_msg);
md.AddButton(Gtk.Stock.No, ResponseType.No);
md.AddButton(Gtk.Stock.Edit, ResponseType.Yes);
if (md.Run() == (int)ResponseType.Yes) {
new SettingsDialog(true);
}
md.Destroy();
}
Resources.ResourceManager.Instance = new Resources.DefaultResourceManager(Instance.SupertuxData + "/");
}