diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-09-09 11:21:19 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-09-09 11:21:19 +0300 |
| commit | 679ebf3c9ecb0271b765df122168d45be8a4a7cb (patch) | |
| tree | f31dd6765645d5afca5729adcd61b5b3c4a1b84c /Software/Visual_Studio/MachineStudio | |
| parent | 96e602f99fd9989b6161de89fd37fd9d7ac65d19 (diff) | |
| parent | d2c6293957afc55bede9f00db65a50ac0f1b2bf4 (diff) | |
| download | Tango-679ebf3c9ecb0271b765df122168d45be8a4a7cb.tar.gz Tango-679ebf3c9ecb0271b765df122168d45be8a4a7cb.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
12 files changed, 305 insertions, 76 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Models/CctModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Models/CctModel.cs new file mode 100644 index 000000000..bb5525ffb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Models/CctModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.ColorLab.Models +{ + public class CctModel + { + public String Guid { get; set; } + public String FileName { get; set; } + public bool IsNew { get; set; } + public byte[] Data { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj index 367657cdc..ef01ae5f9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj @@ -73,6 +73,7 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="ColorLabModuleSettings.cs" /> + <Compile Include="Models\CctModel.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\CalibrationDataPointVM.cs" /> <Compile Include="ViewModels\CalibrationDataViewVM.cs" /> @@ -196,7 +197,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file 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 71929b72b..a521127e1 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 @@ -17,6 +17,7 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.ColorConversion; using Tango.Core.Commands; +using Tango.MachineStudio.ColorLab.Models; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Controls; using Tango.MachineStudio.Common.Notifications; @@ -25,6 +26,7 @@ using Tango.PMR.ColorLab; using Tango.Settings; using Tango.SharedUI; using Tango.SharedUI.Controls; +using System.Data.Entity; namespace Tango.MachineStudio.ColorLab.ViewModels { @@ -32,7 +34,6 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { private ObservablesContext _dbContext; private INotificationProvider _notification; - private bool _isNewCCT; private bool _prevent_inverse_conversion; #region Properties @@ -183,16 +184,40 @@ namespace Tango.MachineStudio.ColorLab.ViewModels set { _targetColor = value; RaisePropertyChangedAuto(); } } - private Cct _cct; - /// <summary> - /// Gets or sets the CCT. - /// </summary> - public Cct CCT + private ObservableCollection<CctModel> _ccts; + public ObservableCollection<CctModel> CCTS + { + get { return _ccts; } + set + { + _ccts = value; + RaisePropertyChangedAuto(); + } + } + + private CctModel _selectedCCT; + public CctModel SelectedCCT { - get { return _cct; } - set { _cct = value; RaisePropertyChangedAuto(); } + get { return _selectedCCT; } + set + { + _selectedCCT = value; + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + OnSelectedCCTChanged(); + } } + //private Cct _cct; + ///// <summary> + ///// Gets or sets the CCT. + ///// </summary> + //public Cct CCT + //{ + // get { return _cct; } + // set { _cct = value; RaisePropertyChangedAuto(); } + //} + private int _deltaChroma; /// <summary> /// Gets or sets the delta chroma. @@ -265,14 +290,14 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { _notification = notification; - CCT = new Cct(); + // CCT = new Cct(); SourceColor = new RgbVM(); SourceColor.ColorChanged += SourceColor_ColorChanged; ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null && IsFree); - ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && CCT != null && CCT.FileName != null && IsFree); + ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && SelectedCCT != null && IsFree); SaveCommand = new RelayCommand(Save, () => SelectedRML != null && IsFree); } @@ -299,6 +324,15 @@ namespace Tango.MachineStudio.ColorLab.ViewModels Machines = _dbContext.Machines.ToObservableCollection(); ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection(); Rmls = _dbContext.Rmls.ToObservableCollection(); + + CCTS = _dbContext.Ccts.Select(x => new CctModel() + { + Guid = x.Guid, + FileName = x.FileName, + + }).ToObservableCollection(); + + CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); }); var settings = SettingsManager.Default.GetOrCreate<ColorLabModuleSettings>(); @@ -331,13 +365,13 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { try { - if (LiquidsCalibrationData == null || CCT.Data == null) return; + if (LiquidsCalibrationData == null || SelectedCCT == null || SelectedCCT.Data == null) return; ConversionInput input = new ConversionInput(); input.ColorSpace = SourceColor.IsLab ? PMR.ColorLab.ColorSpace.Lab : PMR.ColorLab.ColorSpace.Rgb; input.DeltaChroma = DeltaChroma; input.DeltaL = DeltaL; - input.ForwardData = ByteString.CopyFrom(CCT.Data); + input.ForwardData = ByteString.CopyFrom(SelectedCCT.Data); input.InputCoordinates = new InputCoordinates(); input.InputCoordinates.Red = (int)SourceColor.Red; @@ -452,17 +486,57 @@ namespace Tango.MachineStudio.ColorLab.ViewModels String file = GetCCTFileOpen(); if (file != null) { - CCT.FileName = Path.GetFileName(file); - CCT.Data = File.ReadAllBytes(file); + CctModel cctModel = new CctModel(); + cctModel.Guid = Guid.NewGuid().ToString(); + cctModel.IsNew = true; + + cctModel.FileName = Path.GetFileName(file); + cctModel.Data = File.ReadAllBytes(file); + + CCTS.Insert(0, cctModel); + SelectedCCT = cctModel; } } private void ExportForwardData() { - String file = GetCCTFileSave(CCT.FileName); - if (file != null) + + if (SelectedCCT != null) { - File.WriteAllBytes(file, CCT.Data); + String file = GetCCTFileSave(SelectedCCT.FileName); + if (file != null) + { + using (_notification.PushTaskItem("Exporting CCT file...")) + { + try + { + IsFree = false; + + if (SelectedCCT.IsNew) + { + File.WriteAllBytes(file, SelectedCCT.Data); + } + else + { + var cct = _dbContext.Ccts.SingleOrDefault(x => x.Guid == SelectedCCT.Guid); + + if (cct != null) + { + File.WriteAllBytes(file, cct.Data); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting CCT file."); + _notification.ShowError($"An error occurred while trying to export the CCT file.\n{ex.Message}"); + } + finally + { + IsFree = true; + } + } + } } } @@ -497,6 +571,25 @@ namespace Tango.MachineStudio.ColorLab.ViewModels #endregion #region Liquid Volumes + private async void OnSelectedCCTChanged() + { + if (SelectedCCT != null && !SelectedCCT.IsNew) + { + using (_notification.PushTaskItem("Loading CCT data...")) + { + IsFree = false; + + var cct = await _dbContext.Ccts.SingleOrDefaultAsync(x => x.Guid == SelectedCCT.Guid); + + if (cct != null) + { + SelectedCCT.Data = cct.Data; + } + + IsFree = true; + } + } + } private void OnSelectedMachineChanged() { @@ -551,7 +644,7 @@ namespace Tango.MachineStudio.ColorLab.ViewModels input.ColorSpace = PMR.ColorLab.ColorSpace.Volume; input.DeltaChroma = DeltaChroma; input.DeltaL = DeltaL; - input.ForwardData = ByteString.CopyFrom(CCT.Data); + input.ForwardData = ByteString.CopyFrom(SelectedCCT.Data); input.InputCoordinates = new InputCoordinates(); input.ThreadL = SelectedRML.WhitePointL; @@ -636,12 +729,33 @@ namespace Tango.MachineStudio.ColorLab.ViewModels _dbContext.Adapter.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid); } - _selectedRML = new RmlBuilder(_dbContext) + var builder = new RmlBuilder(_dbContext) .Set(_selectedRML.Guid) .WithActiveParametersGroup() .WithCAT(SelectedMachine.Guid) - .WithCCT() - .WithLiquidFactors().Build(); + .WithLiquidFactors(); + + if (IsHosted) + { + builder.WithCCT(); + } + + _selectedRML = builder.Build(); + + if (IsHosted) + { + if(SelectedRML.Cct != null){ + + SelectedCCT = new CctModel() + { + Data = SelectedRML.Cct.Data + }; + } + } + else + { + SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == SelectedRML.CctGuid); + } LiquidVolumes = SelectedMachine.Configuration.GetSupportedIdsPacks(_selectedRML).Select(x => new LiquidVolumeVM() { @@ -685,16 +799,6 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } } - _isNewCCT = false; - CCT = SelectedRML.Cct; - - if (CCT == null) - { - CCT = new Cct(); - SelectedRML.Cct = CCT; - _isNewCCT = true; - } - var settings = SettingsManager.Default.GetOrCreate<ColorLabModuleSettings>(); settings.LastMachineSerialNumber = SelectedMachine.SerialNumber; settings.LastRmlGuid = SelectedRML.Guid; @@ -750,11 +854,6 @@ namespace Tango.MachineStudio.ColorLab.ViewModels public async Task SaveChanges() { - if (_isNewCCT) - { - _dbContext.Ccts.Add(CCT); - } - foreach (var calDataVM in LiquidsCalibrationData) { var cat = calDataVM.IdsPack.LiquidType.Cats.FirstOrDefault(x => x.Machine == SelectedMachine && x.Rml == SelectedRML); @@ -777,6 +876,23 @@ namespace Tango.MachineStudio.ColorLab.ViewModels cat.PutCalibrationData(calData); } + if (SelectedCCT != null && !IsHosted) + { + if (SelectedCCT.IsNew) + { + Cct cct = new Cct(); + cct.Guid = SelectedCCT.Guid; + cct.FileName = SelectedCCT.FileName; + cct.Data = SelectedCCT.Data; + SelectedRML.Cct = cct; + SelectedCCT.IsNew = false; + } + else + { + SelectedRML.CctGuid = SelectedCCT.Guid; + } + } + await _dbContext.SaveChangesAsync(); InvalidateLiquidFactorsCalibrationData(); 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 49966bad2..37f5f70be 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 @@ -148,8 +148,7 @@ <materialDesign:PackIcon Kind="ArrowLeftBoldHexagonOutline" VerticalAlignment="Center" Width="40" Height="40" /> <Image Source="../Images/data-table.png" Height="80" Opacity="0.8"></Image> <StackPanel VerticalAlignment="Center" Width="300" Margin="10 0 0 0"> - - <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding CCT.FileName}" HorizontalContentAlignment="Center"></TextBox> + <ComboBox materialDesign:HintAssist.Hint="No CCT Defined" Margin="0 5 0 0" HorizontalContentAlignment="Center" ItemsSource="{Binding CCTS}" SelectedItem="{Binding SelectedCCT}" DisplayMemberPath="FileName" Style="{StaticResource TransparentComboBoxStyle}"></ComboBox> <UniformGrid Columns="2" Margin="0 5 0 0" HorizontalAlignment="Right"> <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Command="{Binding ImportForwardDataCommand}"> <StackPanel Orientation="Horizontal" Margin="0 0 20 0"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs index 801aa0a72..628613fea 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs @@ -125,6 +125,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels private void GenerateReport() { + _notification.ShowError($"Error generating HW version comparison report.\n"); + SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "Save Report"; dlg.Filter = "CSV Files|*.csv"; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/ComparisonWizardView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/ComparisonWizardView.xaml index af18d0003..d8a125e02 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/ComparisonWizardView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/ComparisonWizardView.xaml @@ -8,21 +8,21 @@ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.HardwareDesigner.ViewModels" mc:Ignorable="d" - d:DesignHeight="800" d:DesignWidth="800" Height="700" Width="1100"> + d:DesignHeight="800" d:DesignWidth="800" Height="700" Width="1100" Foreground="{StaticResource Dialog.Foreground}" Background="{StaticResource Dialog.Background}"> <UserControl.Resources> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" /> <Style TargetType="TextBlock" x:Key="DifferenceTextBoxStyle"> <Style.Triggers> <DataTrigger Binding="{Binding IsDifferent}" Value="True" > - <Setter Property="Foreground" Value="red"/> + <Setter Property="Foreground" Value="{StaticResource RedBrush100}"/> </DataTrigger> </Style.Triggers> </Style> <Style TargetType="TextBlock" x:Key="CollectionHasDifferenceTextBox"> <Style.Triggers> <DataTrigger Binding="{Binding HasDifferences}" Value="True" > - <Setter Property="Foreground" Value="red"/> + <Setter Property="Foreground" Value="{StaticResource RedBrush100}"/> </DataTrigger> </Style.Triggers> </Style> @@ -40,25 +40,23 @@ <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <UniformGrid Columns="3" Grid.Row="0" > - <!--<materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" Foreground="Silver" VerticalAlignment="Center" Margin="5,5,0,0"/>--> <ComboBox Margin="10 0 0 0" HorizontalAlignment="Left" IsEnabled="{Binding IsFree}" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion1}" Width="300" FontSize="16" FontWeight="Bold" materialDesign:HintAssist.Hint="Hardware Version 1"> <ComboBox.ItemTemplate> <DataTemplate> - <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14" Text="{Binding Version}"></Run></TextBlock> + <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource Dialog.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource Dialog.Foreground}" FontSize="14" Text="{Binding Version}"></Run></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - <TextBlock Text="Comparison Wizard" Foreground="Silver" FontStyle="Italic" FontWeight="Bold" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock> + <TextBlock Text="Comparison Wizard" Foreground="{StaticResource LightGrayBrush}" FontStyle="Italic" FontWeight="Bold" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock> <ComboBox IsEnabled="{Binding IsFree}" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion2}" Width="300" FontSize="16" FontWeight="Bold" materialDesign:HintAssist.Hint="Hardware Version 2"> <ComboBox.ItemTemplate> <DataTemplate> - <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14" Text="{Binding Version}"></Run></TextBlock> + <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource Dialog.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource Dialog.Foreground}" FontSize="14" Text="{Binding Version}"></Run></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - <!--<Button Command="{Binding CompareCommand}" FontSize="16" Width="100" HorizontalAlignment="Right">Comp</Button>--> </UniformGrid> <StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Center" Margin="10 0 0 0" HorizontalAlignment="Left"> <CheckBox Name="cbShowOnlyDifference" IsChecked="{Binding IsShowDifference}" VerticalAlignment="Center"></CheckBox> @@ -79,7 +77,7 @@ <ColumnDefinition Width="500*"/> </Grid.ColumnDefinitions> <Border Name="LeftB" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> - <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource WhiteBackgroundBrush}" Padding="20 10"> + <materialDesign:Card Margin="5,10,5,0" Padding="20 10"> <StackPanel Orientation="Vertical"> <ItemsControl Margin="10,0,0,0" Name="ComponentListLeft" ItemsSource="{Binding Components}" HorizontalContentAlignment="Stretch"> <ItemsControl.ItemTemplate> @@ -145,7 +143,7 @@ </Style.Triggers> </Style> </Border.Style> - <TextBlock Text="None" Foreground="Red" FontWeight="SemiBold" HorizontalAlignment="Center" FontSize="16" VerticalAlignment="Center"/> + <TextBlock Text="None" Foreground="{StaticResource RedBrush100}" FontWeight="SemiBold" HorizontalAlignment="Center" FontSize="16" VerticalAlignment="Center"/> </Border> </Grid> </StackPanel> @@ -176,7 +174,7 @@ </materialDesign:Card> </Border> <Border Name="RightB" Grid.Column="1" Margin="10,0,0,0"> - <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource WhiteBackgroundBrush}" Padding="20 10"> + <materialDesign:Card Margin="5,10,5,0" Padding="20 10"> <StackPanel Orientation="Vertical"> <ItemsControl Margin="10,0,0,0" Name="ComponentListRight" ItemsSource="{Binding Components}" HorizontalContentAlignment="Stretch"> <ItemsControl.ItemTemplate> @@ -242,7 +240,7 @@ </Style.Triggers> </Style> </Border.Style> - <TextBlock Text="None" FontWeight="SemiBold" HorizontalAlignment="Center" FontSize="16" VerticalAlignment="Center" Foreground="Red"/> + <TextBlock Text="None" FontWeight="SemiBold" HorizontalAlignment="Center" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource RedBrush100}"/> </Border> </Grid> </StackPanel> @@ -307,7 +305,7 @@ </Grid> </Grid> - <Border CornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F6F6F6" Width="700" Height="350"> + <Border CornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Background="{StaticResource Transparent200}" Width="700" Height="350"> <Border.Style> <Style TargetType="Border"> <Setter Property="Visibility" Value="Hidden"></Setter> @@ -322,10 +320,10 @@ <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="Gray">Select two hardware versions to display a comparison report</TextBlock> </Border> <Grid HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Visibility="{Binding IsRunning,Converter={StaticResource BooleanToVisibilityConverter}}" - Background="#93FFFFFF"> + Background="{StaticResource TransparentBackgroundBrush500}"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> <mahapps:ProgressRing Foreground="#007ACC" Width="80" Height="80"></mahapps:ProgressRing> - <TextBlock Text="Loading..." FontStyle="Italic" Margin="10 0 0 0" FontSize="30" VerticalAlignment="Center" Foreground="Silver"></TextBlock> + <TextBlock Text="Loading..." FontStyle="Italic" Margin="10 0 0 0" FontSize="30" VerticalAlignment="Center" Foreground="{StaticResource HomePageForeground}"></TextBlock> </StackPanel> </Grid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CctModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CctModel.cs new file mode 100644 index 000000000..9079b8fc6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CctModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.RML.Models +{ + public class CctModel + { + public String Guid { get; set; } + public String FileName { get; set; } + public bool IsNew { get; set; } + public byte[] Data { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 6b113be5f..fc05f3c16 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -73,6 +73,7 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="Contracts\IMainView.cs" /> + <Compile Include="Models\CctModel.cs" /> <Compile Include="RMLModule.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 7218ef5ea..aa84fb137 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -17,6 +17,7 @@ using Tango.MachineStudio.ColorLab.ViewModels; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.RML.Contracts; +using Tango.MachineStudio.RML.Models; using Tango.MachineStudio.RML.Views; using Tango.PMR.ColorLab; @@ -120,6 +121,20 @@ namespace Tango.MachineStudio.RML.ViewModels set { _activeProcessParametersTableView = value; RaisePropertyChangedAuto(); } } + private ObservableCollection<CctModel> _ccts; + public ObservableCollection<CctModel> CCTS + { + get { return _ccts; } + set { _ccts = value; RaisePropertyChangedAuto(); } + } + + private CctModel _selectedCCT; + public CctModel SelectedCCT + { + get { return _selectedCCT; } + set { _selectedCCT = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + /// <summary> /// Gets or sets the manage RML command. /// </summary> @@ -170,9 +185,9 @@ namespace Tango.MachineStudio.RML.ViewModels CreateCalibrationDataExcelTemplateCommand = new RelayCommand(CreateCalibrationDataExcelTemplate); SaveCommand = new RelayCommand(Save, () => IsFree); - ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => ActiveRML != null && IsFree); + ImportForwardDataCommand = new RelayCommand(ImportCCTData, () => ActiveRML != null && IsFree); - ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => ActiveRML != null && ActiveRML.Cct != null && IsFree); + ExportForwardDataCommand = new RelayCommand(ExportCCTData, () => ActiveRML != null && SelectedCCT != null && IsFree); } public override void OnApplicationReady() @@ -201,6 +216,16 @@ namespace Tango.MachineStudio.RML.ViewModels _active_context = ObservablesContext.CreateDefault(); + CCTS = _active_context.Ccts + .Select(x => new CctModel() + { + Guid = x.Guid, + FileName = x.FileName, + + }).ToObservableCollection(); + + CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); + LoadRmlProperties(); ActiveRML = await new RmlBuilder(_active_context) @@ -210,6 +235,11 @@ namespace Tango.MachineStudio.RML.ViewModels .WithCCT() .BuildAsync(); + if (ActiveRML.Cct != null) + { + SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid); + } + if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) { if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) @@ -483,6 +513,23 @@ namespace Tango.MachineStudio.RML.ViewModels ActiveRML.LastUpdated = DateTime.UtcNow; + if (SelectedCCT != null) + { + if (SelectedCCT.IsNew) + { + Cct cct = new Cct(); + cct.Guid = SelectedCCT.Guid; + cct.FileName = SelectedCCT.FileName; + cct.Data = SelectedCCT.Data; + ActiveRML.Cct = cct; + SelectedCCT.IsNew = false; + } + else + { + ActiveRML.CctGuid = SelectedCCT.Guid; + } + } + await _active_context.SaveChangesAsync(); } } @@ -505,28 +552,61 @@ namespace Tango.MachineStudio.RML.ViewModels #region Import / Export Color Conversion Data - private void ImportForwardData() + private void ImportCCTData() { String file = GetCCTFileOpen(); if (file != null) { - if (ActiveRML.Cct == null) - { - Cct cct = new Cct(); - ActiveRML.Cct = cct; - } + CctModel cctModel = new CctModel(); + cctModel.Guid = Guid.NewGuid().ToString(); + cctModel.IsNew = true; - ActiveRML.Cct.FileName = Path.GetFileName(file); - ActiveRML.Cct.Data = File.ReadAllBytes(file); + cctModel.FileName = Path.GetFileName(file); + cctModel.Data = File.ReadAllBytes(file); + + CCTS.Insert(0, cctModel); + SelectedCCT = cctModel; } } - private void ExportForwardData() + private void ExportCCTData() { - String file = GetCCTFileSave(ActiveRML.Cct.FileName); - if (file != null) + if (SelectedCCT != null) { - File.WriteAllBytes(file, ActiveRML.Cct.Data); + String file = GetCCTFileSave(ActiveRML.Cct.FileName); + if (file != null) + { + using (_notification.PushTaskItem("Exporting CCT file...")) + { + try + { + IsFree = false; + + if (SelectedCCT.IsNew) + { + File.WriteAllBytes(file, SelectedCCT.Data); + } + else + { + var cct = _active_context.Ccts.SingleOrDefault(x => x.Guid == SelectedCCT.Guid); + + if (cct != null) + { + File.WriteAllBytes(file, cct.Data); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting CCT file."); + _notification.ShowError($"An error occurred while trying to export the CCT file.\n{ex.Message}"); + } + finally + { + IsFree = true; + } + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index 333cf9394..fa51a6bf5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -222,7 +222,7 @@ <Image Source="../Images/data-table.png" Height="80" Opacity="0.8"></Image> <StackPanel VerticalAlignment="Center" Width="300" Margin="10 0 0 0"> - <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding ActiveRML.Cct.FileName}" HorizontalContentAlignment="Center"></TextBox> + <ComboBox materialDesign:HintAssist.Hint="No CCT Defined" Margin="0 5 0 0" HorizontalContentAlignment="Center" ItemsSource="{Binding CCTS}" SelectedItem="{Binding SelectedCCT}" DisplayMemberPath="FileName" Style="{StaticResource TransparentComboBoxStyle}"></ComboBox> <UniformGrid Columns="2" Margin="0 5 0 0" HorizontalAlignment="Right"> <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Command="{Binding ImportForwardDataCommand}"> <StackPanel Orientation="Horizontal" Margin="0 0 20 0"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 7c56115e3..52a861930 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -430,7 +430,7 @@ namespace Tango.MachineStudio.UI.Notifications /// <param name="message">The message.</param> public void ShowError(string message) { - ShowMessageBox(PackIconKind.AlertOctagon, Brushes.Red, message, false); + ShowMessageBox(PackIconKind.AlertOctagon, (SolidColorBrush)Application.Current.Resources["RedBrush100"], message, false); } /// <summary> @@ -439,7 +439,7 @@ namespace Tango.MachineStudio.UI.Notifications /// <param name="message">The message.</param> public void ShowInfo(string message) { - ShowMessageBox(PackIconKind.CommentAlertOutline, Brushes.Black, message, false); + ShowMessageBox(PackIconKind.CommentAlertOutline, (SolidColorBrush)Application.Current.Resources["Dialog.Foreground"], message, false); } /// <summary> @@ -449,7 +449,7 @@ namespace Tango.MachineStudio.UI.Notifications /// <returns></returns> public bool ShowQuestion(string message) { - return ShowMessageBox(PackIconKind.CommentQuestionOutline, Brushes.Black, message, true).Value; + return ShowMessageBox(PackIconKind.CommentQuestionOutline, (SolidColorBrush)Application.Current.Resources["Dialog.Foreground"], message, true).Value; } /// <summary> @@ -458,7 +458,7 @@ namespace Tango.MachineStudio.UI.Notifications /// <param name="message">The message.</param> public void ShowWarning(string message) { - ShowMessageBox(PackIconKind.AlertOutline, Brushes.DarkOrange, message, false); + ShowMessageBox(PackIconKind.AlertOutline, (SolidColorBrush)Application.Current.Resources["OrangeUploadBrush"], message, false); } /// <summary> @@ -468,7 +468,7 @@ namespace Tango.MachineStudio.UI.Notifications /// <returns></returns> public bool ShowErrorQuestion(string message) { - return ShowMessageBox(PackIconKind.CommentAlertOutline, Brushes.DarkOrange, message, true).Value; + return ShowMessageBox(PackIconKind.CommentAlertOutline, (SolidColorBrush)Application.Current.Resources["OrangeUploadBrush"], message, true).Value; } /// <summary> @@ -568,7 +568,7 @@ namespace Tango.MachineStudio.UI.Notifications Owner = Application.Current.MainWindow, Message = message, IconKind = PackIconKind.Pencil, - IconColor = Brushes.DimGray, + IconColor = (SolidColorBrush)Application.Current.Resources["DimGrayBrush"], Hint = hint, Response = defaultResponse }; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml index e037e3630..988e3c21f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml @@ -30,7 +30,7 @@ </StackPanel> <Grid> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 30 0 0"> - <materialDesign:PackIcon Kind="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconKind}" VerticalAlignment="Top" Width="50" Height="50" Foreground="{StaticResource Dialog.Foreground}" /> + <materialDesign:PackIcon Kind="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconKind}" VerticalAlignment="Top" Width="50" Height="50" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconColor}" /> <TextBlock Padding="0 10 0 0" TextWrapping="Wrap" Margin="10 0 0 0" VerticalAlignment="Top" FontSize="14" Text="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=Message}" Width="400" Foreground="{StaticResource Dialog.Foreground}"></TextBlock> </StackPanel> </Grid> |
