aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 16:30:00 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 16:30:00 +0300
commit86339c9b8e383b92e183ee443c5bfbebd05808e7 (patch)
tree02e781b86e30d7615c657819ae8e1e98d6abfae8 /Software/Visual_Studio/MachineStudio/Modules
parent072ee0c67a5c9c45be60fa3da915a493731e5b35 (diff)
downloadTango-86339c9b8e383b92e183ee443c5bfbebd05808e7.tar.gz
Tango-86339c9b8e383b92e183ee443c5bfbebd05808e7.zip
ColorLab Module seems to be working ok...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs92
1 files changed, 61 insertions, 31 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
index 5b317e6d2..3764e00de 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
@@ -243,15 +243,10 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
{
_notification = notification;
- _dbContext = ObservablesContext.CreateDefault();
-
CCT = new Cct();
SourceColor = new RgbVM();
SourceColor.ColorChanged += SourceColor_ColorChanged;
- Machines = _dbContext.Machines.ToObservableCollection();
- ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection();
- Rmls = _dbContext.Rmls.ToObservableCollection();
ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null);
ImportInverseDataCommand = new RelayCommand(ImportInverseData, () => SelectedRML != null);
@@ -267,6 +262,21 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
GetHiveSuggestions();
}
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+
+ Task.Factory.StartNew(() =>
+ {
+ _dbContext = ObservablesContext.CreateDefault();
+ _dbContext.Configuration.LazyLoadingEnabled = false;
+
+ Machines = _dbContext.Machines.ToObservableCollection();
+ ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection();
+ Rmls = _dbContext.Rmls.ToObservableCollection();
+ });
+ }
+
#region ColorLab
private void GetHiveSuggestions()
@@ -417,6 +427,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
{
if (SelectedMachine != null)
{
+ _dbContext.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid);
+
LiquidVolumes = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM()
{
Color = x.LiquidType.Color,
@@ -424,6 +436,9 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
IdsPack = x,
}).ToObservableCollection();
+
+ LiquidVolumes.EnableCrossThreadOperations();
+
LiquidVolumes.ToList().ForEach(x => x.VolumeChanged += (s, e) => OnLiquidVolumeChanged());
InvalidateLiquidFactorsCalibrationData();
@@ -515,42 +530,57 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
#region RML
- private void InvalidateLiquidFactorsCalibrationData()
+ private async void InvalidateLiquidFactorsCalibrationData()
{
if (SelectedRML != null && SelectedMachine != null)
{
- LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList();
- //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active);
+ await Task.Factory.StartNew(() =>
+ {
+ using (_notification.PushTaskItem("Loading RML data..."))
+ {
+ _dbContext.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid);
+ _dbContext.GetRmlCCTs(SelectedRML.Guid);
+ _dbContext.GetRmlCATs(SelectedRML.Guid, SelectedMachine.Guid);
+ _dbContext.GetRmlLiquidTypes(SelectedRML.Guid);
- LiquidsCalibrationData = new ObservableCollection<CalibrationDataVM>();
+ LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList();
+ //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active);
- foreach (var idsPack in SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex))
- {
- CalibrationDataVM vm = new CalibrationDataVM();
- vm.Name = idsPack.LiquidType.Name;
- vm.Color = idsPack.LiquidType.Color;
- vm.IdsPack = idsPack;
+ LiquidsCalibrationData = new ObservableCollection<CalibrationDataVM>();
+ LiquidsCalibrationData.EnableCrossThreadOperations();
- var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.Machine == SelectedMachine && x.Rml == SelectedRML);
+ foreach (var idsPack in SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex))
+ {
+ CalibrationDataVM vm = new CalibrationDataVM();
+ vm.Name = idsPack.LiquidType.Name;
+ vm.Color = idsPack.LiquidType.Color;
+ vm.IdsPack = idsPack;
- if (cat != null)
- {
- var calData = cat.GetCalibrationData();
- vm.CalibrationPoints = calData.CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection();
- }
+ var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.Machine == SelectedMachine && x.Rml == SelectedRML);
- LiquidsCalibrationData.Add(vm);
- }
+ if (cat != null)
+ {
+ var calData = cat.GetCalibrationData();
+ vm.CalibrationPoints = calData.CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection();
+ }
- _isNewCCT = false;
- CCT = SelectedRML.Ccts.FirstOrDefault();
+ InvokeUINow(() =>
+ {
+ LiquidsCalibrationData.Add(vm);
+ });
+ }
- if (CCT == null)
- {
- CCT = new Cct();
- CCT.Rml = SelectedRML;
- _isNewCCT = true;
- }
+ _isNewCCT = false;
+ CCT = SelectedRML.Ccts.FirstOrDefault();
+
+ if (CCT == null)
+ {
+ CCT = new Cct();
+ CCT.Rml = SelectedRML;
+ _isNewCCT = true;
+ }
+ }
+ });
}
}