我目前在我的 Quit 方法中有以下代码:
public void QuitApplication(FormClosingEventArgs a, bool b)
{
bool c = Properties.App.Default.AskToExit, d = Properties.App.Default.AskToSave;
if (!b)
{
if (!c && !d)
{
}
else if (!c)
{
if (YesNoMessageBox("Save Before Quit?", "Would you like to save your settings before you Quit?") == DialogResult.Yes)
{
_debug("Settings Saved");
//Properties.App.Default.Save();
//Properties.Settings.Default.Save();
}
}
else if (!d)
{
if (YesNoMessageBox("Really Quit?", "Are you sure you want to quit?") == DialogResult.No)
{
a.Cancel = true;
}
}
else
{
if (YesNoMessageBox("Really Quit?", "Are you sure you want to quit?") == DialogResult.Yes)
{
if (YesNoMessageBox("Save Before Quit?", "Would you like to save your settings before you Quit?") == DialogResult.Yes)
{
_debug("Settings Saved");
//Properties.App.Default.Save();
//Properties.Settings.Default.Save();
}
}
else
{
a.Cancel = true;
}
}
}
}
这用于检查用户是否要退出并在需要时保存。但是,我有两个选项可以设置为在调用此方法时忽略要求保存或要求退出。我想到的比较这些的唯一方法是上面的,我相信你可以做到,所以重复次数要少得多。(保存方法已被注释掉,因为应用程序仍在开发中,设置文件尚未完成)。
任何人都可以帮忙吗?