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 | |
| 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')
7 files changed, 77 insertions, 35 deletions
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 + + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> + /// <param name="notification">The notification.</param> 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 @@ <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> - <Grid Background="#B1FFFFFF"> + <Grid Background="#B1FFFFFF" IsEnabled="{Binding IsFree}"> <DockPanel> <Grid DockPanel.Dock="Bottom" Margin="20"> <Button Height="60" Command="{Binding SaveCommand}" Width="200" HorizontalAlignment="Right"> @@ -269,7 +269,7 @@ </StackPanel> </StackPanel> - <ItemsControl ItemsSource="{Binding LiquidVolumes}" VerticalAlignment="Center" MinWidth="420"> + <ItemsControl ItemsSource="{Binding LiquidVolumes}" VerticalAlignment="Center" MinWidth="420" IsEnabled="{Binding IsFree}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> @@ -361,7 +361,7 @@ </Grid> <Grid Margin="0 20 0 0"> - <ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding LiquidsCalibrationData}"> + <ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding LiquidsCalibrationData}" IsEnabled="{Binding IsFree}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Rows="1" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 368f615a0..016718075 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -1493,9 +1493,9 @@ </Grid> </Grid> </Expander> - <Expander Header="CONTROL PARAMETERS" IsExpanded="False" Background="#8EFFFFFF"> + <!--<Expander Header="CONTROL PARAMETERS" IsExpanded="False" Background="#8EFFFFFF"> - </Expander> + </Expander>--> </StackPanel> </ScrollViewer> 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"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 36e3994ad..08ddbc073 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -108,14 +108,6 @@ namespace Tango.MachineStudio.Common public bool IsModuleLoaded { get; private set; } /// <summary> - /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class. - /// </summary> - public StudioViewModel() : base() - { - - } - - /// <summary> /// Called when another module has wants to navigate to this module with some arguments. /// </summary> /// <param name="args">The arguments.</param> @@ -187,15 +179,6 @@ namespace Tango.MachineStudio.Common public abstract class StudioViewModel<Module, T> : ViewModel<T>, IStudioViewModel where Module : IStudioModule where T : IView { /// <summary> - /// Initializes a new instance of the <see cref="StudioViewModel{Module, T}"/> class. - /// </summary> - /// <param name="view">The view.</param> - public StudioViewModel(T view) : base(view) - { - - } - - /// <summary> /// Called when the application has been started /// </summary> public virtual void OnApplicationStarted() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index f2550c598..6dbc99591 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -294,6 +294,9 @@ namespace Tango.MachineStudio.UI.ViewModels } } + //Copy new updater utility to app path. + File.Copy(Path.Combine(_newPackageTempFolder, "Tango.MachineStudio.Updater.exe"), Path.Combine(_appPath, "Tango.MachineStudio.Updater.exe"), true); + TangoIOC.Default.GetInstance<MainViewVM>().DisableCheckForUpdates = true; Status = UpdateStatus.UpdateCompleted; } |
