diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-10-23 21:04:22 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-10-23 21:04:22 +0300 |
| commit | 5aadd4125244d13dfdffbc27e453eb81cbbf0b57 (patch) | |
| tree | 77aeae6042af573a7590785bad146b8f3314bc08 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | 00859f5f1ee871007120d4fa9dc534fb67be242c (diff) | |
| download | Tango-5aadd4125244d13dfdffbc27e453eb81cbbf0b57.tar.gz Tango-5aadd4125244d13dfdffbc27e453eb81cbbf0b57.zip | |
PPC Screen Saver.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
3 files changed, 58 insertions, 2 deletions
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; /// <summary> @@ -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); } /// <summary> @@ -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 @@ <localConverters:ItemBaseConverter x:Key="ItemBaseConverter" /> </UserControl.Resources> - <Grid> + <Grid Background="Transparent"> + <i:Interaction.Triggers> + <i:EventTrigger EventName="PreviewMouseUp"> + <i:InvokeCommandAction Command="{Binding ScreenSaverExitCommand}" /> + </i:EventTrigger> + </i:Interaction.Triggers> + <touch:TouchPanel HasMessageBox="{Binding NotificationProvider.HasMessageBox}" CurrentMessageBox="{Binding NotificationProvider.CurrentMessageBox}" @@ -147,5 +154,13 @@ <local:RestartingView></local:RestartingView> </controls:NavigationControl> </touch:TouchPanel> + + <Grid Visibility="{Binding IsScreenSaverOn,Converter={StaticResource BooleanToVisibilityConverter}}" Background="Black"> + <i:Interaction.Triggers> + <i:EventTrigger EventName="PreviewMouseUp"> + <i:InvokeCommandAction Command="{Binding ScreenSaverExitCommand}" /> + </i:EventTrigger> + </i:Interaction.Triggers> + </Grid> </Grid> </UserControl> 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. --> - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> |
