private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
string uri;
_hasConnection = ConnectionExists(out uri);
if (!_hasConnection)
{
MessageBox.Show(string.Format("Could not connect to {0}", uri), "Error");
return;
}
// Promp user.
DialogResult result =
MessageBox.Show(
@"Would you like to synchronise your content with the distribution server before exiting?",
@"Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
// Sync at user behest.
if (result == DialogResult.Yes)
{
LogGenerator.CreateContentLog();
var ftpDialog = new SyncDialog(new SyncInfo(Resources.ContentDirectory, "Content/", SyncJobType.Upload));
ftpDialog.ShowDialog();
}
// Cancel if this was all a horrible mistake.
if (result == DialogResult.Cancel)
e.Cancel = true;
}