From 439ee2d80eab039c2dee00f697d2d814ec67247e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 22 Aug 2018 18:33:29 +0300 Subject: Added IsFree to base ViewModel. Implemented IsFree on HardwareVersions & ColorLab modules. --- .../ViewModels/MainViewVM.cs | 40 +++++++++++++++++++--- .../Views/MainView.xaml | 6 ++-- .../Views/JobView.xaml | 4 +-- .../ViewModels/MainViewVM.cs | 36 ++++++++++++++++--- .../Views/MainView.xaml | 6 ++-- .../Tango.MachineStudio.Common/StudioViewModel.cs | 17 --------- .../ViewModels/UpdateViewVM.cs | 3 ++ 7 files changed, 77 insertions(+), 35 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') 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 3764e00de..5c513af9e 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 @@ -239,6 +239,12 @@ namespace Tango.MachineStudio.ColorLab.ViewModels #endregion + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The notification. public MainViewVM(INotificationProvider notification) : base() { _notification = notification; @@ -248,20 +254,28 @@ namespace Tango.MachineStudio.ColorLab.ViewModels SourceColor = new RgbVM(); SourceColor.ColorChanged += SourceColor_ColorChanged; - ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null); - ImportInverseDataCommand = new RelayCommand(ImportInverseData, () => SelectedRML != null); + ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null && IsFree); + ImportInverseDataCommand = new RelayCommand(ImportInverseData, () => SelectedRML != null && IsFree); - ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && CCT != null && CCT.ForwardFileName != null); - ExportInverseDataCommand = new RelayCommand(ExportInverseData, () => SelectedRML != null && CCT != null && CCT.InverseFileName != null); + ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && CCT != null && CCT.ForwardFileName != null && IsFree); + ExportInverseDataCommand = new RelayCommand(ExportInverseData, () => SelectedRML != null && CCT != null && CCT.InverseFileName != null && IsFree); - SaveCommand = new RelayCommand(Save, () => SelectedRML != null); + SaveCommand = new RelayCommand(Save, () => SelectedRML != null && IsFree); } + #endregion + + #region Event Handlers + private void SourceColor_ColorChanged(object sender, Color e) { GetHiveSuggestions(); } + #endregion + + #region Application Ready + public override void OnApplicationReady() { base.OnApplicationReady(); @@ -277,6 +291,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels }); } + #endregion + #region ColorLab private void GetHiveSuggestions() @@ -427,6 +443,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { if (SelectedMachine != null) { + IsFree = false; + _dbContext.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid); LiquidVolumes = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() @@ -445,6 +463,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels SelectedMachine.Modified -= SelectedMachine_Modified; SelectedMachine.Modified += SelectedMachine_Modified; + + IsFree = true; } } @@ -534,6 +554,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { if (SelectedRML != null && SelectedMachine != null) { + IsFree = false; + await Task.Factory.StartNew(() => { using (_notification.PushTaskItem("Loading RML data...")) @@ -581,6 +603,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } } }); + + IsFree = true; } } @@ -594,6 +618,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { try { + IsFree = false; + if (_isNewCCT) { _dbContext.Ccts.Add(CCT); @@ -631,6 +657,10 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { _notification.ShowError(LogManager.Log(ex, "An error occurred while trying to save to data base.").Message + Environment.NewLine + ex.Message); } + finally + { + IsFree = true; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml index d8ef015be..78eaf04e8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml @@ -35,7 +35,7 @@ - +