Skip to content

Instantly share code, notes, and snippets.

@ToJans
Created February 7, 2011 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToJans/814404 to your computer and use it in GitHub Desktop.
Save ToJans/814404 to your computer and use it in GitHub Desktop.
public interface IUpdaterUI
{
string Message {set;}
int Progress {set;}
bool AllowContinue {set;}
bool AllowCancel {set;}
void Close();
}
private void DownloadUpdates(IUpdaterUI ui)
{
try
{
ui.Progress = 5;
ui.Message = AvailableUpdate.DownloadingUpdateLabelText;
var IsSoftwareUpdate = AvailableUpdate.SoftwareUpdateAvailable;
var IsDataUpdate = !IsSoftwareUpdate && AvailableUpdate.DataUpdateAvailable;
var IsUpdate = IsSoftwareUpdate || IsDataUpdate;
if (IsUpdate) ui.Progress = 50;
if (IsSoftwareUpdate) UpdateSoftware();
if (IsDataUpdate) UpdateData();
if (IsUpdate) ui.Progress = 100;
if (IsSoftwareUpdate)
{
ui.Close();
}
if (IsDataUpdate)
{
ui.Message = "Complete";
ui.AllowCancel=false;
ui.AllowContinue = true;
}
}
catch (Exception e)
{
// error handler code here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment