mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-05 15:56:15 +02:00
- Add GitHub and Download plugins button
- Add auto updater - Disable calender
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user