diff --git a/Source/AppScaffolding/LibationScaffolding.cs b/Source/AppScaffolding/LibationScaffolding.cs
index 31eaa833..84ec6fe4 100644
--- a/Source/AppScaffolding/LibationScaffolding.cs
+++ b/Source/AppScaffolding/LibationScaffolding.cs
@@ -29,6 +29,9 @@ namespace AppScaffolding
public static class LibationScaffolding
{
+ public const string RepositoryUrl = "ht" + "tps://github.com/rmcrackan/Libation";
+ public const string WebsiteUrl = "ht" + "tps://getlibation.com";
+ public const string RepositoryLatestUrl = "ht" + "tps://github.com/rmcrackan/Libation/releases/latest";
public static ReleaseIdentifier ReleaseIdentifier { get; private set; }
public static VarietyType Variety
=> ReleaseIdentifier == ReleaseIdentifier.WindowsClassic ? VarietyType.Classic
@@ -354,7 +357,7 @@ namespace AppScaffolding
public static UpgradeProperties GetLatestRelease()
{
// timed out
- (var latest, var zip) = getLatestRelease(TimeSpan.FromSeconds(10));
+ (var latest, var zip) = getLatestRelease(TimeSpan.FromSeconds(10000));
if (latest is null || zip is null)
return null;
@@ -363,9 +366,6 @@ namespace AppScaffolding
if (!Version.TryParse(latestVersionString, out var latestRelease))
return null;
- // we're up to date
- if (latestRelease <= BuildVersion)
- return null;
// we have an update
@@ -378,7 +378,7 @@ namespace AppScaffolding
zipUrl
});
- return new(zipUrl, latest.HtmlUrl, zip.Name, latestRelease);
+ return new(zipUrl, latest.HtmlUrl, zip.Name, latestRelease, latest.Body);
}
private static (Octokit.Release, Octokit.ReleaseAsset) getLatestRelease(TimeSpan timeout)
{
diff --git a/Source/AppScaffolding/UpgradeProperties.cs b/Source/AppScaffolding/UpgradeProperties.cs
index f1ca062f..d3a040f2 100644
--- a/Source/AppScaffolding/UpgradeProperties.cs
+++ b/Source/AppScaffolding/UpgradeProperties.cs
@@ -1,6 +1,34 @@
using System;
+using System.Text.RegularExpressions;
namespace AppScaffolding
{
- public record UpgradeProperties(string ZipUrl, string HtmlUrl, string ZipName, Version LatestRelease);
+ public record UpgradeProperties
+ {
+ private static readonly Regex linkstripper = new Regex(@"\[(.*)\]\(.*\)");
+ public string ZipUrl { get; }
+ public string HtmlUrl { get; }
+ public string ZipName { get; }
+ public Version LatestRelease { get; }
+ public string Notes { get; }
+
+ public UpgradeProperties(string zipUrl, string htmlUrl, string zipName, Version latestRelease, string notes)
+ {
+ ZipName = zipName;
+ HtmlUrl = htmlUrl;
+ ZipUrl = zipUrl;
+ LatestRelease = latestRelease;
+ Notes = stripMarkdownLinks(notes);
+ }
+ private string stripMarkdownLinks(string body)
+ {
+ body = body.Replace(@"\", "");
+ var matches = linkstripper.Matches(body);
+
+ foreach (Match match in matches)
+ body = body.Replace(match.Groups[0].Value, match.Groups[1].Value);
+
+ return body;
+ }
+ }
}
diff --git a/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml b/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml
deleted file mode 100644
index 7318396d..00000000
--- a/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml.cs b/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml.cs
deleted file mode 100644
index b00cbc91..00000000
--- a/Source/LibationAvalonia/Dialogs/UpgradeNotification.axaml.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using AppScaffolding;
-using Avalonia.Controls;
-using Dinah.Core;
-using System;
-
-namespace LibationAvalonia.Dialogs
-{
- public partial class UpgradeNotification : Window
- {
- public string VersionText { get; }
- public string DownloadLinkText { get; }
- private string PackageUrl { get; }
- public UpgradeNotification()
- {
- if (Design.IsDesignMode)
- {
- VersionText = "Libation version 8.7.0 is now available.";
- DownloadLinkText = "Download Libation.8.7.0-macos-chardonnay.tar.gz";
- DataContext = this;
- }
-
- InitializeComponent();
- }
-
- public UpgradeNotification(UpgradeProperties upgradeProperties) : this()
- {
- VersionText = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available.";
- PackageUrl = upgradeProperties.ZipUrl;
- DownloadLinkText = $"Download {upgradeProperties.ZipName}";
- DataContext = this;
- }
-
- public void OK_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => Close(DialogResult.OK);
- public void DontRemind_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => Close(DialogResult.Ignore);
- public void Download_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
- => Go.To.Url(PackageUrl);
- public void Website_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
- => Go.To.Url("ht" + "tps://getlibation.com");
- public void Github_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
- => Go.To.Url("ht" + "tps://github.com/rmcrackan/Libation");
- }
-}
diff --git a/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml b/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml
new file mode 100644
index 00000000..0478afa8
--- /dev/null
+++ b/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml.cs
new file mode 100644
index 00000000..eab6a26e
--- /dev/null
+++ b/Source/LibationAvalonia/Dialogs/UpgradeNotificationDialog.axaml.cs
@@ -0,0 +1,51 @@
+using AppScaffolding;
+using Avalonia.Controls;
+using Dinah.Core;
+using System;
+
+namespace LibationAvalonia.Dialogs
+{
+ public partial class UpgradeNotificationDialog : Window
+ {
+ private const string UpdateMessage = "There is a new version available. Would you like to update?\r\n\r\nAfter you close Libation, the upgrade will start automatically.";
+ public string TopMessage { get; }
+ public string DownloadLinkText { get; }
+ public string ReleaseNotes { get; }
+ public string OkText { get; }
+ private string PackageUrl { get; }
+ public UpgradeNotificationDialog()
+ {
+ if (Design.IsDesignMode)
+ {
+ TopMessage = UpdateMessage;
+ Title = "Libation version 8.7.0 is now available.";
+ DownloadLinkText = "Libation.8.7.0-macos-chardonnay.tar.gz";
+ ReleaseNotes = "New features:\r\n\r\n* 'Remove' now removes forever. Removed books won't be re-added on next scan\r\n* #406 : Right Click Menu for Stop-Light Icon\r\n* #398 : Grid, right-click, copy\r\n* Add option for user to choose custom temp folder\r\n* Build Docker image\r\n\r\nEnhancements\r\n\r\n* Illegal Char Replace dialog in Chardonnay\r\n* Filename character replacement allows replacing any char, not just illegal\r\n* #352 : Better error messages for license denial\r\n* Improve 'cancel download'\r\n\r\nThanks to @Mbucari (u/MSWMan), @pixil98 (u/pixil)\r\n\r\nLibation is a free, open source audible library manager for Windows. Decrypt, backup, organize, and search your audible library\r\n\r\nI intend to keep Libation free and open source, but if you want to leave a tip, who am I to argue?";
+ OkText = "Yes";
+ DataContext = this;
+ }
+
+ InitializeComponent();
+ }
+
+ public UpgradeNotificationDialog(UpgradeProperties upgradeProperties, bool canUpgrade) : this()
+ {
+ Title = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available.";
+ PackageUrl = upgradeProperties.ZipUrl;
+ DownloadLinkText = upgradeProperties.ZipName;
+ ReleaseNotes = upgradeProperties.Notes;
+ TopMessage = canUpgrade ? UpdateMessage : "";
+ OkText = canUpgrade ? "Yes" : "OK";
+ DataContext = this;
+ }
+
+ public void OK_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => Close(DialogResult.OK);
+ public void DontRemind_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => Close(DialogResult.Ignore);
+ public void Download_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
+ => Go.To.Url(PackageUrl);
+ public void Website_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
+ => Go.To.Url(LibationScaffolding.WebsiteUrl);
+ public void Github_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
+ => Go.To.Url(LibationScaffolding.RepositoryUrl);
+ }
+}
diff --git a/Source/LibationAvalonia/Views/MainWindow.Update.cs b/Source/LibationAvalonia/Views/MainWindow.Update.cs
index 0c5e9ac5..40f515cc 100644
--- a/Source/LibationAvalonia/Views/MainWindow.Update.cs
+++ b/Source/LibationAvalonia/Views/MainWindow.Update.cs
@@ -2,6 +2,7 @@
using LibationAvalonia.Dialogs;
using LibationFileManager;
using System;
+using System.IO;
using System.Threading.Tasks;
namespace LibationAvalonia.Views
@@ -25,11 +26,11 @@ namespace LibationAvalonia.Views
//Silently download the update in the background, save it to a temp file.
- var zipFile = System.IO.Path.GetTempFileName();
+ var zipFile = Path.GetTempFileName();
try
{
System.Net.Http.HttpClient cli = new();
- using var fs = System.IO.File.OpenWrite(zipFile);
+ using var fs = File.OpenWrite(zipFile);
using var dlStream = await cli.GetStreamAsync(new Uri(upgradeProperties.ZipUrl));
await dlStream.CopyToAsync(fs);
}
@@ -44,11 +45,11 @@ namespace LibationAvalonia.Views
void runWindowsUpgrader(string zipFile)
{
var thisExe = Environment.ProcessPath;
- var thisDir = System.IO.Path.GetDirectoryName(thisExe);
+ var thisDir = Path.GetDirectoryName(thisExe);
- var zipExtractor = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "ZipExtractor.exe");
+ var zipExtractor = Path.Combine(Path.GetTempPath(), "ZipExtractor.exe");
- System.IO.File.Copy("ZipExtractor.exe", zipExtractor, overwrite: true);
+ File.Copy("ZipExtractor.exe", zipExtractor, overwrite: true);
var psi = new System.Diagnostics.ProcessStartInfo()
{
@@ -69,7 +70,6 @@ namespace LibationAvalonia.Views
};
System.Diagnostics.Process.Start(psi);
- Environment.Exit(0);
}
try
@@ -77,34 +77,32 @@ namespace LibationAvalonia.Views
var upgradeProperties = await Task.Run(LibationScaffolding.GetLatestRelease);
if (upgradeProperties is null) return;
- if (Configuration.IsWindows)
+ const string ignoreUpdate = "IgnoreUpdate";
+ var config = Configuration.Instance;
+
+ if (config.GetString(ignoreUpdate) == upgradeProperties.LatestRelease.ToString())
+ return;
+
+ var notificationResult = await new UpgradeNotificationDialog(upgradeProperties, Configuration.IsWindows).ShowDialog(this);
+
+ if (notificationResult == DialogResult.Ignore)
+ config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
+
+ if (notificationResult != DialogResult.OK || !Configuration.IsWindows) return;
+
+ //Download the update file in the background,
+ //then wire up installaion on window close.
+
+ string zipFile = await downloadUpdate(upgradeProperties);
+
+ if (string.IsNullOrEmpty(zipFile) || !File.Exists(zipFile))
+ return;
+
+ Closed += (_, _) =>
{
- string zipFile = await downloadUpdate(upgradeProperties);
-
- if (string.IsNullOrEmpty(zipFile) || !System.IO.File.Exists(zipFile))
- return;
-
- var result = await MessageBox.Show(this, $"{upgradeProperties.HtmlUrl}\r\n\r\nWould you like to upgrade now?", "New version available", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
-
- if (result == DialogResult.Yes)
+ if (File.Exists(zipFile))
runWindowsUpgrader(zipFile);
- }
- else
- {
- //We're not going to have a solution for in-place upgrade on
- //linux/mac, so just notify that an update is available.
-
- const string ignoreUpdate = "IgnoreUpdate";
- var config = Configuration.Instance;
-
- if (config.GetString(ignoreUpdate) == upgradeProperties.LatestRelease.ToString())
- return;
-
- var notificationResult = await new UpgradeNotification(upgradeProperties).ShowDialog(this);
-
- if (notificationResult == DialogResult.Ignore)
- config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
- }
+ };
}
catch (Exception ex)
{
diff --git a/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.Designer.cs b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.Designer.cs
new file mode 100644
index 00000000..581e0b9e
--- /dev/null
+++ b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.Designer.cs
@@ -0,0 +1,221 @@
+namespace LibationWinForms.Dialogs
+{
+ partial class UpgradeNotificationDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.Label label1;
+ System.Windows.Forms.Label label2;
+ System.Windows.Forms.GroupBox groupBox1;
+ System.Windows.Forms.LinkLabel linkLabel3;
+ System.Windows.Forms.LinkLabel linkLabel2;
+ System.Windows.Forms.Label label3;
+ this.packageDlLink = new System.Windows.Forms.LinkLabel();
+ this.releaseNotesTbox = new System.Windows.Forms.TextBox();
+ this.dontRemindBtn = new System.Windows.Forms.Button();
+ this.yesBtn = new System.Windows.Forms.Button();
+ this.noBtn = new System.Windows.Forms.Button();
+ label1 = new System.Windows.Forms.Label();
+ label2 = new System.Windows.Forms.Label();
+ groupBox1 = new System.Windows.Forms.GroupBox();
+ linkLabel3 = new System.Windows.Forms.LinkLabel();
+ linkLabel2 = new System.Windows.Forms.LinkLabel();
+ label3 = new System.Windows.Forms.Label();
+ groupBox1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ label1.Location = new System.Drawing.Point(12, 9);
+ label1.Name = "label1";
+ label1.Size = new System.Drawing.Size(416, 21);
+ label1.TabIndex = 0;
+ label1.Text = "There is a new version available. Would you like to update?";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new System.Drawing.Point(12, 39);
+ label2.Name = "label2";
+ label2.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
+ label2.Size = new System.Drawing.Size(327, 25);
+ label2.TabIndex = 1;
+ label2.Text = "After you close Libation, the upgrade will start automatically.";
+ //
+ // groupBox1
+ //
+ groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ groupBox1.Controls.Add(linkLabel3);
+ groupBox1.Controls.Add(linkLabel2);
+ groupBox1.Controls.Add(this.packageDlLink);
+ groupBox1.Controls.Add(label3);
+ groupBox1.Controls.Add(this.releaseNotesTbox);
+ groupBox1.Location = new System.Drawing.Point(12, 67);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new System.Drawing.Size(531, 303);
+ groupBox1.TabIndex = 3;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Release Information";
+ //
+ // linkLabel3
+ //
+ linkLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ linkLabel3.AutoSize = true;
+ linkLabel3.Location = new System.Drawing.Point(348, 250);
+ linkLabel3.Name = "linkLabel3";
+ linkLabel3.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
+ linkLabel3.Size = new System.Drawing.Size(177, 25);
+ linkLabel3.TabIndex = 1;
+ linkLabel3.TabStop = true;
+ linkLabel3.Text = "View the source code on GitHub";
+ linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.GoToGithub_LinkClicked);
+ //
+ // linkLabel2
+ //
+ linkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ linkLabel2.AutoSize = true;
+ linkLabel2.Location = new System.Drawing.Point(392, 275);
+ linkLabel2.Name = "linkLabel2";
+ linkLabel2.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
+ linkLabel2.Size = new System.Drawing.Size(133, 25);
+ linkLabel2.TabIndex = 2;
+ linkLabel2.TabStop = true;
+ linkLabel2.Text = "Go to Libation\'s website";
+ linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.GoToWebsite_LinkClicked);
+ //
+ // packageDlLink
+ //
+ this.packageDlLink.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.packageDlLink.AutoSize = true;
+ this.packageDlLink.Location = new System.Drawing.Point(6, 275);
+ this.packageDlLink.Name = "packageDlLink";
+ this.packageDlLink.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
+ this.packageDlLink.Size = new System.Drawing.Size(157, 25);
+ this.packageDlLink.TabIndex = 3;
+ this.packageDlLink.TabStop = true;
+ this.packageDlLink.Text = "[Release Package File Name]";
+ this.packageDlLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.PackageDlLink_LinkClicked);
+ //
+ // label3
+ //
+ label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ label3.AutoSize = true;
+ label3.Location = new System.Drawing.Point(6, 250);
+ label3.Name = "label3";
+ label3.Size = new System.Drawing.Size(106, 15);
+ label3.TabIndex = 3;
+ label3.Text = "Download Release:";
+ //
+ // releaseNotesTbox
+ //
+ this.releaseNotesTbox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.releaseNotesTbox.Location = new System.Drawing.Point(6, 22);
+ this.releaseNotesTbox.Multiline = true;
+ this.releaseNotesTbox.Name = "releaseNotesTbox";
+ this.releaseNotesTbox.ReadOnly = true;
+ this.releaseNotesTbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.releaseNotesTbox.Size = new System.Drawing.Size(519, 214);
+ this.releaseNotesTbox.TabIndex = 0;
+ //
+ // dontRemindBtn
+ //
+ this.dontRemindBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.dontRemindBtn.Location = new System.Drawing.Point(12, 376);
+ this.dontRemindBtn.Name = "dontRemindBtn";
+ this.dontRemindBtn.Size = new System.Drawing.Size(121, 38);
+ this.dontRemindBtn.TabIndex = 4;
+ this.dontRemindBtn.Text = "Don\'t remind me about this release";
+ this.dontRemindBtn.UseVisualStyleBackColor = true;
+ this.dontRemindBtn.Click += new System.EventHandler(this.DontRemindBtn_Click);
+ //
+ // yesBtn
+ //
+ this.yesBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.yesBtn.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.yesBtn.Location = new System.Drawing.Point(440, 376);
+ this.yesBtn.Name = "yesBtn";
+ this.yesBtn.Size = new System.Drawing.Size(103, 38);
+ this.yesBtn.TabIndex = 6;
+ this.yesBtn.Text = "Yes";
+ this.yesBtn.UseVisualStyleBackColor = true;
+ this.yesBtn.Click += new System.EventHandler(this.YesBtn_Click);
+ //
+ // noBtn
+ //
+ this.noBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.noBtn.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.noBtn.Location = new System.Drawing.Point(360, 376);
+ this.noBtn.Name = "noBtn";
+ this.noBtn.Size = new System.Drawing.Size(74, 38);
+ this.noBtn.TabIndex = 5;
+ this.noBtn.Text = "No";
+ this.noBtn.UseVisualStyleBackColor = true;
+ this.noBtn.Click += new System.EventHandler(this.NoBtn_Click);
+ //
+ // UpgradeNotificationDialog
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(555, 426);
+ this.Controls.Add(this.noBtn);
+ this.Controls.Add(this.yesBtn);
+ this.Controls.Add(this.dontRemindBtn);
+ this.Controls.Add(groupBox1);
+ this.Controls.Add(label2);
+ this.Controls.Add(label1);
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.MinimumSize = new System.Drawing.Size(460, 420);
+ this.Name = "UpgradeNotificationDialog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "UpgradeNotificationDialog";
+ groupBox1.ResumeLayout(false);
+ groupBox1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox releaseNotesTbox;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.LinkLabel linkLabel3;
+ private System.Windows.Forms.LinkLabel linkLabel2;
+ private System.Windows.Forms.LinkLabel packageDlLink;
+ private System.Windows.Forms.Button dontRemindBtn;
+ private System.Windows.Forms.Button yesBtn;
+ private System.Windows.Forms.Button noBtn;
+ }
+}
\ No newline at end of file
diff --git a/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.cs b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.cs
new file mode 100644
index 00000000..8bb7ebdc
--- /dev/null
+++ b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.cs
@@ -0,0 +1,71 @@
+using AppScaffolding;
+using Dinah.Core;
+using LibationFileManager;
+using System;
+using System.Windows.Forms;
+
+namespace LibationWinForms.Dialogs
+{
+ public partial class UpgradeNotificationDialog : Form
+ {
+ private string PackageUrl { get; }
+
+ public UpgradeNotificationDialog()
+ {
+ InitializeComponent();
+ this.SetLibationIcon();
+ }
+
+ public UpgradeNotificationDialog(UpgradeProperties upgradeProperties) : this()
+ {
+ Text = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available.";
+ PackageUrl = upgradeProperties.ZipUrl;
+ packageDlLink.Text = upgradeProperties.ZipName;
+ releaseNotesTbox.Text = upgradeProperties.Notes;
+
+ Shown += (_, _) => yesBtn.Focus();
+ Load += UpgradeNotificationDialog_Load;
+ }
+
+ private void UpgradeNotificationDialog_Load(object sender, EventArgs e)
+ {
+ //This dialog starts before Form1, soposition it at the center of where Form1 will be.
+ var savedState = Configuration.Instance.GetNonString(nameof(Form1));
+
+ if (savedState is null) return;
+
+ int x = savedState.X + (savedState.Width - Width) / 2;
+ int y = savedState.Y + (savedState.Height - Height) / 2;
+
+ Location = new(x, y);
+ TopMost = true;
+ }
+
+ private void PackageDlLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ => Go.To.Url(PackageUrl);
+
+ private void GoToGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ => Go.To.Url(LibationScaffolding.RepositoryUrl);
+
+ private void GoToWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ => Go.To.Url(LibationScaffolding.WebsiteUrl);
+
+ private void YesBtn_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Yes;
+ Close();
+ }
+
+ private void DontRemindBtn_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Ignore;
+ Close();
+ }
+
+ private void NoBtn_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.No;
+ Close();
+ }
+ }
+}
diff --git a/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.resx b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.resx
new file mode 100644
index 00000000..dbc7c549
--- /dev/null
+++ b/Source/LibationWinForms/Dialogs/UpgradeNotificationDialog.resx
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
\ No newline at end of file
diff --git a/Source/LibationWinForms/FormSaveExtension.cs b/Source/LibationWinForms/FormSaveExtension.cs
index 9789e9eb..f5763ad3 100644
--- a/Source/LibationWinForms/FormSaveExtension.cs
+++ b/Source/LibationWinForms/FormSaveExtension.cs
@@ -89,14 +89,13 @@ namespace LibationWinForms
config.SetNonString(saveState, form.Name);
}
-
- private record FormSizeAndPosition
- {
- public int X;
- public int Y;
- public int Height;
- public int Width;
- public bool IsMaximized;
- }
+ }
+ record FormSizeAndPosition
+ {
+ public int X;
+ public int Y;
+ public int Height;
+ public int Width;
+ public bool IsMaximized;
}
}
diff --git a/Source/LibationWinForms/Program.cs b/Source/LibationWinForms/Program.cs
index 53833005..7cb9bc75 100644
--- a/Source/LibationWinForms/Program.cs
+++ b/Source/LibationWinForms/Program.cs
@@ -188,7 +188,7 @@ namespace LibationWinForms
return;
}
- Updater.Run(upgradeProperties.LatestRelease, upgradeProperties.ZipUrl);
+ Updater.Run(upgradeProperties);
}
private static void postLoggingGlobalExceptionHandling()
diff --git a/Source/LibationWinForms/Updater.cs b/Source/LibationWinForms/Updater.cs
index 9660c7ce..6e2c1eb7 100644
--- a/Source/LibationWinForms/Updater.cs
+++ b/Source/LibationWinForms/Updater.cs
@@ -1,50 +1,57 @@
using System;
using System.Windows.Forms;
+using AppScaffolding;
using AutoUpdaterDotNET;
+using LibationFileManager;
+using LibationWinForms.Dialogs;
namespace LibationWinForms
{
public static class Updater
{
- private const string REPO_URL = "https://github.com/rmcrackan/Libation/releases/latest";
-
- public static void Run(Version latestVersionOnServer, string downloadZipUrl)
- => Run(latestVersionOnServer.ToString(), downloadZipUrl);
- public static void Run(string latestVersionOnServer, string downloadZipUrl)
+ public static void Run(UpgradeProperties upgradeProperties)
{
+ string latestVersionOnServer = upgradeProperties.LatestRelease.ToString();
+ string downloadZipUrl = upgradeProperties.ZipUrl;
AutoUpdater.ParseUpdateInfoEvent +=
args => args.UpdateInfo = new()
{
CurrentVersion = latestVersionOnServer,
DownloadURL = downloadZipUrl,
- ChangelogURL = REPO_URL
+ ChangelogURL = LibationScaffolding.RepositoryLatestUrl
};
+
+ void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
+ {
+ if (args is null || !args.IsUpdateAvailable)
+ return;
+
+ const string ignoreUpdate = "IgnoreUpdate";
+ var config = Configuration.Instance;
+
+ if (config.GetString(ignoreUpdate) == args.CurrentVersion)
+ return;
+
+ var notificationResult = new UpgradeNotificationDialog(upgradeProperties).ShowDialog();
+
+ if (notificationResult == DialogResult.Ignore)
+ config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
+
+ if (notificationResult != DialogResult.Yes) return;
+
+ try
+ {
+ Serilog.Log.Logger.Information("Start upgrade. {@DebugInfo}", new { CurrentlyInstalled = args.InstalledVersion, TargetVersion = args.CurrentVersion });
+ AutoUpdater.DownloadUpdate(args);
+ }
+ catch (Exception ex)
+ {
+ MessageBoxLib.ShowAdminAlert(null, "Error downloading update", "Error downloading update", ex);
+ }
+ }
+
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
- AutoUpdater.Start(REPO_URL);
- }
-
- private static void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
- {
- if (args is null || !args.IsUpdateAvailable)
- return;
-
- var dialogResult = MessageBox.Show(string.Format(
- $"There is a new version available. Would you like to update?\r\n\r\nAfter you close Libation, the upgrade will start automatically."),
- "Update Available",
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Information);
- if (dialogResult != DialogResult.Yes)
- return;
-
- try
- {
- Serilog.Log.Logger.Information("Start upgrade. {@DebugInfo}", new { CurrentlyInstalled = args.InstalledVersion, TargetVersion = args.CurrentVersion });
- AutoUpdater.DownloadUpdate(args);
- }
- catch (Exception ex)
- {
- MessageBoxLib.ShowAdminAlert(null, "Error downloading update", "Error downloading update", ex);
- }
+ AutoUpdater.Start(LibationScaffolding.RepositoryLatestUrl);
}
}
}