private void Button_Update_Click(object sender, EventArgs e) { if (UpdateAvailable) { Form_Main.DownloadUpdate(); } else { Interface.VersionCheck.Request(VersionCheck_Callback_FromButton); } }
public void VersionCheck_Callback_OnLoad(Interface.VersionCheck.RequestResult RequestResult) { // Thread safe invoke handling if (InvokeRequired) { Invoke(new Action <Interface.VersionCheck.RequestResult>(VersionCheck_Callback_OnLoad), RequestResult); return; } if (RequestResult == Interface.VersionCheck.RequestResult.UpdateFound) { if (!Settings.Config.PromptUpdate) { CheckUpdateButtonStatus(); return; } DialogResult Choice = MessageBox.Show( string.Format( "New update (version {0}) available!\nDo you want to download the update now?", Settings.Config.LatestVersion ), "Tasual", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Choice == DialogResult.Yes) { Close(); Form_Main.DownloadUpdate(); } else { CheckUpdateButtonStatus(); } } }
public void VersionCheck_Callback_FromButton(Interface.VersionCheck.RequestResult RequestResult) { // Thread safe invoke handling if (InvokeRequired) { Invoke(new Action <Interface.VersionCheck.RequestResult>(VersionCheck_Callback_FromButton), RequestResult); return; } switch (RequestResult) { case Interface.VersionCheck.RequestResult.UpdateFound: { if (!Settings.Config.PromptUpdate) { return; } DialogResult Choice = MessageBox.Show( string.Format( "New update (version {0}) available!\nDo you want to download the update now?", Settings.Config.LatestVersion ), "Tasual", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Choice == DialogResult.Yes) { Close(); Form_Main.DownloadUpdate(); } else { CheckUpdateButtonStatus(); } break; } case Interface.VersionCheck.RequestResult.UpToDate: { MessageBox.Show( "Already up to date", "Tasual", MessageBoxButtons.OK, MessageBoxIcon.Information ); break; } case Interface.VersionCheck.RequestResult.NotCompleted: case Interface.VersionCheck.RequestResult.BadRequest: { MessageBox.Show( "Failed to check for updates (check network connection)", "Tasual", MessageBoxButtons.OK, MessageBoxIcon.Error ); break; } } }