diff options
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; + } } } } |
