mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Added initial Autoupdater.NET config
Have created the basic setup using the JSON version of the Autoupdater.NET config shown on the Autoupdater.NET website at: https://github.com/ravibpatel/AutoUpdater.NET JSON file to be stored on the update website: { "version":"0.2.0.0", "url":"http://displaymagician.com/downloads/DisplayMagicianSetup.zip", "changelog":"https://github.com/terrymacdonald/DisplayMagician/releases", "mandatory":{ "value":false, "minVersion": "0.1.0.0", "mode":1 }, "checksum":{ "value":"E5F59E50FC91A9E52634FFCB11F32BD37FE0E2F1", "hashingAlgorithm":"SHA1" } }
This commit is contained in:
parent
05bb163312
commit
c662681860
@ -214,6 +214,9 @@
|
||||
<PackageReference Include="AudioSwitcher.AudioApi.CoreAudio">
|
||||
<Version>4.0.0-alpha5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Autoupdater.NET.Official">
|
||||
<Version>1.6.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CircularProgressBar">
|
||||
<Version>2.8.0.16</Version>
|
||||
</PackageReference>
|
||||
|
@ -13,6 +13,9 @@ using System.Reflection;
|
||||
using DisplayMagician.Shared;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
using AutoUpdaterDotNET;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
|
||||
namespace DisplayMagician.UIForms
|
||||
{
|
||||
@ -121,6 +124,9 @@ namespace DisplayMagician.UIForms
|
||||
// Start loading the Steam Games just after the Main form opens
|
||||
//SteamGame.GetAllInstalledGames();
|
||||
EnableShortcutButtonIfProfiles();
|
||||
|
||||
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
|
||||
AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.json");
|
||||
}
|
||||
|
||||
private void EnableShortcutButtonIfProfiles()
|
||||
@ -277,7 +283,97 @@ namespace DisplayMagician.UIForms
|
||||
|
||||
private void MainForm_Activated(object sender, EventArgs e)
|
||||
{
|
||||
//EnableShortcutButtonIfProfiles();
|
||||
EnableShortcutButtonIfProfiles();
|
||||
}
|
||||
|
||||
private void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
|
||||
{
|
||||
dynamic json = JsonConvert.DeserializeObject(args.RemoteData);
|
||||
args.UpdateInfo = new UpdateInfoEventArgs
|
||||
{
|
||||
CurrentVersion = json.version,
|
||||
ChangelogURL = json.changelog,
|
||||
DownloadURL = json.url,
|
||||
Mandatory = new Mandatory
|
||||
{
|
||||
Value = json.mandatory.value,
|
||||
UpdateMode = json.mandatory.mode,
|
||||
MinimumVersion = json.mandatory.minVersion
|
||||
},
|
||||
CheckSum = new CheckSum
|
||||
{
|
||||
Value = json.checksum.value,
|
||||
HashingAlgorithm = json.checksum.hashingAlgorithm
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
|
||||
{
|
||||
if (args.Error == null)
|
||||
{
|
||||
if (args.IsUpdateAvailable)
|
||||
{
|
||||
DialogResult dialogResult;
|
||||
if (args.Mandatory.Value)
|
||||
{
|
||||
dialogResult =
|
||||
MessageBox.Show(
|
||||
$@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application.", @"Update Available",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
dialogResult =
|
||||
MessageBox.Show(
|
||||
$@"There is new version {args.CurrentVersion} available. You are using version {
|
||||
args.InstalledVersion
|
||||
}. Do you want to update the application now?", @"Update Available",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
// Uncomment the following line if you want to show standard update dialog instead.
|
||||
// AutoUpdater.ShowUpdateForm(args);
|
||||
|
||||
if (dialogResult.Equals(DialogResult.Yes) || dialogResult.Equals(DialogResult.OK))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (AutoUpdater.DownloadUpdate(args))
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(@"There is no update available please try again later.", @"No update available",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.Error is WebException)
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"There is a problem reaching update server. Please check your internet connection and try again later.",
|
||||
@"Update Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(args.Error.Message,
|
||||
args.Error.GetType().ToString(), MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "DisplayMagician - Setup Game Shortcuts";
|
||||
//this.Activated += new System.EventHandler(this.ShortcutLibraryForm_Activated);
|
||||
this.Activated += new System.EventHandler(this.ShortcutLibraryForm_Activated);
|
||||
this.Load += new System.EventHandler(this.ShortcutLibraryForm_Load);
|
||||
this.cms_shortcuts.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
@ -279,7 +279,7 @@ namespace DisplayMagician.UIForms
|
||||
|
||||
private void ShortcutLibraryForm_Activated(object sender, EventArgs e)
|
||||
{
|
||||
//RemoveWarningIfShortcuts();
|
||||
RemoveWarningIfShortcuts();
|
||||
}
|
||||
|
||||
private void tsmi_save_to_desktop_Click(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user