diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-22 18:33:29 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-22 18:33:29 +0300 |
| commit | 439ee2d80eab039c2dee00f697d2d814ec67247e (patch) | |
| tree | dccddef098f5960b42bd60ab817e5cf5678f4c07 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels | |
| parent | f3ed76912f8dc895023b2afb92d605ddde1f0c42 (diff) | |
| download | Tango-439ee2d80eab039c2dee00f697d2d814ec67247e.tar.gz Tango-439ee2d80eab039c2dee00f697d2d814ec67247e.zip | |
Added IsFree to base ViewModel.
Implemented IsFree on HardwareVersions & ColorLab modules.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 9e67c247b..9197ad989 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -69,14 +69,14 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion = new HardwareVersion(); - SaveCommand = new RelayCommand(Save, () => SelectedVersion != null); - NewCommand = new RelayCommand(New); - DeleteCommand = new RelayCommand(Delete, () => !_isNew && SelectedVersion != null); + SaveCommand = new RelayCommand(Save, () => SelectedVersion != null && IsFree); + NewCommand = new RelayCommand(New,() => IsFree); + DeleteCommand = new RelayCommand(Delete, () => !_isNew && SelectedVersion != null && IsFree); CurrentVersion = new HardwareVersion(); - CopyParametersCommand = new RelayCommand(CopyParameters, (x) => SelectedVersion != null); - CloneCommand = new RelayCommand(CloneCurrentVersion, () => SelectedVersion != null); + CopyParametersCommand = new RelayCommand(CopyParameters, (x) => SelectedVersion != null && IsFree); + CloneCommand = new RelayCommand(CloneCurrentVersion, () => SelectedVersion != null && IsFree); } public override void OnApplicationReady() @@ -218,6 +218,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { using (_notification.PushTaskItem("Loading hardware version...")) { + IsFree = false; + await Task.Factory.StartNew(() => { _isNew = false; @@ -232,6 +234,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels RaisePropertyChanged(nameof(SelectedVersion)); }); }); + + IsFree = true; } } @@ -246,6 +250,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { using (_notification.PushTaskItem("Creating new machine version...")) { + IsFree = false; + await Task.Factory.StartNew(() => { SelectedVersion = null; @@ -268,6 +274,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels _isNew = true; InvalidateRelayCommands(); }); + + IsFree = true; } } } @@ -278,6 +286,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { try { + IsFree = false; + await Task.Factory.StartNew(() => { _db.SaveChanges(); @@ -294,6 +304,10 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels LogManager.Log(ex, "Could not save hardware version."); _notification.ShowError($"An error occurred while trying to save this hardware version.\n{ex.Message}"); } + finally + { + IsFree = true; + } } } @@ -309,6 +323,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { try { + IsFree = false; + await Task.Factory.StartNew(() => { var cloned = CurrentVersion.Clone(); @@ -329,6 +345,10 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels LogManager.Log(ex, "Could not clone hardware version."); _notification.ShowError($"An error occurred while trying to clone this hardware version.\n{ex.Message}"); } + finally + { + IsFree = true; + } } } } @@ -343,6 +363,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { try { + IsFree = false; + await CurrentVersion.DeleteCascadeAsync(_db); await Task.Factory.StartNew(() => @@ -360,6 +382,10 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels LogManager.Log(ex, "Could not delete hardware version."); _notification.ShowError($"An error occurred while trying to delete this hardware version.\n{ex.Message}"); } + finally + { + IsFree = true; + } } } } |
