void updateHelper_ProgressChanged(object sender, UpdateHelperData e)
{
switch (e.ResponseType)
{
case Response.Failed:
// show the error icon & menu
// and set last successful step
UpdateStepFailed(UpdateStepToUpdateStepOn(e.UpdateStep), new FailArgs { ErrorTitle = e.ExtraData[0], ErrorMessage = e.ExtraData[1] });
break;
case Response.Succeeded:
switch (e.UpdateStep)
{
case UpdateStep.CheckForUpdate:
AutoUpdaterInfo.LastCheckedForUpdate = DateTime.Now;
// there's an update available
if (e.ExtraData.Count != 0)
{
version = e.ExtraData[0];
// if there are changes, save them
if (e.ExtraData.Count > 1)
{
changes = e.ExtraData[1];
changesAreRTF = e.ExtraDataIsRTF[1];
}
// save the changes to the AutoUpdateInfo file
AutoUpdaterInfo.UpdateVersion = version;
AutoUpdaterInfo.ChangesInLatestVersion = changes;
AutoUpdaterInfo.ChangesIsRTF = changesAreRTF;
}
else
{
// Clear saved version details for cases where we're
// continuing an update (the version details filled
// in from the AutoUpdaterInfo file) however,
// wyUpdate reports your app has since been updated.
// Thus we need to clear the saved info.
version = null;
changes = null;
changesAreRTF = false;
AutoUpdaterInfo.ClearSuccessError();
}
break;
case UpdateStep.DownloadUpdate:
UpdateStepOn = UpdateStepOn.UpdateDownloaded;
break;
case UpdateStep.RestartInfo:
// show client & send the "begin update" message
updateHelper.InstallNow();
// close this application so it can be updated
// use either the custom handler or Environment.Exit();
if (CloseAppNow != null)
CloseAppNow(this, EventArgs.Empty);
else
Environment.Exit(0);
return;
}
StartNextStep(e.UpdateStep);
break;
case Response.Progress:
// call the progress changed event
if (ProgressChanged != null)
ProgressChanged(this, e.Progress);
break;
}
}