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 | |
| 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')
2 files changed, 34 insertions, 8 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; + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index 8df9e465d..293b947f0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -57,7 +57,7 @@ <TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">HARDWARE DESIGNER</TextBlock> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10 10 0 0"> <materialDesign:PackIcon Kind="Pencil" Width="32" Height="32" Foreground="Silver" /> - <ComboBox ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion}" Width="300" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version"> + <ComboBox IsEnabled="{Binding IsFree}" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion}" Width="300" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="Gray" FontSize="14">v</Run><Run Foreground="Gray" FontSize="14" Text="{Binding Version}"></Run></TextBlock> @@ -72,7 +72,7 @@ <Grid Grid.Row="1"> - <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="50 20 0 0"> + <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="50 20 0 0" IsEnabled="{Binding IsFree}"> <StackPanel> <StackPanel Orientation="Horizontal"> <Image VerticalAlignment="Center" Source="../Images/engine.png" Width="32"></Image> @@ -353,7 +353,7 @@ <RowDefinition Height="60"/> </Grid.RowDefinitions> - <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0 90 0 10"> + <ScrollViewer IsEnabled="{Binding IsFree}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0 90 0 10"> <Grid> <StackPanel> <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}" Padding="20 10"> |
