private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
ExitQuestion dlg = null;
Properties.Settings.Default.WindowState = WindowState;
if (WindowState == FormWindowState.Normal)
{
Properties.Settings.Default.WindowSize = Size;
Properties.Settings.Default.WindowLocation = Location;
}
else
{
Properties.Settings.Default.WindowSize = RestoreBounds.Size;
Properties.Settings.Default.WindowLocation = RestoreBounds.Location;
}
if (Properties.Settings.Default.AskForTerminate)
{
TimeSpan time =
new TimeSpan(DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).Subtract
(StartTime);
dlg = new ExitQuestion(time, NumberOfEdits, "");
dlg.ShowDialog();
Properties.Settings.Default.AskForTerminate = !dlg.CheckBoxDontAskAgain;
}
// save user persistent settings
Properties.Settings.Default.Save();
if (dlg != null)
{
switch (dlg.DialogResult)
{
case DialogResult.OK:
CloseDownAWB();
break;
case DialogResult.Cancel:
e.Cancel = true;
break;
}
}
else if (!Properties.Settings.Default.AskForTerminate)
{
CloseDownAWB();
}
else
{
e.Cancel = true;
}
}