From fdfa740288568dba27877a5ef5c817be323cfbb0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 13:47:20 +0300 Subject: Working on PPC. --- .../MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index d9710b5fc..53eb632e9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Sun 07/15/2018 18:18:51.73 +Mon 07/16/2018 10:23:46.28 -- cgit v1.3.1 From 13e34402f91fae6229b2d9719ddb48ced1d37fbf Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 15:51:33 +0300 Subject: Some fixed and improvements. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../ViewModels/MainViewVM.cs | 1 + .../Views/JobView.xaml | 6 +- .../Views/MainView.xaml | 8 +- .../Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- .../ViewModels/MainViewVM.cs | 8 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 21 +++-- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 32 +++---- .../Tango.BL/EntitiesExtensions/Contact.cs | 8 +- .../Tango.BL/EntitiesExtensions/Job.cs | 14 +++ .../Tango.BL/EntitiesExtensions/User.cs | 25 +++--- .../Visual_Studio/Tango.BL/IObservableEntity.cs | 10 +-- .../Visual_Studio/Tango.BL/ObservableEntity.cs | 98 ++++++++++++++++++++- .../Tango.Core/Commands/RelayCommand.cs | 2 +- 16 files changed, 173 insertions(+), 64 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index b7bb164a4..7ec69c408 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 6ae13450e..493f8b3a4 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index dacbc89b1..b4e588700 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1478,6 +1478,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { seg.SegmentIndex = 1; } + ActiveJob.Segments.Add(seg); SelectedSegment = seg; AddBrushStop(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index fc62c0128..b4deb72a9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -1085,7 +1085,7 @@ - + @@ -1129,7 +1129,7 @@ - + @@ -1149,7 +1149,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 2ece5c76b..fd3b2289d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -110,7 +110,7 @@ - + @@ -179,7 +179,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -207,7 +207,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index 53eb632e9..a112fbafb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Mon 07/16/2018 10:23:46.28 +Mon 07/16/2018 15:39:26.63 diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index fd28d5b1e..a7762a5e6 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -444,9 +444,9 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (!x.SelectedMachine.EnableDiagnostics) + if (x.SelectedMachine.EnableDiagnostics) { - x.SelectedMachine.EnableEmbeddedDebugging = false; + x.SelectedMachine.EnableEmbeddedDebugging = true; } await x.SelectedMachine.Connect(); @@ -484,9 +484,9 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (!x.SelectedMachine.EnableDiagnostics) + if (x.SelectedMachine.EnableDiagnostics) { - x.SelectedMachine.EnableEmbeddedDebugging = false; + x.SelectedMachine.EnableEmbeddedDebugging = true; } await x.SelectedMachine.Connect(); 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 92c9b4b94..0b53974d2 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 @@ -248,9 +248,12 @@ namespace Tango.PPC.Jobs.ViewModels /// private async void SaveJob() { - await _db.SaveChangesAsync(); - RaiseMessage(new JobSavedMessage() { Job = Job }); - await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); + if (Job.Validate(_db)) + { + await _db.SaveChangesAsync(); + RaiseMessage(new JobSavedMessage() { Job = Job }); + await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); + } } /// @@ -471,7 +474,7 @@ namespace Tango.PPC.Jobs.ViewModels { Thread.Sleep(500); - if (Job != null && IsVisible) + if (Job != null && IsVisible && (Job.ColorSpace != null && Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32())) { var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.Corrected && !x.OutOfGamutChecked).ToList(); @@ -481,10 +484,13 @@ namespace Tango.PPC.Jobs.ViewModels stop.OutOfGamutChecked = true; } - InvokeUI(() => + if (brushStops.Count > 0) { - DyeCommand.RaiseCanExecuteChanged(); - }); + InvokeUI(() => + { + DyeCommand.RaiseCanExecuteChanged(); + }); + } } } } @@ -520,6 +526,7 @@ namespace Tango.PPC.Jobs.ViewModels _db = ObservablesContext.CreateDefault(); Job = await _db.Jobs.SingleOrDefaultAsync(x => x.Guid == _job_to_load.Guid); + Job.ValidateOnPropertyChanged = true; Rmls = await _db.Rmls.ToListAsync(); ColorSpaces = await _db.ColorSpaces.ToListAsync(); SpoolTypes = await _db.SpoolTypes.ToListAsync(); 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 656b0b33a..a9aebb068 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 @@ -365,7 +365,7 @@ Job name: - + Customer: 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 3aa6e0118..7f1c1a115 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -26,8 +26,8 @@ - - + + - - - - Home + + + + Home - + - - - - + + + + @@ -84,11 +84,11 @@ - - - - - Sign Out + + + + + Sign Out diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Contact.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Contact.cs index 26f0329b0..8dcfda32d 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Contact.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Contact.cs @@ -34,18 +34,18 @@ namespace Tango.BL.Entities FullName = FirstName + " " + LastName; } - public override void Validate(ObservablesContext context) + protected override void OnValidating(ObservablesContext context) { - base.Validate(context); + base.OnValidating(context); if (FirstName.IsNullOrWhiteSpace() || LastName.IsNullOrWhiteSpace()) { - throw new ArgumentException("Contact first name and last name was not provided."); + InsertError(nameof(FirstName), "Contact first name and last name was not provided."); } if (!Email.IsEmail()) { - throw new ArgumentException("Invalid contact email format."); + InsertError(nameof(Email), "Invalid contact email format."); } } } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index 0c5a72bd8..e5144386a 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -379,5 +379,19 @@ namespace Tango.BL.Entities } #endregion + + #region Validation + + protected override void OnValidating(ObservablesContext context) + { + base.OnValidating(context); + + if (String.IsNullOrWhiteSpace(Name)) + { + InsertError(nameof(Name), "Job name is required"); + } + } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/User.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/User.cs index 0d1e864ee..6c1b03145 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/User.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/User.cs @@ -85,37 +85,34 @@ namespace Tango.BL.Entities } } - public override void Validate(ObservablesContext context) + public override bool Validate(ObservablesContext context) { + return base.Validate(context) && Contact.Validate(context) && Address.Validate(context); + } + + protected override void OnValidating(ObservablesContext context) + { + base.OnValidating(context); + var users = context.Users.ToList(); if (users.Exists(x => x.Guid != Guid && x.Email.ToLower() == Email.ToLower())) { - throw new ArgumentException("The specified email is already taken by another account."); + InsertError(nameof(Email), "The specified email is already taken by another account."); } if (!Email.IsEmail()) { - throw new ArgumentException("The specified email address is invalid."); + InsertError(nameof(Email), "The specified email address is invalid."); } if (_passwordGatewayModified) { if (!PasswordGateWay.IsBetweenLength(4, 30)) { - throw new ArgumentException("A user password must be at least 4 characters long and maximum 30."); + InsertError(nameof(PasswordGateWay), "A user password must be at least 4 characters long and maximum 30."); } } - - if (Contact != null) - { - Contact.Validate(context); - } - - if (Address != null) - { - Address.Validate(context); - } } /// diff --git a/Software/Visual_Studio/Tango.BL/IObservableEntity.cs b/Software/Visual_Studio/Tango.BL/IObservableEntity.cs index dcb7ad5da..d83f3a6b2 100644 --- a/Software/Visual_Studio/Tango.BL/IObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/IObservableEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity; @@ -13,7 +14,7 @@ namespace Tango.BL /// /// Represents an observable database entity. /// - public interface IObservableEntity : IParameterized + public interface IObservableEntity : INotifyDataErrorInfo, IParameterized { /// /// Occurs after this observable has been saved. @@ -84,13 +85,6 @@ namespace Tango.BL /// Task DeleteCascadeAsync(ObservablesContext context); - /// - /// Performs entity field validation. - /// Will throw an exception with the proper message if one of the fields is invalid. - /// - /// The context. - void Validate(ObservablesContext context); - /// /// Gets the database set containing this entity. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs index 7c82d927b..99d7360ef 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs @@ -22,6 +22,7 @@ using Tango.Serialization; using System.Xml.Serialization; using Newtonsoft.Json; using Tango.Logging; +using System.ComponentModel; namespace Tango.BL { @@ -35,6 +36,7 @@ namespace Tango.BL public abstract class ObservableEntity : ExtendedObject, IObservableEntity where T : class, IObservableEntity { private Regex regExDAL; + private List> _currentErrors = new List>(); //Holds the current validation errors. /// /// Occurs after this observable has been saved. @@ -323,9 +325,36 @@ Maybe you have deleted an entity that was no yet inserted into database?", LogCa /// Will throw an exception with the proper message if one of the fields is invalid. /// /// The context. - public virtual void Validate(ObservablesContext context) + public virtual bool Validate(ObservablesContext context) { + HasErrors = false; + _currentErrors.Clear(); + if (ValidationErrors == null) + { + ValidationErrors = new ObservableCollection(); + } + + ValidationErrors.Clear(); + + OnValidating(context); + + foreach (var prop in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + foreach (var validation in prop.GetCustomAttributes()) + { + if (!validation.IsValid(prop.GetValue(this))) + { + _currentErrors.Add(new KeyValuePair(prop.Name, validation.ErrorMessage)); + ValidationErrors.Add(validation.ErrorMessage); + } + } + + HasErrors = _currentErrors.Count > 0; + RaiseError(prop.Name); + } + + return !HasErrors; } public DbSet GetDbSet(ObservablesContext context) where T1 : class, IObservableEntity @@ -333,6 +362,73 @@ Maybe you have deleted an entity that was no yet inserted into database?", LogCa return GetDbSet(context) as DbSet; } + public IEnumerable GetErrors(string propertyName) + { + return _currentErrors.Where(x => x.Key == propertyName).Select(x => x.Value).ToList(); + } + + protected virtual void OnValidating(ObservablesContext context) + { + + } + + protected void InsertError(String propName, String error) + { + _currentErrors.Add(new KeyValuePair(propName, error)); + } + + private bool _validateOnPropertyChanged; + [NotMapped] + public bool ValidateOnPropertyChanged + { + get { return _validateOnPropertyChanged; } + set { _validateOnPropertyChanged = value; RaisePropertyChangedAuto(); } + } + + + /// + /// Invoked the event. + /// + /// Name of the property. + protected void RaiseError(String propName) + { + ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propName)); + } + + private bool _hasErrors; + /// + /// Gets a value that indicates whether the entity has validation errors. + /// + [NotMapped] + public bool HasErrors + { + get { return _hasErrors; } + set { _hasErrors = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _validationErrors; + /// + /// Gets or sets the validation errors. + /// + [NotMapped] + public ObservableCollection ValidationErrors + { + get { return _validationErrors; } + protected set { _validationErrors = value; RaisePropertyChangedAuto(); } + } + + public event EventHandler ErrorsChanged; + + protected override void RaisePropertyChanged(string propName) + { + base.RaisePropertyChanged(propName); + + if (ValidateOnPropertyChanged) + { + Validate(null); + } + } + #region Operator Overloading //public static bool operator ==(ObservableEntity observable1, ObservableEntity observable2) diff --git a/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs b/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs index 761038284..b3964d1e0 100644 --- a/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs +++ b/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs @@ -40,7 +40,7 @@ namespace Tango.Core.Commands } - public RelayCommand(Action action, Func canExecuteChange) : this((x) => action(), new Func((x) => true)) + public RelayCommand(Action action, Func canExecute) : this((x) => action(), canExecute) { } -- cgit v1.3.1 From 69bbedacee151090d5d0b6665b3a1614e65f1997 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 20:01:10 +0300 Subject: Added color conversion to Machine Studio. Fixed issue with segments cloning. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Images/arrow-long-right.png | Bin 0 -> 2169 bytes .../Tango.MachineStudio.Developer.csproj | 7 ++ .../ViewModels/MainViewVM.cs | 109 ++++++++++++++++++++- .../Views/JobView.xaml | 48 ++++++++- .../Views/JobView.xaml.cs | 23 +++++ .../ViewModels/ApplicationLogsViewVM.cs | 1 + .../ViewModels/EmbeddedLogsViewVM.cs | 1 + .../ViewModels/EventsViewVM.cs | 1 + .../Tango.MachineStudio.Common/StudioViewModel.cs | 10 +- .../Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- .../Tango.BL/EntitiesExtensions/Job.cs | 5 + .../Tango.BL/EntitiesExtensions/Segment.cs | 6 ++ .../Implementation/BrushPicker.cs | 7 +- Software/Visual_Studio/Versioning/MachineStudio.cs | 4 +- 16 files changed, 211 insertions(+), 13 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 7ec69c408..972c5075b 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 493f8b3a4..3e7545385 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png new file mode 100644 index 000000000..6c089d44e Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f8f121dff..46396c791 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -224,6 +224,10 @@ {b112d89a-a106-41ae-a0c1-4abc84c477f5} Tango.DragAndDrop + + {942134ac-6ea2-4500-8f22-0f739b70a05f} + Tango.Hive + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration @@ -349,5 +353,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index b4e588700..ab74fcca8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -38,6 +38,7 @@ using System.Threading; using Tango.SharedUI.Helpers; using Tango.Core.DI; using Tango.MachineStudio.Common; +using Tango.BL.ColorConversion; namespace Tango.MachineStudio.Developer.ViewModels { @@ -64,9 +65,32 @@ namespace Tango.MachineStudio.Developer.ViewModels private DataCapture.ViewModels.MainViewVM _dataCaptureVM; private bool _isRecording; private DeveloperModuleSettings _settings; + private Thread _colorConversionThread; + private bool _hiveOpened; + private bool _color_changed_from_hive; #region Properties + private List _hiveSuggestions; + /// + /// Gets or sets the hive suggestions. + /// + public List HiveSuggestions + { + get { return _hiveSuggestions; } + set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } + } + + private ColorConversionSuggestion _selectedSuggestion; + /// + /// Gets or sets the selected suggestion. + /// + public ColorConversionSuggestion SelectedSuggestion + { + get { return _selectedSuggestion; } + set { _selectedSuggestion = value; RaisePropertyChangedAuto(); OnSelectedSuggestionChanged(); } + } + private RunningJobStatus _runningJobStatus; /// /// Gets or sets the running job status. @@ -670,6 +694,83 @@ namespace Tango.MachineStudio.Developer.ViewModels ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; _eventLogger.NewLog += _eventLogger_NewLog; + + _colorConversionThread = new Thread(ColorConversionThreadMethod); + _colorConversionThread.IsBackground = true; + _colorConversionThread.Start(); + } + + private void ColorConversionThreadMethod() + { + while (true) + { + if (IsVisible && ActiveJob != null) + { + var stops = ActiveJob.Segments.SelectMany(x => x.BrushStops); + + foreach (var stop in stops) + { + if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32()) + { + try + { + var output = TangoColorConverter.GetSuggestions(stop); + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + } + catch { } + } + } + } + + Thread.Sleep(500); + } + } + + public void OnHivePopupOpened() + { + if (SelectedBrushStop != null) + { + _hiveOpened = true; + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop)); + } + } + + private void OnSelectedSuggestionChanged() + { + if (SelectedSuggestion != null && SelectedBrushStop != null && _hiveOpened) + { + _color_changed_from_hive = true; + SelectedBrushStop.Color = SelectedSuggestion.Color; + + var coords = SelectedSuggestion.Coordinates; + + foreach (var liquid in coords.OutputLiquids) + { + var liquidVolume = SelectedBrushStop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == liquid.LiquidType.ToInt32()); + + if (liquidVolume != null) + { + liquidVolume.Volume = liquid.Volume; + } + } + + _color_changed_from_hive = false; + } + } + + public void OnSelectedBrushColorChanged(Color color) + { + if (!_color_changed_from_hive && _hiveOpened) + { + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop)); + } + } + + public void OnHivePopupClosed() + { + _hiveOpened = false; } #endregion @@ -1045,7 +1146,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } }; - _jobHandler.UnitCompleted += (x, unit) => + _jobHandler.UnitCompleted += (x, unit) => { _speech.SpeakInfo(String.Format("{0} Units Completed.", unit + 1)); _eventLogger.Log(String.Format("{0} Units Completed.", unit + 1)); @@ -1299,7 +1400,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Saves the active job. /// - private async void SaveActiveJob() + private void SaveActiveJob() { if (ActiveJob != null) { @@ -1310,7 +1411,7 @@ namespace Tango.MachineStudio.Developer.ViewModels ActiveJob.Rml = SelectedRML; ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; - await ActiveJob.SaveAsync(_activeJobDbContext); + _activeJobDbContext.SaveChanges(); ReloadMachine(); SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == ActiveJob.Guid); } @@ -1836,7 +1937,5 @@ namespace Tango.MachineStudio.Developer.ViewModels } #endregion - - } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index b4deb72a9..e350f966b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -5,7 +5,10 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorConversion="clr-namespace:Tango.BL.ColorConversion;assembly=Tango.BL" + xmlns:hive="clr-namespace:Tango.Hive;assembly=Tango.Hive" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:techViews="clr-namespace:Tango.MachineStudio.Technician.Views;assembly=Tango.MachineStudio.Technician" @@ -66,6 +69,7 @@ + @@ -136,7 +140,7 @@ - + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index b48e91f31..bb17a502d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -242,5 +242,28 @@ namespace Tango.MachineStudio.Developer.Views editor.ParameterizedObject = draggedItem.ParameterizedObject; } } + + private void PopupButton_Checked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupOpened(); + } + + private void BrushPicker_ColorChanged(object sender, BrushPicker.ColorChangedEventArgs e) + { + + } + + private void ColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (e.NewValue.HasValue) + { + _vm.OnSelectedBrushColorChanged((Color)e.NewValue); + } + } + + private void PopupButton_Unchecked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupClosed(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs index 2bb96c1e5..2b12b1670 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs @@ -173,6 +173,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs index ba18cbdb1..1895dd230 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs @@ -175,6 +175,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index c4f391c55..98fcf12db 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -181,6 +181,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) { _notification.ShowModalDialog(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); + SelectedEvent = null; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 77fad1fc6..96715dc20 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -15,6 +15,8 @@ namespace Tango.MachineStudio.Common /// public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel { + public bool IsVisible { get; private set; } + /// /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// @@ -42,6 +44,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -50,6 +53,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -88,6 +92,8 @@ namespace Tango.MachineStudio.Common /// public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule { + public bool IsVisible { get; private set; } + /// /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// @@ -115,6 +121,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -123,6 +130,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -149,7 +157,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnApplicationStarted() { - + } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index a112fbafb..4e5321cc7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Mon 07/16/2018 15:39:26.63 +Mon 07/16/2018 19:59:53.31 diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index e5144386a..29e517695 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -267,6 +267,11 @@ namespace Tango.BL.Entities cloned.WindingMethod = WindingMethod; cloned.Segments = Segments.Select(x => x.Clone(cloned)).ToObservableCollection(); + foreach (var segment in cloned.Segments) + { + segment.JobGuid = cloned.Guid; + segment.Job = cloned; + } return cloned; } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs index 4b7c11272..634047f24 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs @@ -137,6 +137,12 @@ namespace Tango.BL.Entities cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToObservableCollection(); + foreach (var stop in cloned.BrushStops) + { + stop.SegmentGuid = cloned.Guid; + stop.Segment = cloned; + } + return cloned; } diff --git a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs index 5c834dcdf..d3bd2e372 100644 --- a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs +++ b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs @@ -553,10 +553,13 @@ namespace Tango.BrushPicker c.G = color.G; c.B = color.B; + if (e.OldValue != e.NewValue) + { + c.RaiseColorChangedEvent((Color)e.NewValue); + } + c._RGBSetInternally = false; } - - c.RaiseColorChangedEvent((Color)e.NewValue); } } diff --git a/Software/Visual_Studio/Versioning/MachineStudio.cs b/Software/Visual_Studio/Versioning/MachineStudio.cs index 072b392db..6aac33a9c 100644 --- a/Software/Visual_Studio/Versioning/MachineStudio.cs +++ b/Software/Visual_Studio/Versioning/MachineStudio.cs @@ -9,5 +9,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © Twine LTD 2017")] [assembly: AssemblyTrademark("Twine LTD")] -[assembly: AssemblyVersion("1.0.0.14")] -[assembly: AssemblyFileVersion("1.0.0.14")] +[assembly: AssemblyVersion("1.0.0.15")] +[assembly: AssemblyFileVersion("1.0.0.15")] -- cgit v1.3.1