Created
February 7, 2011 14:10
-
-
Save ToJans/814404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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