From 749d9907ffe8da66164ee3f523055b6fde5407a7 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 18 Apr 2019 16:40:48 +0300 Subject: Some fixes on PPC. --- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs') 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 f0cf87079..850bd5964 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 @@ -545,18 +545,18 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Starts the job. /// - private void StartJob() + private async void StartJob() { try { LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); - PrintingManager.Print(Job, _db); - NavigationManager.NavigateTo(nameof(JobProgressView)); + await PrintingManager.Print(Job, _db); + await NavigationManager.NavigateTo(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); - NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); + await NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); } } @@ -802,20 +802,20 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Starts a sample dye. /// - private void StartSampleDye() + private async void StartSampleDye() { try { LogManager.Log("Sample dye command pressed..."); - PrintingManager.PrintSample(Job, _db); + await PrintingManager.PrintSample(Job, _db); - NavigationManager.NavigateTo(nameof(JobProgressView)); + await NavigationManager.NavigateTo(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); - NotificationProvider.ShowError("An error occurred while trying to execute the sample dye."); + await NotificationProvider.ShowError("An error occurred while trying to execute the sample dye."); } } @@ -940,7 +940,7 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Starts the fine tuning. /// - private void StartFineTuning() + private async void StartFineTuning() { try { @@ -948,14 +948,14 @@ namespace Tango.PPC.Jobs.ViewModels _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); + await PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); - NavigationManager.NavigateTo(nameof(JobProgressView)); + await NavigationManager.NavigateTo(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, "Error executing fine tuning job."); - NotificationProvider.ShowError("An error occurred while trying to start the fine tuning job."); + await NotificationProvider.ShowError("An error occurred while trying to start the fine tuning job."); } } -- cgit v1.3.1 From 26ede873b194b0df70979b6f1b62e0c91ca19341 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 20 Apr 2019 21:48:32 +0300 Subject: Working on PPC performance... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 7 +- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 3 +- .../Visual_Studio/Tango.Core/ExtendedObject.cs | 9 +- .../Tango.SharedUI/Controls/FastTextBlock.cs | 73 +++++++++++++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- .../Controls/TouchVirtualizedContentControl.cs | 99 +++++++++++++++++++++ .../Controls/TouchVirtualizedContentControl.xaml | 15 ++++ .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 7 +- .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 1 + Software/Visual_Studio/Tango.sln | 12 +-- 12 files changed, 217 insertions(+), 12 deletions(-) create mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 724b8c150..1d4f688b1 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index a2be2cb15..dc895c719 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 850bd5964..9aaf9fcbd 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 @@ -764,8 +764,11 @@ namespace Tango.PPC.Jobs.ViewModels /// The brush stop. public void OnBrushStopFieldValueChanged(BrushStop brushStop) { - brushStop.Corrected = false; - brushStop.OutOfGamutChecked = false; + if (brushStop != null) + { + brushStop.Corrected = false; + brushStop.OutOfGamutChecked = false; + } } /// 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 95d6bc290..86c53440e 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 @@ -272,6 +272,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Job '{job.Name}' selected."); + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); + if (!directlyToEdit && MachineProvider.MachineOperator.Status == Integration.Operation.MachineStatuses.ReadyToDye) { await NavigationManager.NavigateWithObject(new JobSummeryNavigationObject() @@ -284,7 +286,6 @@ namespace Tango.PPC.Jobs.ViewModels { await NavigationManager.NavigateTo(nameof(JobView)); } - RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); } /// diff --git a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs index 44663b503..acead4157 100644 --- a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs +++ b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs @@ -109,7 +109,14 @@ namespace Tango.Core /// The action. protected virtual void InvokeUI(Action action) { - Application.Current.Dispatcher.BeginInvoke(action); + if (Application.Current != null) + { + Application.Current.Dispatcher.BeginInvoke(action); + } + else + { + action(); + } } /// diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs new file mode 100644 index 000000000..5b2808ab1 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +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.SharedUI.Controls +{ + + public class FastTextBlock : Control + { + private FormattedText _formattedText; + + static FastTextBlock() + { + + } + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register( + "Text", + typeof(string), + typeof(FastTextBlock), + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure, + (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue))); + + private void TextPropertyChanged(string text) + { + if (text != null) + { + var typeface = new Typeface( + FontFamily, + FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + + _formattedText = new FormattedText( + text, CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, typeface, FontSize, Foreground); + } + } + + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + protected override void OnRender(DrawingContext drawingContext) + { + if (_formattedText != null) + { + drawingContext.DrawText(_formattedText, new Point()); + } + } + + protected override Size MeasureOverride(Size constraint) + { + return _formattedText != null + ? new Size(_formattedText.Width, _formattedText.Height) + : new Size(); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index a8bd06040..37ba006f0 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -68,6 +68,7 @@ + HiveControl.xaml @@ -235,7 +236,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs new file mode 100644 index 000000000..8e3db84fa --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -0,0 +1,99 @@ +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.Markup; +using System.Windows.Shapes; +using Tango.Core.Threading; + +namespace Tango.Touch.Controls +{ + [ContentProperty(nameof(Content))] + public class TouchVirtualizedContentControl : Control + { + private LightTouchScrollViewer _scrollViewer; + private ContentPresenter _innerBorder; + private ActionTimer _updateTimer; + private Point _location; + private bool _loaded; + + public UIElement Content + { + get { return (UIElement)GetValue(ContentProperty); } + set { SetValue(ContentProperty, value); } + } + public static readonly DependencyProperty ContentProperty = + DependencyProperty.Register("Content", typeof(UIElement), typeof(TouchVirtualizedContentControl), new PropertyMetadata(null)); + + static TouchVirtualizedContentControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchVirtualizedContentControl), new FrameworkPropertyMetadata(typeof(TouchVirtualizedContentControl))); + } + + public TouchVirtualizedContentControl() + { + _updateTimer = new ActionTimer(TimeSpan.FromMilliseconds(200)); + Loaded += TouchVirtualizedContentControl_Loaded; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _innerBorder = GetTemplateChild("PART_innerBorder") as ContentPresenter; + } + + private void TouchVirtualizedContentControl_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + _scrollViewer = this.FindAncestor(); + _scrollViewer.Scrolling += _scrollViewer_Scrolling; + + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer); + + ApplyOptimization(); + _loaded = true; + } + + private void _scrollViewer_Scrolling(object sender, DoubleValueChangedEventArgs e) + { + if (_loaded) + { + //_updateTimer.ResetReplace(() => + //{ + // Dispatcher.BeginInvoke(new Action(() => + // { + ApplyOptimization(); + // })); + //}); + } + } + + private void ApplyOptimization() + { + var _border_viewport = _scrollViewer.GetViewportBorder(); + + if (_border_viewport.IsAncestorOf(this)) + { + //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); + //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); + //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); + if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) + { + if (_innerBorder.Visibility == Visibility.Hidden) + { + _innerBorder.Visibility = Visibility.Visible; + } + } + else + { + if (_innerBorder.Visibility == Visibility.Visible) + { + _innerBorder.Visibility = Visibility.Hidden; + } + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml new file mode 100644 index 000000000..7cd72cc40 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.xaml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 15e455168..3177f206d 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -91,6 +91,7 @@ + @@ -245,6 +246,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -385,7 +390,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index 832a3bf95..b80e058db 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -44,6 +44,7 @@ + diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 880ff9c4a..a3e349ad0 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -5296,12 +5296,12 @@ Global {B822CBD9-1113-4668-85C9-22AA9C24CE60} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal -- cgit v1.3.1 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/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml | 20 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 17 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 1142 ++++++++++---------- .../Controls/TwineCatalogControl.xaml | 15 +- .../PPC/Tango.PPC.UI/MainWindow.xaml.cs | 14 + .../Notifications/DefaultNotificationProvider.cs | 10 +- .../PPC/Tango.PPC.UI/Views/LoginView.xaml | 7 - .../PPC/Tango.PPC.UI/Views/MainView.xaml | 4 +- .../Visual_Studio/Tango.BL/Entities/BrushStop.cs | 12 +- .../Visual_Studio/Tango.BL/Entities/Segment.cs | 1 + .../Tango.DragAndDrop/DragAndDropService.cs | 14 +- .../Tango.SharedUI/Controls/FastTextBlock.cs | 28 +- .../Components/SharedResourceDictionary.cs | 55 + .../Tango.Touch/Controls/TouchAutoComplete.cs | 4 + .../Tango.Touch/Controls/TouchLoadingPanel.xaml | 2 +- .../Tango.Touch/Controls/TouchNumericTextBox.cs | 5 +- .../Tango.Touch/Controls/TouchNumericTextBox.xaml | 22 +- .../Tango.Touch/Controls/TouchPanel.cs | 14 + .../Tango.Touch/Controls/TouchPanel.xaml | 124 ++- .../Tango.Touch/Controls/TouchTextBox.xaml | 2 +- .../Controls/TouchVirtualizedContentControl.cs | 42 +- .../Tango.Touch/Resources/Colors.xaml | 4 +- .../Visual_Studio/Tango.Touch/Resources/Fonts.xaml | 4 +- .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 1 + 26 files changed, 882 insertions(+), 681 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 1d4f688b1..e66689c76 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index dc895c719..42942dacd 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml index e7a416623..be151678d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml @@ -7,7 +7,7 @@ xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:local="clr-namespace:Tango.PPC.Jobs.Controls" mc:Ignorable="d" - d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=entities:Job, IsDesignTimeCreatable=False}"> + d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=entities:Job, IsDesignTimeCreatable=False}" x:Name="control"> @@ -20,7 +20,7 @@ - + @@ -28,12 +28,12 @@ - + - - - + + + @@ -42,13 +42,13 @@ - + @@ -67,7 +67,7 @@ - + @@ -102,7 +102,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 9aaf9fcbd..c7946ee6a 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 @@ -396,7 +396,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); - NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + IsFree = false; _can_navigate_back = false; @@ -433,10 +434,6 @@ namespace Tango.PPC.Jobs.ViewModels SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - InvokeUIOnIdle(() => - { - NotificationProvider.ReleaseGlobalBusyMessage(); - }); _job_to_load = null; } @@ -471,10 +468,16 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log(ex, $"Error loading job '{_job_to_load.Name}'"); await NotificationProvider.ShowError("An error occurred while trying to load the selected job."); } + finally + { + InvokeUIOnIdle(() => + { + IsFree = true; + //NotificationProvider.ReleaseGlobalBusyMessage(); + }); + } } - - /// /// Saves the job. /// 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 893cdc973..cb12805f5 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 @@ -17,11 +17,15 @@ xmlns:localControls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" mc:Ignorable="d" - d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobViewVM}"> + d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobViewVM}" x:Name="view"> + + + + - + - + - + - - + + - - - - - + + - + - - - - - - + + + Color & Length + - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - SOLID SEGMENT - - - - - - - - - - - - - GRADIENT SEGMENT - - - + + + + + + + + + + + SOLID SEGMENT + + + + + + + + + + + + + GRADIENT SEGMENT + + + - - - Include white gap between segments - - + + + Include white gap between segments + + - + - + - - - - + + + + - + - - - Output - + + + Output + - - - - - - - - + + + + + + + - - - - - Job Summary - + + + + + Job Summary + - - - - + + + + - + - - + + - - - - - + + + + + (+%) - - + + - - + + - + - + - % + % - - - + + + + - - + - - Additional Tools - + + Additional Tools + - - - - - - Sample Dye - - + + + + + Sample Dye + + - - - - - - - - - - START - - - - + + + + + + + + + + + + START + + + + - - - - - - How to continue? + + + + + + How to continue? + + + + + + + DONE + + - - - - - - DONE - - + The sample is approved + - The sample is approved - + + + + + REPEAT + + - - + Dye more samples + + + + + + + + + + + + + + + Sample Approved: + + + - - REPEAT + + ANOTHER SAMPLE + + + + + + + + + + - Dye more samples - - - - - - - - - - - - - - - Sample Approved: - - - - - - ANOTHER SAMPLE - - - - - - + + + - - - - - - - - - + + - - - + + + You can use the color fine tuning tool to adjust the colors. - + + - - + - - - - - Color Fine Tuning - - - - - - - - - - - - - - - - - - + + + + + Color Fine Tuning + + - - Reset + - - START - - - - - - - - - - - - - - 1 - - Select the best variation for each color: - + + + + + + + + + + + + + + + + + 2 + + How to continue - - - - - REPEAT - - + + + + + + DONE + + - Some color need more fine tuning - - - - - - + All colors are approved + - - - - - - + + + + + REPEAT + + + + Some color need more fine tuning + + + + + + + + + + + + + Colors Approved: - - - - - REPEAT FINE TUNING - - - - - - - - - - - - - + + + + + REPEAT FINE TUNING + + + + + + + + + + + + + + - - - - - - - - - - + + - - - - - - - - - + + + - - + + + - + - - + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml index 897810c99..f99b299cc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.PPC.Common.Controls" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:catalog="clr-namespace:Tango.BL.Catalogs;assembly=Tango.BL" mc:Ignorable="d" @@ -20,8 +21,8 @@ - - + + @@ -45,8 +46,8 @@ - - + + @@ -54,8 +55,8 @@ - - + + @@ -68,7 +69,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index 364ca8ee7..b90a1afff 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -11,7 +11,9 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -32,6 +34,8 @@ namespace Tango.PPC.UI { Instance = this; + //Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),new FrameworkPropertyMetadata { DefaultValue = 30 }); + InitializeComponent(); bool has_touch = false; @@ -77,6 +81,16 @@ namespace Tango.PPC.UI Closing += MainWindow_Closing; } + protected override void OnSourceInitialized(EventArgs e) + { + //var hwndSource = PresentationSource.FromVisual(this) as HwndSource; + + //if (hwndSource != null) + // hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly; + + base.OnSourceInitialized(e); + } + private void LockAspectRatio() { this.Width = (this.Height * (800d / 1280d)) - 10; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index d7dca484e..5062df1d6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -140,7 +140,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.AlertOctagon, + Icon = TouchIconKind.AlertCircleOutline, Title = "Error", Brush = Application.Current.Resources["TangoMessageBoxErrorBrush"] as Brush, }); @@ -156,7 +156,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.InfoCircleSolid, + Icon = TouchIconKind.AlertCircleOutline, Title = "Information", Brush = Application.Current.Resources["TangoMessageBoxInfoBrush"] as Brush, }); @@ -172,7 +172,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.Alert, + Icon = TouchIconKind.AlertCircleOutline, Title = "Warning", Brush = Application.Current.Resources["TangoMessageBoxWarningBrush"] as Brush, }); @@ -188,7 +188,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.QuestionCircleSolid, + Icon = TouchIconKind.QuestionCircleRegular, Title = "Confirm", HasCancel = true, Brush = Application.Current.Resources["TangoMessageBoxQuestionBrush"] as Brush, @@ -218,6 +218,8 @@ namespace Tango.PPC.UI.Notifications /// private Task ShowMessageBox(MessageBoxVM vm) { + ReleaseGlobalBusyMessage(); + LogManager.Log($"Displaying MessagBox '{vm.Message}'."); TaskCompletionSource source = new TaskCompletionSource(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml index 179d1dde3..dee4e9c7b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml @@ -27,13 +27,6 @@ Forgot password? - - - - - - - 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 c63ef1e13..604c79aeb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -28,7 +28,9 @@ ItemExpandedPropertyPath="IsExpanded" HasDialog="{Binding NotificationProvider.HasDialog}" CurrentDialog="{Binding NotificationProvider.CurrentDialog}" - NotificationBarVisibility="{Binding NotificationProvider.NotificationsVisible,Converter={StaticResource BooleanToVisibilityConverter}}"> + NotificationBarVisibility="{Binding NotificationProvider.NotificationsVisible,Converter={StaticResource BooleanToVisibilityConverter}}" + IsBusy="{Binding NotificationProvider.IsInGlobalBusyState}" + BusyMessage="{Binding NotificationProvider.GlobalBusyMessage}"> diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 8816d9825..6738ad99c 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -211,11 +211,15 @@ namespace Tango.BL.Entities get { return _isOutOfGamut; } set { - _isOutOfGamut = value; RaisePropertyChangedAuto(); - - if (Segment != null) + if (_isOutOfGamut != value) { - Segment.RaiseHasOutOfGamutBrushStop(); + _isOutOfGamut = value; + RaisePropertyChangedAuto(); + + if (Segment != null) + { + Segment.RaiseHasOutOfGamutBrushStop(); + } } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Segment.cs b/Software/Visual_Studio/Tango.BL/Entities/Segment.cs index 7e15b9ea5..a15cb32ab 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Segment.cs @@ -139,6 +139,7 @@ namespace Tango.BL.Entities } [NotMapped] + [JsonIgnore] public bool HasOutOfGamutBrushStop { get { return BrushStops.Any(x => x.IsOutOfGamut); } diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 1c84b8768..e814985e6 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -579,7 +579,7 @@ namespace Tango.DragAndDrop //element.AddHandler(FrameworkElement.PreviewMouseDownEvent, (MouseButtonEventHandler)Draggable_PreviewMouseDown, true); //element.AddHandler(FrameworkElement.MouseMoveEvent, (MouseEventHandler)Draggable_MouseMove, true); //element.AddHandler(FrameworkElement.PreviewMouseUpEvent, (MouseButtonEventHandler)Draggable_PreviewMouseUp, true); - element.Unloaded += Element_Unloaded; + element.Unloaded += Draggable_Unloaded; } } @@ -592,7 +592,7 @@ namespace Tango.DragAndDrop if (!_dropElements.Contains(element)) { _dropElements.Add(element); - element.Unloaded += Element_Unloaded1; + element.Unloaded += Droppable_Unloaded; } } @@ -601,12 +601,10 @@ namespace Tango.DragAndDrop /// /// The source of the event. /// The instance containing the event data. - private static void Element_Unloaded(object sender, RoutedEventArgs e) + private static void Draggable_Unloaded(object sender, RoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; UnRegisterDraggable(element); - element.PreviewMouseUp -= Draggable_PreviewMouseUp; - element.Unloaded -= Element_Unloaded; } /// @@ -614,11 +612,10 @@ namespace Tango.DragAndDrop /// /// The source of the event. /// The instance containing the event data. - private static void Element_Unloaded1(object sender, RoutedEventArgs e) + private static void Droppable_Unloaded(object sender, RoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; UnRegisterDroppable(element); - element.Unloaded -= Element_Unloaded1; } /// @@ -628,6 +625,8 @@ namespace Tango.DragAndDrop private static void UnRegisterDraggable(FrameworkElement element) { _dragElements.Remove(element); + element.PreviewMouseUp -= Draggable_PreviewMouseUp; + element.Unloaded -= Draggable_Unloaded; } /// @@ -637,6 +636,7 @@ namespace Tango.DragAndDrop private static void UnRegisterDroppable(FrameworkElement element) { _dropElements.Remove(element); + element.Unloaded -= Droppable_Unloaded; } /// diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs index 5b2808ab1..141fa6e27 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs @@ -9,6 +9,7 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; @@ -16,14 +17,24 @@ using System.Windows.Shapes; namespace Tango.SharedUI.Controls { - + [ContentProperty(nameof(Text))] public class FastTextBlock : Control { private FormattedText _formattedText; static FastTextBlock() { - + + } + + public FastTextBlock() + { + Loaded += FastTextBlock_Loaded; + } + + private void FastTextBlock_Loaded(object sender, RoutedEventArgs e) + { + Init(); } public static readonly DependencyProperty TextProperty = @@ -31,19 +42,24 @@ namespace Tango.SharedUI.Controls "Text", typeof(string), typeof(FastTextBlock), - new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure, + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue))); private void TextPropertyChanged(string text) { - if (text != null) + Init(); + } + + private void Init() + { + if (Text != null) { var typeface = new Typeface( FontFamily, - FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + FontStyle, FontWeight, FontStretch); _formattedText = new FormattedText( - text, CultureInfo.CurrentCulture, + Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground); } } diff --git a/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs new file mode 100644 index 000000000..efa1e77e4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.Touch.Components +{ + /// + /// The shared resource dictionary is a specialized resource dictionary + /// that loads it content only once. If a second instance with the same source + /// is created, it only merges the resources from the cache. + /// + public class SharedResourceDictionary : ResourceDictionary + { + /// + /// Internal cache of loaded dictionaries + /// + public static Dictionary _sharedDictionaries = + new Dictionary(); + + /// + /// Local member of the source uri + /// + private Uri _sourceUri; + + /// + /// Gets or sets the uniform resource identifier (URI) to load resources from. + /// + public new Uri Source + { + get { return _sourceUri; } + set + { + _sourceUri = value; + + if (!_sharedDictionaries.ContainsKey(value)) + { + // If the dictionary is not yet loaded, load it by setting + // the source of the base class + base.Source = value; + + // add it to the cache + _sharedDictionaries.Add(value, this); + } + else + { + // If the dictionary is already loaded, get it from the cache + MergedDictionaries.Add(_sharedDictionaries[value]); + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs index a684cbf5a..4e1ced33b 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs @@ -203,6 +203,10 @@ namespace Tango.Touch.Controls _textBox.CaretIndex = _textBox.Text.Length; } } + else if (_textBox != null) + { + _textBox.Text = null; + } if (_popup != null) { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml index 4a4cdbba2..9a2a51017 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml @@ -17,7 +17,7 @@ - + - - - + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs index 6c29e4652..bb715abba 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -256,7 +256,21 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty NotificationBarVisibilityProperty = DependencyProperty.Register("NotificationBarVisibility", typeof(Visibility), typeof(TouchPanel), new PropertyMetadata(Visibility.Visible)); + public bool IsBusy + { + get { return (bool)GetValue(IsBusyProperty); } + set { SetValue(IsBusyProperty, value); } + } + public static readonly DependencyProperty IsBusyProperty = + DependencyProperty.Register("IsBusy", typeof(bool), typeof(TouchPanel), new PropertyMetadata(false)); + public String BusyMessage + { + get { return (String)GetValue(BusyMessageProperty); } + set { SetValue(BusyMessageProperty, value); } + } + public static readonly DependencyProperty BusyMessageProperty = + DependencyProperty.Register("BusyMessage", typeof(String), typeof(TouchPanel), new PropertyMetadata(null)); #region Attached Properties diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index e80bd7daa..e7f822bb5 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -73,9 +73,9 @@ - - - + + + @@ -135,18 +135,18 @@ @@ -173,24 +173,24 @@ - + - + + - - - - - - - - - - + + + + + + + + + + - - + + CANCEL + OK + - + - + + + + + - + + + + + - - CANCEL - OK - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml index c00bd40b9..e6acda366 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml @@ -8,7 +8,7 @@ xmlns:local="clr-namespace:Tango.Touch.Controls"> - + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs index 8e3db84fa..02240ecc8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -72,28 +72,28 @@ namespace Tango.Touch.Controls private void ApplyOptimization() { - var _border_viewport = _scrollViewer.GetViewportBorder(); + //var _border_viewport = _scrollViewer.GetViewportBorder(); - if (_border_viewport.IsAncestorOf(this)) - { - //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); - //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); - //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); - if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) - { - if (_innerBorder.Visibility == Visibility.Hidden) - { - _innerBorder.Visibility = Visibility.Visible; - } - } - else - { - if (_innerBorder.Visibility == Visibility.Visible) - { - _innerBorder.Visibility = Visibility.Hidden; - } - } - } + //if (_border_viewport.IsAncestorOf(this)) + //{ + // //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); + // //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); + // //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); + // if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) + // { + // if (_innerBorder.Visibility == Visibility.Hidden) + // { + // _innerBorder.Visibility = Visibility.Visible; + // } + // } + // else + // { + // if (_innerBorder.Visibility == Visibility.Visible) + // { + // _innerBorder.Visibility = Visibility.Hidden; + // } + // } + //} } } } diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml index 1a77b76be..c8a6d0e8d 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml @@ -52,7 +52,7 @@ #757373 #C3F2F5FA - #DDE7FD + #DDE7FD #4E5470 @@ -117,7 +117,7 @@ #121212 #F1F1F1 - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml index 387977e0a..a4732966e 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml @@ -13,8 +13,8 @@ 20 20 - 30 - 20 + 24 + 22 22 23 diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 3177f206d..7600d4c14 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -59,6 +59,7 @@ GlobalVersionInfo.cs + -- 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/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.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