aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
index 4cc4ee46f..25a4f8c4b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -12,6 +12,7 @@ using Tango.PPC.Common;
using Tango.PPC.Common.MachineUpdate;
using Tango.PPC.Common.Web;
using Tango.PPC.UI.Dialogs;
+using Tango.PPC.UI.Notifications.NotificationItems;
using Tango.PPC.UI.ViewsContracts;
namespace Tango.PPC.UI.ViewModels
@@ -36,6 +37,7 @@ namespace Tango.PPC.UI.ViewModels
private DbCompareResult _db_compare_result;
private bool _isChecking;
private CheckForUpdateResponse _checkUpdateResponse;
+ private UpdateAvailableNotificationItem _updateNotificationItem;
#region Properties
@@ -125,6 +127,8 @@ namespace Tango.PPC.UI.ViewModels
NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
NavigateTo(MachineUpdateView.UpdateCheckView);
});
+
+ machineUpdateManager.UpdateAvailable += MachineUpdateManager_UpdateAvailable;
}
#endregion
@@ -280,6 +284,24 @@ namespace Tango.PPC.UI.ViewModels
{
RunPostUpdatePackages();
}
+ else
+ {
+ MachineUpdateManager.AutoCheckForUpdates = MachineProvider.Machine.AutoCheckForUpdates;
+ }
+ }
+
+ /// <summary>
+ /// Called when the navigation system has navigated to this VM view.
+ /// </summary>
+ public override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+
+ if (_updateNotificationItem != null)
+ {
+ _updateNotificationItem.Close();
+ _updateNotificationItem = null;
+ }
}
#endregion
@@ -389,5 +411,39 @@ namespace Tango.PPC.UI.ViewModels
}
#endregion
+
+ #region Auto Check For Update
+
+ private void MachineUpdateManager_UpdateAvailable(object sender, CheckForUpdateResponse e)
+ {
+ if (!IsVisible && _updateNotificationItem == null)
+ {
+ LogManager.Log($"New application version detected ({e.Version}). Pushing notification...");
+
+ InvokeUI(() =>
+ {
+ _updateNotificationItem = new UpdateAvailableNotificationItem();
+ _updateNotificationItem.Version = Version.Parse(e.Version).ToString(3);
+ _updateNotificationItem.Pressed += (_, __) =>
+ {
+ _updateNotificationItem = null;
+
+ if (!IsVisible)
+ {
+ LogManager.Log("Update available notification pressed. Navigating to update view...");
+ NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView);
+ CheckForUpdates();
+ }
+ };
+ _updateNotificationItem.Closed += (_, __) =>
+ {
+ _updateNotificationItem = null;
+ };
+ NotificationProvider.PushNotification(_updateNotificationItem);
+ });
+ }
+ }
+
+ #endregion
}
}