aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-04-23 16:13:41 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-04-23 16:13:41 +0300
commitba4aec4c691476d68b3da383a70bff42341c7171 (patch)
treecff1ec9b2b4c6bc09ceb4d2a7a64f8cf1e6a8fc0 /Software/Visual_Studio/PPC
parent2c48f9ef5ee4978f531e18d0c5945f33705bfe46 (diff)
downloadTango-ba4aec4c691476d68b3da383a70bff42341c7171.tar.gz
Tango-ba4aec4c691476d68b3da383a70bff42341c7171.zip
Implemented screen lock for PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationView.xaml5
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs64
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml46
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs11
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs27
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml25
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs17
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml30
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockView.xaml.cs36
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ScreenLockViewVM.cs19
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml7
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/TechnicianModeLoginView.xaml.cs8
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs70
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj10
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml5
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs12
18 files changed, 394 insertions, 15 deletions
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 @@
<Grid>
<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="70 0" StrokeThickness="1" Stroke="{StaticResource TangoDividerBrush}" />
- <touch:TouchStaticListBox Margin="0 -40 0 0" VerticalAlignment="Center" Width="440" ItemsSource="{Binding SupportedColorSpaces}" SelectedItem="{Binding SelectedColorSpace,Mode=TwoWay}">
+
+ <Grid Margin="-20 -40 -20 0">
+ <touch:TouchStaticListBox VerticalAlignment="Center" ItemsSource="{Binding SupportedColorSpaces}" SelectedItem="{Binding SelectedColorSpace,Mode=TwoWay}">
<touch:TouchStaticListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
@@ -96,6 +98,7 @@
</DataTemplate>
</touch:TouchStaticListBox.ItemTemplate>
</touch:TouchStaticListBox>
+ </Grid>
</Grid>
</UniformGrid>
</DockPanel>
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<String, List<FineTuneItem>> _jobs_fine_tune_items;
private StartPrintingButton _start_printing_btn;
+ private ActionTimer _volumeConversionTimer;
#region Properties
@@ -319,6 +323,8 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public JobViewVM()
{
+ _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50));
+
RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage);
FineTuneItems = new ObservableCollection<FineTuneItem>();
@@ -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
}
}
+ /// <summary>
+ /// Sets the segment liquid volumes.
+ /// </summary>
+ /// <param name="segment">The segment.</param>
+ 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);
}
/// <summary>
@@ -764,13 +792,35 @@ namespace Tango.PPC.Jobs.ViewModels
/// <summary>
/// Called when the brush stop field value has been changed (This called from the view!).
/// </summary>
- /// <param name="brushStop">The brush stop.</param>
- public void OnBrushStopFieldValueChanged(BrushStop brushStop)
+ /// <param name="stop">The brush stop.</param>
+ [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<JobTypes>().ToList(),
- machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().Where(x => x.IsUserSpace()).ToList()
+ machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().Where(x => x.IsUserSpace() || (ApplicationManager.IsInTechnicianMode && x == ColorSpaces.Volume)).ToList()
);
var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>();
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 @@
<BitmapImage x:Key="Image_Out_Of_Gamut" UriSource="../Images/JobView/error.png" />
<BitmapImage x:Key="Image_Replace_Color" UriSource="../Images/JobView/replace-color.png" />
<BitmapImage x:Key="Image_Color_Picker" UriSource="../Images/JobView/color-picker.png" />
-
+
<Style TargetType="FrameworkElement" x:Key="Level1Container">
<Setter Property="Margin" Value="20 15 60 15"></Setter>
@@ -37,6 +37,42 @@
<Setter Property="Margin" Value="80 40 60 0"></Setter>
</Style>
+ <DataTemplate x:Key="Volume_Template" DataType="{x:Type entities:BrushStop}">
+ <Grid>
+ <ItemsControl ItemsSource="{Binding LiquidVolumes}" VerticalAlignment="Center" Margin="0 0 -90 0">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Border>
+ <Border.Style>
+ <Style TargetType="Border">
+ <Setter Property="Visibility" Value="Visible"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IdsPack.IdsPackFormula.Name}" Value="Lubricant">
+ <Setter Property="Visibility" Value="Collapsed"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IdsPack.IdsPackFormula.Name}" Value="Cleaner">
+ <Setter Property="Visibility" Value="Collapsed"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+ <touch:TouchNumericTextBox DisplayWatermarkHint="True" Width="50" Watermark="{Binding IdsPack.LiquidType.Name,IsAsync=True}" Margin="2 0" ValueChanged="OnLiquidVolumeFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Volume}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="0" Maximum="100" JoggingFactor="0.5" StringFormat="0.00" />
+ </Border>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+
+ <Canvas VerticalAlignment="Bottom" Visibility="{Binding IsLiquidVolumesOutOfRange,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <controls:FastTextBlock Canvas.Top="2" Foreground="{StaticResource TangoErrorBrush}" FontSize="{StaticResource TangoSmallFontSize}" Text="Liquid volumes are out of range."></controls:FastTextBlock>
+ </Canvas>
+ </Grid>
+ </DataTemplate>
+
<DataTemplate x:Key="RGB_Template" DataType="{x:Type entities:BrushStop}">
<UniformGrid Rows="1" Columns="3">
<touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Red}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" />
@@ -120,6 +156,9 @@
<DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Twine">
<Setter Property="ContentTemplate" Value="{StaticResource TWINE_Template}" />
</DataTrigger>
+ <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Volume">
+ <Setter Property="ContentTemplate" Value="{StaticResource Volume_Template}" />
+ </DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
@@ -258,6 +297,9 @@
<DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Twine">
<Setter Property="ContentTemplate" Value="{StaticResource TWINE_Template}" />
</DataTrigger>
+ <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Volume">
+ <Setter Property="ContentTemplate" Value="{StaticResource Volume_Template}" />
+ </DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
@@ -385,7 +427,7 @@
<Grid.CacheMode>
<BitmapCache RenderAtScale="1" SnapsToDevicePixels="False" />
</Grid.CacheMode>
-
+
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
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<JobTypes>(Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection());
SelectedColorSpaces = new SelectedObjectCollection<ColorSpaces>(Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().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}">
<Grid Background="{StaticResource TangoMidBackgroundBrush}">
<Grid.RowDefinitions>
@@ -172,6 +172,29 @@
</DockPanel>
</StackPanel>
</touch:TouchExpander>
+
+ <!--LOCK SCREEN-->
+ <touch:TouchExpander Margin="0 20 0 0" Header="Lock Screen" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}">
+ <StackPanel>
+ <controls:TableGrid Margin="10" RowHeight="60" MakeFirstColumnVerticalAlignmentBottom="False" TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
+ <TextBlock VerticalAlignment="Center">Enable Lock Screen</TextBlock>
+ <touch:TouchToggleSlider Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Margin="0 0 110 0" Width="90" IsChecked="{Binding EnableLockScreen}"></touch:TouchToggleSlider>
+
+ <TextBlock VerticalAlignment="Bottom">Lock Screen Timeout (m)</TextBlock>
+ <touch:TouchNumericTextBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Minimum="1" Maximum="60" Value="{Binding LockScreenTimeoutMinutes}" HasDecimalPoint="False" KeyboardContainer="{Binding ElementName=Container}"></touch:TouchNumericTextBox>
+
+ <TextBlock VerticalAlignment="Bottom">Lock Screen Password</TextBlock>
+ <touch:TouchTextBox IsPassword="True" Watermark="•••••••" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Text="{Binding LockScreenPassword}" KeyboardContainer="{Binding ElementName=Container}"></touch:TouchTextBox>
+ </controls:TableGrid>
+
+ <DockPanel Margin="10 -50 0 0">
+ <touch:TouchIcon VerticalAlignment="Top" Icon="InformationOutline" Foreground="{StaticResource TangoGrayTextBrush}"></touch:TouchIcon>
+ <TextBlock Margin="10 0 0 0" VerticalAlignment="Top" TextWrapping="Wrap" FontSize="{StaticResource TangoSmallFontSize}" Foreground="{StaticResource TangoGrayTextBrush}">
+ Enable the lock screen to protect the panel from unauthorized access.
+ </TextBlock>
+ </DockPanel>
+ </StackPanel>
+ </touch:TouchExpander>
</StackPanel>
</touch:LightTouchScrollViewer>
</Grid>
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.
/// </summary>
String BuildDate { get; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the screen is currently locked.
+ /// </summary>
+ bool IsScreenLocked { get; set; }
+
+ /// <summary>
+ /// Resets the screen lock timer.
+ /// </summary>
+ void ResetScreenLockTimer();
+
+ /// <summary>
+ /// Invokes a dialog for entering a password and releasing the screen lock.
+ /// </summary>
+ 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
@@ -98,6 +98,21 @@ namespace Tango.PPC.Common
public int GradientGenerationResolution { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether to enable the application lock screen.
+ /// </summary>
+ public bool EnableLockScreen { get; set; }
+
+ /// <summary>
+ /// Gets or sets the lock screen timeout.
+ /// </summary>
+ public TimeSpan LockScreenTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the lock screen password.
+ /// </summary>
+ public String LockScreenPassword { get; set; }
+
+ /// <summary>
/// Gets the machine service address.
/// </summary>
/// <returns></returns>
@@ -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 @@
+<UserControl x:Class="Tango.PPC.UI.Dialogs.ScreenLockView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:local="clr-namespace:Tango.PPC.UI.Dialogs"
+ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
+ 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:ScreenLockViewVM, IsDesignTimeCreatable=False}">
+
+ <UserControl.InputBindings>
+ <KeyBinding Key="Return" Command="{Binding OKCommand}"></KeyBinding>
+ </UserControl.InputBindings>
+ <Grid Margin="10">
+ <DockPanel>
+ <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
+ <touch:TouchButton Command="{Binding CloseCommand}" Style="{StaticResource TangoMessageBoxButton}" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton>
+ <touch:TouchButton Command="{Binding OKCommand}" Style="{StaticResource TangoMessageBoxButton}" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">OK</touch:TouchButton>
+ </StackPanel>
+ <DockPanel>
+ <touch:TouchIcon Foreground="{StaticResource TangoErrorBrush}" Icon="Lock" VerticalAlignment="Top" Height="70"></touch:TouchIcon>
+ <StackPanel Margin="10 0 0 0">
+ <TextBlock FontSize="{StaticResource TangoHeaderFontSize}">Screen Locked</TextBlock>
+ <TextBlock Margin="0 10 0 0" TextWrapping="Wrap">Please enter the password to unlock the screen.</TextBlock>
+ <touch:TouchTextBox x:Name="txtPassword" Margin="0 30 40 0" IsPassword="True" KeyboardAction="Go" Text="{Binding Password,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
+ </StackPanel>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+</UserControl>
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
+{
+ /// <summary>
+ /// Interaction logic for TechnicianModeLoginView.xaml
+ /// </summary>
+ 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}">
+
+ <UserControl.InputBindings>
+ <KeyBinding Key="Return" Command="{Binding OKCommand}"></KeyBinding>
+ </UserControl.InputBindings>
+
<Grid Margin="10">
<DockPanel>
<StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
@@ -18,7 +23,7 @@
<StackPanel Margin="10 0 0 0">
<TextBlock FontSize="{StaticResource TangoHeaderFontSize}">Technician Mode</TextBlock>
<TextBlock Margin="0 10 0 0" TextWrapping="Wrap">Please enter the technician mode password.</TextBlock>
- <touch:TouchTextBox Margin="0 30 40 0" IsPassword="True" Text="{Binding Password,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
+ <touch:TouchTextBox x:Name="txtPassword" KeyboardAction="Go" Margin="0 30 40 0" IsPassword="True" Text="{Binding Password,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</DockPanel>
</DockPanel>
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;
/// <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;
+ }
}
}
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 @@
<Compile Include="Connectivity\WiFiAuthenticationViewVM.cs" />
<Compile Include="Converters\AppBarItemConverter.cs" />
<Compile Include="Converters\ItemBaseConverter.cs" />
+ <Compile Include="Dialogs\ScreenLockView.xaml.cs">
+ <DependentUpon>ScreenLockView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Dialogs\TechnicianModeLoginView.xaml.cs">
<DependentUpon>TechnicianModeLoginView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Dialogs\ScreenLockViewVM.cs" />
<Compile Include="Dialogs\TechnicianModeLoginViewVM.cs" />
<Compile Include="Dialogs\UpdateFromFileView.xaml.cs">
<DependentUpon>UpdateFromFileView.xaml</DependentUpon>
@@ -186,6 +190,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Dialogs\ScreenLockView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Dialogs\TechnicianModeLoginView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -526,7 +534,7 @@ del "$(TargetDir)firmware_package.tfp"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ 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 @@
<!--MODULES GOES HERE-->
</controls:NavigationControl>
</Grid>
+
</DockPanel>
</touch:TouchSideMenu>
+
+ <Grid PreviewMouseUp="Grid_PreviewMouseUp" IsHitTestVisible="True" Background="Transparent" Visibility="{Binding ApplicationManager.IsScreenLocked,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <touch:TouchIcon HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="40" Icon="Lock" Width="60" Height="60" Opacity="0.5" Foreground="{StaticResource TangoSuccessBrush}" />
+ </Grid>
</Grid>
</UserControl>
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();
+ }
}
}