in sources/Google.Solutions.IapDesktop.Application/ToolWindows/Update/CheckForUpdateCommand.cs [97:216]
internal void PromptForAction(IRelease? latestRelease)
{
if (latestRelease == null)
{
return;
}
else if (IsUpdateAdvised(latestRelease))
{
var nameOfUpdate = this.updatePolicy.GetReleaseTrack(latestRelease) switch
{
ReleaseTrack.Canary => "An optional update",
ReleaseTrack.Critical => "A critical security update",
_ => "An update",
};
//
// Prompt for upgrade.
//
var dialogParameters = new TaskDialogParameters(
"Update available",
$"{nameOfUpdate} is available for IAP Desktop.\n\n" +
$"Installed version: {this.install.CurrentVersion}\n" +
$"Available version: {latestRelease.TagVersion}",
"Would you like to download the update now?")
{
Icon = TaskDialogIcon.ShieldGreenBackground,
};
dialogParameters.Buttons.Add(TaskDialogStandardButton.Cancel);
//
// Get download URL.
//
// In case there are multple download URLs, prefer the
// one that matches the current platform.
//
var downloadButton = new TaskDialogCommandLinkButton(
"Yes, download now",
DialogResult.OK);
if (!latestRelease.TryGetDownloadUrl(
ProcessEnvironment.ProcessArchitecture,
out var downloadUrl) ||
downloadUrl == null)
{
downloadUrl = latestRelease.DetailsUrl;
}
downloadButton.Click += (_, __) => this.browser.Navigate(downloadUrl);
dialogParameters.Buttons.Add(downloadButton);
//
// Show release notes.
//
var showReleaseNotes = new TaskDialogCommandLinkButton(
"Show release notes",
DialogResult.OK);
showReleaseNotes.Click += (_, __) => this.browser.Navigate(
latestRelease.DetailsUrl);
dialogParameters.Buttons.Add(showReleaseNotes);
//
// No, later.
//
var laterButton = new TaskDialogCommandLinkButton(
"No, download later",
DialogResult.Cancel);
dialogParameters.Buttons.Add(laterButton);
this.taskDialog.ShowDialog(
this.parentWindow,
dialogParameters);
}
else if (
latestRelease.Survey != null &&
this.EnableSurveys &&
(this.LastSurveyVersion == null || this.LastSurveyVersion < latestRelease.TagVersion))
{
var dialogParameters = new TaskDialogParameters(
"Tell us what you think",
latestRelease.Survey.Title,
latestRelease.Survey.Description);
dialogParameters.Buttons.Add(TaskDialogStandardButton.Cancel);
//
// Open survey.
//
var openButton = new TaskDialogCommandLinkButton(
"Start survey",
DialogResult.OK);
openButton.Click += (_, __) =>
{
this.browser.Navigate(latestRelease.Survey.Url);
this.LastSurveyVersion = latestRelease.TagVersion;
};
dialogParameters.Buttons.Add(openButton);
//
// No, later.
//
var laterButton = new TaskDialogCommandLinkButton(
"Maybe later",
DialogResult.Cancel);
dialogParameters.Buttons.Add(laterButton);
//
// Opt-out.
//
dialogParameters.VerificationCheckBox = new TaskDialogVerificationCheckBox(
"Don't show this message again")
{
Checked = false
};
this.taskDialog.ShowDialog(
this.parentWindow,
dialogParameters);
this.EnableSurveys = !dialogParameters.VerificationCheckBox.Checked;
}
}