From 13887d7b53fec7e2d357fd377a6a1fbd0e875e65 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 22 Apr 2019 09:33:28 +0300 Subject: Working on PPC optimizations... --- Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs') diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index fa57169f3..5e6a309da 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -13,6 +13,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.SharedUI.Controls; namespace Tango.Touch.Controls { @@ -20,7 +21,7 @@ namespace Tango.Touch.Controls { private TextBox _text_box; private bool _prevent_text_change; - private TextBlock _text_block; + private FastTextBlock _text_block; private double _lastValue; Regex regex_integer = new Regex(@"^-?[0-9]\d*(\d+)?$"); Regex regex_double = new Regex(@"^-?[0-9]\d*(\.\d+)?$"); @@ -101,7 +102,7 @@ namespace Tango.Touch.Controls base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; - _text_block = GetTemplateChild("PART_TextDisplay") as TextBlock; + _text_block = GetTemplateChild("PART_TextDisplay") as FastTextBlock; _text_box.PreviewTextInput += _text_box_PreviewTextInput; _text_box.PreviewKeyDown += _text_box_PreviewKeyDown; _text_box.LostFocus += _text_box_LostFocus; -- cgit v1.3.1 From ba4aec4c691476d68b3da383a70bff42341c7171 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 23 Apr 2019 16:13:41 +0300 Subject: Implemented screen lock for PPC. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.PPC.Jobs/Dialogs/JobCreationView.xaml | 5 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 64 ++++++++++++++++--- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 2 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 46 +++++++++++++- .../Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs | 11 ++++ .../ViewModels/MainViewVM.cs | 27 ++++++++ .../Tango.PPC.MachineSettings/Views/MainView.xaml | 25 +++++++- .../Application/IPPCApplicationManager.cs | 15 +++++ .../PPC/Tango.PPC.Common/PPCSettings.cs | 17 +++++ .../PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml | 30 +++++++++ .../Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs | 36 +++++++++++ .../PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs | 19 ++++++ .../Dialogs/TechnicianModeLoginView.xaml | 7 ++- .../Dialogs/TechnicianModeLoginView.xaml.cs | 8 +++ .../PPCApplication/DefaultPPCApplicationManager.cs | 70 ++++++++++++++++++++- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 10 ++- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 5 ++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs | 12 ++++ Software/Visual_Studio/Tango.BL/Entities/Job.cs | 4 +- .../Tango.Core/Threading/ActionTimer.cs | 14 ++++- .../Tango.Touch/Controls/TouchNumericTextBox.cs | 12 ++++ .../Tango.Touch/Controls/TouchNumericTextBox.xaml | 56 ++++++++++++----- .../Tango.Touch/Controls/TouchTextBox.cs | 11 +++- 27 files changed, 472 insertions(+), 34 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 385ec2708..a7bbbb937 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index c94ea41e5..e23788fde 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 488624b20..f5902c028 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index 6e8a53f2e..c47eeefb7 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml index 0e4f6e38c..cecdf813c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml @@ -65,7 +65,9 @@ - + + + @@ -96,6 +98,7 @@ + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index c7946ee6a..713dfce42 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -31,6 +31,9 @@ using Tango.Logging; using Tango.PPC.Common.Messages; using Tango.BL.Builders; using Tango.PPC.Jobs.AppButtons; +using Tango.Core.Threading; +using System.Diagnostics; +using System.Runtime.ExceptionServices; namespace Tango.PPC.Jobs.ViewModels { @@ -47,6 +50,7 @@ namespace Tango.PPC.Jobs.ViewModels private JobNavigationIntent _job_to_load_intent; private static Dictionary> _jobs_fine_tune_items; private StartPrintingButton _start_printing_btn; + private ActionTimer _volumeConversionTimer; #region Properties @@ -319,6 +323,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public JobViewVM() { + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + RegisterForMessage(HandleJobSelectedMessage); FineTuneItems = new ObservableCollection(); @@ -426,6 +432,11 @@ namespace Tango.PPC.Jobs.ViewModels Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); + foreach (var segment in Job.Segments) + { + SetSegmentLiquidVolumesIfVolume(segment); + } + if (!_check_gamut_thread.IsAlive) { _check_gamut_thread.Start(); @@ -601,7 +612,9 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Adding new solid segment..."); - return Job.AddSolidSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + var s = Job.AddSolidSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + SetSegmentLiquidVolumesIfVolume(s); + return s; } catch (Exception ex) { @@ -619,7 +632,9 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Adding new gradient segment..."); - return Job.AddGradientSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + var s = Job.AddGradientSegment(MachineProvider.Machine.DefaultSegmentLength > 0 ? MachineProvider.Machine.DefaultSegmentLength : 10); + SetSegmentLiquidVolumesIfVolume(s); + return s; } catch (Exception ex) { @@ -683,6 +698,18 @@ namespace Tango.PPC.Jobs.ViewModels } } + /// + /// Sets the segment liquid volumes. + /// + /// The segment. + private void SetSegmentLiquidVolumesIfVolume(Segment segment) + { + if (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32()) + { + segment.BrushStops.ToList().ForEach(x => x.SetLiquidVolumes(Job.Machine.Configuration, Job.Rml, Job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault())); + } + } + #endregion #region Brush Stops Management @@ -695,6 +722,7 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Adding new brush stop to segment {segment.SegmentIndex}."); segment.AddBrushStop(); + SetSegmentLiquidVolumesIfVolume(segment); } /// @@ -764,13 +792,35 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Called when the brush stop field value has been changed (This called from the view!). /// - /// The brush stop. - public void OnBrushStopFieldValueChanged(BrushStop brushStop) + /// The brush stop. + [HandleProcessCorruptedStateExceptions] + public void OnBrushStopFieldValueChanged(BrushStop stop) { - if (brushStop != null) + if (stop != null) { - brushStop.Corrected = false; - brushStop.OutOfGamutChecked = false; + stop.Corrected = false; + stop.OutOfGamutChecked = false; + + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + _volumeConversionTimer.ResetReplace(() => + { + try + { + var output = TangoColorConverter.GetSuggestions(stop); + + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + stop.Corrected = true; + stop.IsOutOfGamut = false; + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + } + }); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 86c53440e..bd6f95d44 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -378,7 +378,7 @@ namespace Tango.PPC.Jobs.ViewModels JobCreationViewVM vm = new JobCreationViewVM( machine.SupportedJobTypes.Count > 0 ? machine.SupportedJobTypes : Enum.GetValues(typeof(JobTypes)).Cast().ToList(), - machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace()).ToList() + machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace() || (ApplicationManager.IsInTechnicianMode && x == ColorSpaces.Volume)).ToList() ); var settings = SettingsManager.Default.GetOrCreate(); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 02e4cb6eb..75c4e9578 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -25,7 +25,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -120,6 +156,9 @@ + + + @@ -258,6 +297,9 @@ + + + @@ -385,7 +427,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs index 6a6e770a7..3cd6e1bce 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.BL; using Tango.BL.Entities; using Tango.Core.DI; using Tango.PPC.Jobs.ViewContracts; @@ -111,5 +112,15 @@ namespace Tango.PPC.Jobs.Views borderDockFloat.Child = dockEdit; borderEditDock.Visibility = Visibility.Collapsed; } + + private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; + + if (liquidVolume != null) + { + _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index c858e982e..b413fee0d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -86,6 +86,27 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _enableRemoteAssistance = value; RaisePropertyChangedAuto(); OnEnableRemoteAssistanceChanged(); } } + private bool _enableLockScreen; + public bool EnableLockScreen + { + get { return _enableLockScreen; } + set { _enableLockScreen = value; RaisePropertyChangedAuto(); } + } + + private int _lockScreenTimeoutMinutes; + public int LockScreenTimeoutMinutes + { + get { return _lockScreenTimeoutMinutes; } + set { _lockScreenTimeoutMinutes = value; RaisePropertyChangedAuto(); } + } + + private String _lockScreenPassword; + public String LockScreenPassword + { + get { return _lockScreenPassword; } + set { _lockScreenPassword = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -125,6 +146,9 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.HotSpotPassword = HotSpotPassword; Settings.EnableExternalBridge = EnableExternalBridge; Settings.ExternalBridgePassword = ExternalBridgePassword; + Settings.EnableLockScreen = EnableLockScreen; + Settings.LockScreenTimeout = TimeSpan.FromMinutes(LockScreenTimeoutMinutes); + Settings.LockScreenPassword = LockScreenPassword; Settings.Save(); await MachineProvider.SaveMachine(); @@ -166,6 +190,9 @@ namespace Tango.PPC.MachineSettings.ViewModels _enableRemoteAssistance = RemoteAssistanceProvider.IsEnabled; RaisePropertyChanged(nameof(EnableRemoteAssistance)); + EnableLockScreen = Settings.EnableLockScreen; + LockScreenTimeoutMinutes = (int)Settings.LockScreenTimeout.TotalMinutes; + LockScreenPassword = Settings.LockScreenPassword; SelectedJobTypes = new SelectedObjectCollection(Enum.GetValues(typeof(JobTypes)).Cast().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection()); SelectedColorSpaces = new SelectedObjectCollection(Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace()).ToObservableCollection(), Machine.SupportedColorSpaces.ToObservableCollection()); 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 4f846a46d..dd5f89bb2 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 @@ -11,7 +11,7 @@ xmlns:global="clr-namespace:Tango.PPC.MachineSettings" xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views" mc:Ignorable="d" - d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="2500" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -172,6 +172,29 @@ + + + + + + Enable Lock Screen + + + Lock Screen Timeout (m) + + + Lock Screen Password + + + + + + + Enable the lock screen to protect the panel from unauthorized access. + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index 2d76b202f..5f58be48b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -94,5 +94,20 @@ namespace Tango.PPC.Common.Application /// Gets the application build date. /// String BuildDate { get; } + + /// + /// Gets or sets a value indicating whether the screen is currently locked. + /// + bool IsScreenLocked { get; set; } + + /// + /// Resets the screen lock timer. + /// + void ResetScreenLockTimer(); + + /// + /// Invokes a dialog for entering a password and releasing the screen lock. + /// + void ReleaseScreenLock(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 698dbf374..050f1615c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -97,6 +97,21 @@ namespace Tango.PPC.Common /// public int GradientGenerationResolution { get; set; } + /// + /// Gets or sets a value indicating whether to enable the application lock screen. + /// + public bool EnableLockScreen { get; set; } + + /// + /// Gets or sets the lock screen timeout. + /// + public TimeSpan LockScreenTimeout { get; set; } + + /// + /// Gets or sets the lock screen password. + /// + public String LockScreenPassword { get; set; } + /// /// Gets the machine service address. /// @@ -119,6 +134,8 @@ namespace Tango.PPC.Common EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; + LockScreenTimeout = TimeSpan.FromMinutes(10); + LockScreenPassword = "1111"; DeploymentSlot = DeploymentSlot.TEST; EnableWatchDog = true; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml new file mode 100644 index 000000000..8a90b03a0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + CANCEL + OK + + + + + Screen Locked + Please enter the password to unlock the screen. + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs new file mode 100644 index 000000000..4a28984e6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// + /// Interaction logic for TechnicianModeLoginView.xaml + /// + public partial class ScreenLockView : UserControl + { + public ScreenLockView() + { + InitializeComponent(); + + Loaded += ScreenLockView_Loaded; + } + + private async void ScreenLockView_Loaded(object sender, RoutedEventArgs e) + { + await Task.Delay(200); + txtPassword.Focus(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs new file mode 100644 index 000000000..e19117621 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class ScreenLockViewVM : DialogViewVM + { + private String _password; + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml index ca53d6027..24a5416ba 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml @@ -7,6 +7,11 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="250" d:DataContext="{d:DesignInstance Type=local:TechnicianModeLoginViewVM, IsDesignTimeCreatable=False}"> + + + + + @@ -18,7 +23,7 @@ Technician Mode Please enter the technician mode password. - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs index 02dfed896..3a809b6f3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs @@ -23,6 +23,14 @@ namespace Tango.PPC.UI.Dialogs public TechnicianModeLoginView() { InitializeComponent(); + + Loaded += TechnicianModeLoginView_Loaded; + } + + private async void TechnicianModeLoginView_Loaded(object sender, RoutedEventArgs e) + { + await Task.Delay(200); + txtPassword.Focus(); } } } 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; /// /// Occurs when a system restart is required. @@ -116,6 +119,16 @@ namespace Tango.PPC.UI.PPCApplication } } + private bool _isScreenLocked; + /// + /// Gets or sets a value indicating whether the screen is currently locked. + /// + public bool IsScreenLocked + { + get { return _isScreenLocked; } + set { _isScreenLocked = value; RaisePropertyChangedAuto(); } + } + /// /// Initializes a new instance of the class. /// @@ -306,6 +319,8 @@ namespace Tango.PPC.UI.PPCApplication /// private void FinalizeModuleInitialization() { + var settings = SettingsManager.Default.GetOrCreate(); + 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().EnableTechnicianModeByDefault) + if (settings.EnableTechnicianModeByDefault) { EnterTechnicianMode(false); } + + if (settings.EnableLockScreen) + { + _screenLockTimer = new ActionTimer(settings.LockScreenTimeout); + _screenLockTimer.ResetReplace(ScreenLockTimerAction); + } + + TangoMessenger.Default.Register((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."); } + + /// + /// Invokes a dialog for entering a password and releasing the screen lock. + /// + public async void ReleaseScreenLock() + { + if (IsScreenLocked) + { + var vm = await _notificationProvider.ShowDialog(); + + if (vm.DialogResult) + { + if (vm.Password == SettingsManager.Default.GetOrCreate().LockScreenPassword) + { + IsScreenLocked = false; + ResetScreenLockTimer(); + } + } + } + } + + public void ResetScreenLockTimer() + { + if (_screenLockTimer != null) + { + _screenLockTimer.ResetReplace(ScreenLockTimerAction); + } + } + + private void ScreenLockTimerAction() + { + IsScreenLocked = true; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 22ecff0f6..71fa82504 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -122,9 +122,13 @@ + + ScreenLockView.xaml + TechnicianModeLoginView.xaml + UpdateFromFileView.xaml @@ -186,6 +190,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -526,7 +534,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 768fce222..6e820ab64 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -279,7 +279,12 @@ + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs index 777083b67..883d3f893 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs @@ -42,6 +42,13 @@ namespace Tango.PPC.UI.Views _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(10); _timer.Tick += _timer_Tick; + + this.PreviewMouseUp += LayoutView_PreviewMouseUp; + } + + private void LayoutView_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + _vm.ApplicationManager.ResetScreenLockTimer(); } private void _timer_Tick(object sender, EventArgs e) @@ -77,5 +84,10 @@ namespace Tango.PPC.UI.Views _timer.Stop(); } + + private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + _vm.ApplicationManager.ReleaseScreenLock(); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 555e26ccc..c93889dad 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -455,9 +455,9 @@ namespace Tango.BL.Entities public Segment AddGradientSegment(double length) { var segment = AddSolidSegment(length); - segment.BrushStops.Last().Color = System.Windows.Media.Colors.Silver; + segment.BrushStops.Last().Color = System.Windows.Media.Colors.White; segment.AddBrushStop(); - segment.BrushStops.Last().Color = System.Windows.Media.Colors.DimGray; + segment.BrushStops.Last().Color = System.Windows.Media.Colors.White; return segment; } diff --git a/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs b/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs index 48ee12964..f16e7739c 100644 --- a/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs +++ b/Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs @@ -10,7 +10,7 @@ namespace Tango.Core.Threading /// /// Represents an action executer with a predefined interval and a reset mechanism. /// - public class ActionTimer + public class ActionTimer : IDisposable { private Timer _timer; private Action _action; @@ -43,5 +43,17 @@ namespace Tango.Core.Threading _timer.Stop(); _action?.Invoke(); } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + if (_timer != null) + { + _timer.Stop(); + _timer = null; + } + } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 5e6a309da..6fbce65bf 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -49,6 +49,18 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(String), typeof(TouchNumericTextBox), new PropertyMetadata(null)); + + + public bool DisplayWatermarkHint + { + get { return (bool)GetValue(DisplayWatermarkHintProperty); } + set { SetValue(DisplayWatermarkHintProperty, value); } + } + public static readonly DependencyProperty DisplayWatermarkHintProperty = + DependencyProperty.Register("DisplayWatermarkHint", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(false)); + + + public String StringFormat { get { return (String)GetValue(StringFormatProperty); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml index bfe65cbd1..29be2dd00 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml @@ -88,23 +88,49 @@ - - - - - - - - + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs index 777e53ed0..beb7e0c18 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs @@ -21,6 +21,7 @@ namespace Tango.Touch.Controls public class TouchTextBox : TouchInput { private TextBox _text_box; + private PasswordBox _password_box; private DateTime _lost_focus_time; public String Text @@ -97,6 +98,7 @@ namespace Tango.Touch.Controls base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; + _password_box = GetTemplateChild("PART_PasswordBox") as PasswordBox; _text_box.GotFocus += _text_box_GotFocus; _text_box.LostFocus += _text_box_LostFocus; @@ -137,7 +139,14 @@ namespace Tango.Touch.Controls public new void Focus() { - _text_box.Focus(); + if (IsPassword) + { + _password_box.Focus(); + } + else + { + _text_box.Focus(); + } } } } -- cgit v1.3.1