- Add GitHub and Download plugins button

- Add auto updater
- Disable calender
This commit is contained in:
Stone-Red-Code
2021-09-14 19:03:36 +02:00
parent 6e4757adea
commit 7d2f68a66a
10 changed files with 77 additions and 24 deletions
+34 -2
View File
@@ -1,4 +1,6 @@
using System;
using AlwaysUpToDate;
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows;
@@ -10,6 +12,11 @@ namespace DesktopMagic
public partial class App : Application
{
private Mutex _mutex;
#if DEBUG
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json");
#else
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif
public App()
{
@@ -25,11 +32,36 @@ namespace DesktopMagic
}
else
{
// Add Event handler to exit event.
Exit += CloseMutexHandler;
updater.ProgressChanged += Updater_ProgressChanged;
updater.OnException += Updater_OnException;
updater.NoUpdateAvailible += Updater_NoUpdateAvailible;
updater.UpdateAvailible += Updater_UpdateAvailible;
updater.Start();
}
}
private void Updater_UpdateAvailible(string version, string additionalInformation)
{
updater.Update();
}
private void Updater_NoUpdateAvailible()
{
Debug.WriteLine("No update avalible.");
}
private void Updater_OnException(Exception exception)
{
Debug.WriteLine("Update exception: " + exception);
}
private void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage)
{
Debug.WriteLine($"{progressPercentage}% {totalBytesDownloaded}/{totalFileSize}");
}
protected virtual void CloseMutexHandler(object sender, EventArgs e)
{
_mutex?.Close();