From 5aadd4125244d13dfdffbc27e453eb81cbbf0b57 Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 23 Oct 2022 21:04:22 +0300 Subject: PPC Screen Saver. --- .../Tango.PPC.MachineSettings/Views/MainView.xaml | 30 ++++++++++++++++ .../PPC/Tango.PPC.Common/PPCSettings.cs | 20 +++++++++++ .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 41 ++++++++++++++++++++++ .../PPC/Tango.PPC.UI/Views/MainView.xaml | 17 ++++++++- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.BL/Enumerations/ColorSpaces.cs | 6 ++++ 6 files changed, 114 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 87a1a361f..557ee8a8f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -323,6 +323,36 @@ + + + + + + + Turn off the screen when the machine is turned off + + + + and no interactions are made + + + + + Turn off screen delay (m) + + + + + + + + You can activate the screen anytime by pressing + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index fce1ce046..ba7499cc1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -321,6 +321,24 @@ namespace Tango.PPC.Common /// public int FineTuningTrialLengthMeters { get; set; } + /// + /// Gets or sets a value indicating whether to enable the screen saver. + /// + public bool EnableScreenSaver { get; set; } + + private int _screenSaverStartDuration; + /// + /// Gets or sets the start duration of the screen saver. + /// + public int ScreenSaverStartDuration + { + get { return _screenSaverStartDuration; } + set + { + _screenSaverStartDuration = Math.Max(value, 1); + } + } + /// /// Gets the machine service address. /// @@ -384,6 +402,8 @@ namespace Tango.PPC.Common EnableProxifier = true; UseJobsModuleV2 = true; DefaultTabColorSpace = ColorSpaces.CMYK; + ScreenSaverStartDuration = 5; + EnableScreenSaver = true; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index 9dc4684c2..9a302a6ff 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -23,6 +23,8 @@ using Tango.SharedUI; using System.Data.Entity; using Tango.PPC.UI.AppBarItems; using Tango.PPC.Common.Notifications.NotificationItems; +using Tango.Core.Commands; +using System.Timers; namespace Tango.PPC.UI.ViewModels { @@ -38,6 +40,7 @@ namespace Tango.PPC.UI.ViewModels private PowerUpAppBarItem _powerUpAppBar; private bool _started; private MessageNotificationItem _headTypeNotification; + private Timer _screenSaverTimer; private DateTime _currentDateTime; /// @@ -49,6 +52,15 @@ namespace Tango.PPC.UI.ViewModels set { _currentDateTime = value; RaisePropertyChangedAuto(); } } + private bool _isScreenSaverOn; + public bool IsScreenSaverOn + { + get { return _isScreenSaverOn; } + set { _isScreenSaverOn = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ScreenSaverExitCommand { get; set; } + public MainViewVM() { _date_timer = new DispatcherTimer(); @@ -61,6 +73,8 @@ namespace Tango.PPC.UI.ViewModels _headTypeNotification.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error; _headTypeNotification.Priority = NotificationItem.NotificationPriority.Critical; _headTypeNotification.Message = "Machine head type mismatch."; + + ScreenSaverExitCommand = new RelayCommand(ResetScreenSaverTimer); } /// @@ -84,6 +98,10 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineOperator.PowerUpEnded += MachineOperator_PowerUpEnded; MachineProvider.MachineConnected += MachineProvider_MachineConnected; + + _screenSaverTimer = new Timer(TimeSpan.FromMinutes(Settings.ScreenSaverStartDuration).TotalMilliseconds); + _screenSaverTimer.Elapsed += _screenSaverTimer_Elapsed; + _screenSaverTimer.Start(); } #region Power Up @@ -262,6 +280,8 @@ namespace Tango.PPC.UI.ViewModels private void MachineProvider_MachineConnected(object sender, EventArgs e) { + ResetScreenSaverTimer(); + NotificationProvider.PopNotification(_headTypeNotification); if (MachineProvider.MachineOperator.DeviceInformation != null && !MachineProvider.Machine.IsDemo) @@ -275,5 +295,26 @@ namespace Tango.PPC.UI.ViewModels } #endregion + + #region Screen Saver + + public void ResetScreenSaverTimer() + { + _screenSaverTimer.Stop(); + _screenSaverTimer.Start(); + IsScreenSaverOn = false; + } + + private void _screenSaverTimer_Elapsed(object sender, ElapsedEventArgs e) + { + _screenSaverTimer.Interval = TimeSpan.FromMinutes(Settings.ScreenSaverStartDuration).TotalMilliseconds; + + if (Settings.EnableScreenSaver && !MachineProvider.IsConnected) + { + IsScreenSaverOn = true; + } + } + + #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 2e36347a3..0d59961cc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -13,6 +13,7 @@ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:components="clr-namespace:Tango.Touch.Components;assembly=Tango.Touch" xmlns:localConverters="clr-namespace:Tango.PPC.UI.Converters" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -20,7 +21,13 @@ - + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs b/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs index d254475d9..00fb75b42 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs @@ -49,5 +49,11 @@ namespace Tango.BL.Enumerations [Description("Catalog")] Catalog = 4, + /// + /// (Catalog) + /// + [Description("HSB")] + HSB = 5, + } } -- cgit v1.3.1