aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2019-09-08 14:56:38 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2019-09-08 14:56:38 +0300
commit333a1e44ac878c6de96bc398e0fa49d3adabc4c1 (patch)
treef1f10bd187877c87fbfa22976038940fd8710248 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
parenta8945386c7a9b5e18f02e5136ee5fa8f71b164b0 (diff)
downloadTango-333a1e44ac878c6de96bc398e0fa49d3adabc4c1.tar.gz
Tango-333a1e44ac878c6de96bc398e0fa49d3adabc4c1.zip
Refactored RML module CCT association.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CctModel.cs16
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs106
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml2
4 files changed, 110 insertions, 15 deletions
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..cb79dd043 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,21 @@ namespace Tango.MachineStudio.RML.ViewModels
ActiveRML.LastUpdated = DateTime.UtcNow;
+ if (SelectedCCT != null)
+ {
+ if (SelectedCCT.IsNew)
+ {
+ Cct cct = new Cct();
+ cct.FileName = SelectedCCT.FileName;
+ cct.Data = SelectedCCT.Data;
+ ActiveRML.Cct = cct;
+ }
+ else
+ {
+ ActiveRML.CctGuid = SelectedCCT.Guid;
+ }
+ }
+
await _active_context.SaveChangesAsync();
}
}
@@ -505,28 +550,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">