diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 55 |
1 files changed, 46 insertions, 9 deletions
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 2e5d42296..7a1c94504 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 @@ -33,6 +33,7 @@ using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.Video; using Tango.Integration.Services; using Tango.MachineStudio.Developer.Navigation; +using System.Data.Entity; namespace Tango.MachineStudio.Developer.ViewModels { @@ -50,9 +51,25 @@ namespace Tango.MachineStudio.Developer.ViewModels private DeveloperNavigationManager _navigation; private ObservablesContext _dbJobContext; private Job _jobFromList; + private bool _blockInvalidateCommands; #region Properties + private ObservableCollection<ColorSpace> _colorSpaces; + + public ObservableCollection<ColorSpace> ColorSpaces + { + get { return _colorSpaces; } + set { _colorSpaces = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection<Rml> _rmls; + + public ObservableCollection<Rml> Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Gets or sets the application manager. /// </summary> @@ -631,21 +648,34 @@ namespace Tango.MachineStudio.Developer.ViewModels { await Task.Factory.StartNew(() => { + _blockInvalidateCommands = false; + _dbJobContext = ObservablesContext.CreateDefault(); + _dbJobContext.Configuration.LazyLoadingEnabled = true; + + ColorSpaces = _dbJobContext.ColorSpaces.ToObservableCollection(); + Rmls = _dbJobContext.Rmls.ToObservableCollection(); _jobFromList = SelectedJob; - SelectedJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid); - SelectedRML = SelectedJob.Rml; + _selectedJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid); + _selectedRML = SelectedJob.Rml; - SelectedSegment = SelectedJob.Segments.FirstOrDefault(); + _selectedSegment = SelectedJob.Segments.FirstOrDefault(); SelectedJob.LengthChanged -= SelectedJob_LengthChanged; SelectedJob.LengthChanged += SelectedJob_LengthChanged; + SelectedJob = _selectedJob; + SelectedRML = _selectedRML; + SelectedSegment = _selectedSegment; + UpdateEstimatedDuration(); - }); - _navigation.NavigateTo(DeveloperNavigationView.JobView); + _blockInvalidateCommands = false; + InvalidateRelayCommands(); + + InvokeUI(() => _navigation.NavigateTo(DeveloperNavigationView.JobView)); + }); } } } @@ -654,11 +684,11 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedJob != null) { - using (_notification.PushTaskItem("Saving machine jobs...")) + using (_notification.PushTaskItem("Saving job to database...")) { SelectedJob.LastUpdated = DateTime.UtcNow; SelectedJob.Rml = SelectedRML; - await _dbJobContext.SaveChangesAsync(); + await SelectedJob.SaveAsync(); await _jobFromList.Reload(); } } @@ -936,7 +966,9 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedRML != null && SelectedMachine != null) { LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); - RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.SingleOrDefault(x => x.Active); + RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); + + _selectedGroupHistory = RmlProcessParametersTableGroup; if (RmlProcessParametersTableGroup != null) { @@ -945,6 +977,8 @@ namespace Tango.MachineStudio.Developer.ViewModels } GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); + + RaisePropertyChangedAuto(nameof(SelectedGroupHistory)); } } @@ -1075,7 +1109,10 @@ namespace Tango.MachineStudio.Developer.ViewModels { base.RaisePropertyChangedAuto(caller); - InvalidateRelayCommands(); + if (!_blockInvalidateCommands) + { + InvalidateRelayCommands(); + } } #endregion |
