aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs70
1 files changed, 69 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
index ba1b44c8a..1550e97e1 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -29,6 +29,8 @@ using Tango.BL.Enumerations;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.WatchDog;
using Tango.PPC.UI.Dialogs;
+using Tango.Core.Threading;
+using Tango.PPC.Common.Messages;
namespace Tango.PPC.UI.PPCApplication
{
@@ -48,6 +50,7 @@ namespace Tango.PPC.UI.PPCApplication
private INotificationProvider _notificationProvider;
private WatchDogServer _watchdogServer;
private ObservablesContext _machineContext;
+ private ActionTimer _screenLockTimer;
/// <summary>
/// Occurs when a system restart is required.
@@ -116,6 +119,16 @@ namespace Tango.PPC.UI.PPCApplication
}
}
+ private bool _isScreenLocked;
+ /// <summary>
+ /// Gets or sets a value indicating whether the screen is currently locked.
+ /// </summary>
+ public bool IsScreenLocked
+ {
+ get { return _isScreenLocked; }
+ set { _isScreenLocked = value; RaisePropertyChangedAuto(); }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="DefaultPPCApplicationManager"/> class.
/// </summary>
@@ -306,6 +319,8 @@ namespace Tango.PPC.UI.PPCApplication
/// </summary>
private void FinalizeModuleInitialization()
{
+ var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
+
LogManager.Log("Finalizing application initialization...");
LogManager.Log("Initializing Machine Provider...");
@@ -336,10 +351,30 @@ namespace Tango.PPC.UI.PPCApplication
vm.OnApplicationReady();
}
- if (SettingsManager.Default.GetOrCreate<PPCSettings>().EnableTechnicianModeByDefault)
+ if (settings.EnableTechnicianModeByDefault)
{
EnterTechnicianMode(false);
}
+
+ if (settings.EnableLockScreen)
+ {
+ _screenLockTimer = new ActionTimer(settings.LockScreenTimeout);
+ _screenLockTimer.ResetReplace(ScreenLockTimerAction);
+ }
+
+ TangoMessenger.Default.Register<MachineSettingsSavedMessage>((msg) =>
+ {
+ if (_screenLockTimer != null)
+ {
+ _screenLockTimer.Dispose();
+ }
+
+ if (settings.EnableLockScreen)
+ {
+ _screenLockTimer = new ActionTimer(settings.LockScreenTimeout);
+ _screenLockTimer.ResetReplace(ScreenLockTimerAction);
+ }
+ });
});
}
@@ -460,5 +495,38 @@ namespace Tango.PPC.UI.PPCApplication
_moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianExited());
_notificationProvider.ShowInfo("Technician mode is now disabled.");
}
+
+ /// <summary>
+ /// Invokes a dialog for entering a password and releasing the screen lock.
+ /// </summary>
+ public async void ReleaseScreenLock()
+ {
+ if (IsScreenLocked)
+ {
+ var vm = await _notificationProvider.ShowDialog<ScreenLockViewVM>();
+
+ if (vm.DialogResult)
+ {
+ if (vm.Password == SettingsManager.Default.GetOrCreate<PPCSettings>().LockScreenPassword)
+ {
+ IsScreenLocked = false;
+ ResetScreenLockTimer();
+ }
+ }
+ }
+ }
+
+ public void ResetScreenLockTimer()
+ {
+ if (_screenLockTimer != null)
+ {
+ _screenLockTimer.ResetReplace(ScreenLockTimerAction);
+ }
+ }
+
+ private void ScreenLockTimerAction()
+ {
+ IsScreenLocked = true;
+ }
}
}