diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-07 14:42:44 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-07 14:42:44 +0300 |
| commit | 20b54cfc2b40bb69d1d6558c7fac6cc412c98da0 (patch) | |
| tree | 5428e4e0428e0f9334bc76202d8a88005959e830 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML | |
| parent | 0b40fe3742d90cdb7a4abab88207d0552dd4e3a7 (diff) | |
| download | Tango-20b54cfc2b40bb69d1d6558c7fac6cc412c98da0.tar.gz Tango-20b54cfc2b40bb69d1d6558c7fac6cc412c98da0.zip | |
Implemented RML import/export.
Fixed issue with MS in 1920x1080.
Added IP Address & Up Time to PPC.
Added ExternalBridge Icon IsInSession Indication.
Fixed issue with ExternalBridgeService disconnection.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML')
2 files changed, 139 insertions, 28 deletions
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 a76799881..ee21b9ac3 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 @@ -181,6 +181,10 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand CloneRmlCommand { get; set; } + public RelayCommand ExportRMLFileCommand { get; set; } + + public RelayCommand ImportRMLFileCommand { get; set; } + public MainViewVM(INotificationProvider notificationProvider) { _notification = notificationProvider; @@ -199,6 +203,9 @@ namespace Tango.MachineStudio.RML.ViewModels ImportForwardDataCommand = new RelayCommand(ImportCCTData, () => ActiveRML != null && IsFree); ExportForwardDataCommand = new RelayCommand(ExportCCTData, () => ActiveRML != null && SelectedCCT != null && IsFree); + + ExportRMLFileCommand = new RelayCommand(ExportRmlFile, () => SelectedRML != null && IsFree); + ImportRMLFileCommand = new RelayCommand(ImportRmlFile, () => IsFree); } public override void OnApplicationReady() @@ -769,5 +776,89 @@ namespace Tango.MachineStudio.RML.ViewModels } #endregion + + #region RML Import / Export + + private async void ImportRmlFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Import Thread Files"; + dlg.Filter = "Twine Thread Files|*.rml"; + dlg.Multiselect = true; + + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Importing thread files...")) + { + try + { + IsFree = false; + + LogManager.Log($"Importing thread files..."); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + foreach (var file in dlg.FileNames) + { + var json = File.ReadAllText(file); + var rmlFile = await Rml.FromRmlFile(db, json); + + db.Rmls.Add(rmlFile); + } + + await db.SaveChangesAsync(); + } + + IsFree = true; + + _notification.ShowInfo($"Threads imported successfully."); + + LoadRmls(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing thread file."); + _notification.ShowError($"An error occurred while trying to import the selected thread file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + + private async void ExportRmlFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Export Thread File"; + dlg.Filter = "Twine Thread Files|*.rml"; + dlg.DefaultExt = ".rml"; + dlg.FileName = SelectedRML.Name; + + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Exporting Thread '{SelectedRML.Name}'...")) + { + try + { + LogManager.Log($"Exporting Thread file {SelectedRML.Name}"); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var rmlJsonFile = await SelectedRML.ToRmlFile(db); + File.WriteAllText(dlg.FileName, rmlJsonFile); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting Thread file."); + _notification.ShowError($"An error occurred while trying to export thread '{SelectedRML.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml index fdfc00ba6..288f00a3d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml @@ -19,38 +19,58 @@ </UserControl.Resources> <Grid> - <DockPanel Margin="100" MaxWidth="1200"> + <DockPanel Margin="100 100 100 50" MaxWidth="1200"> <Grid DockPanel.Dock="Top"> <Image Source="../Images/threads.png" Width="300" Margin="10" /> </Grid> <Grid DockPanel.Dock="Bottom"> - <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 0"> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource RedBrush300}" BorderBrush="{StaticResource RedBrush300}" Command="{Binding RemoveRmlCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock> + <StackPanel> + <Grid> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 0"> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource RedBrush300}" BorderBrush="{StaticResource RedBrush300}" Command="{Binding RemoveRmlCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock> + </StackPanel> + </Button> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource OrangeBrush300}" BorderBrush="{StaticResource OrangeBrush300}" Command="{Binding CloneRmlCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentCopy" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">DUPLICATE</TextBlock> + </StackPanel> + </Button> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource GreenBrush300}" BorderBrush="{StaticResource GreenBrush300}" Command="{Binding AddRmlCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">NEW MEDIA</TextBlock> + </StackPanel> + </Button> </StackPanel> - </Button> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource OrangeBrush300}" BorderBrush="{StaticResource OrangeBrush300}" Command="{Binding CloneRmlCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="ContentCopy" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">DUPLICATE</TextBlock> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" /> + <TextBlock Margin="10 0 0 0" FontSize="18">EDIT</TextBlock> + </StackPanel> + </Button> </StackPanel> - </Button> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource GreenBrush300}" BorderBrush="{StaticResource GreenBrush300}" Command="{Binding AddRmlCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">NEW MEDIA</TextBlock> - </StackPanel> - </Button> - </StackPanel> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> - <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" /> - <TextBlock Margin="10 0 0 0" FontSize="18">EDIT</TextBlock> - </StackPanel> - </Button> + </Grid> + + <StackPanel Orientation="Horizontal" Margin="0 40 0 0"> + <Button Command="{Binding ImportRMLFileCommand}" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" Style="{StaticResource emptyButton}" Cursor="Hand"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="FileImport" VerticalAlignment="Center" Width="30" Height="30" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Import Thread File</TextBlock> + </StackPanel> + </Button> + + <Button Margin="30 0 0 0" Command="{Binding ExportRMLFileCommand}" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" Style="{StaticResource emptyButton}" Cursor="Hand"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="FileExport" VerticalAlignment="Center" Width="30" Height="30" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Export Thread File</TextBlock> + </StackPanel> + </Button> + </StackPanel> </StackPanel> </Grid> <Grid> @@ -63,11 +83,11 @@ </Style> </DataGrid.CellStyle> <DataGrid.Columns> - <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="Auto" /> + <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="140" /> <DataGridTextColumn Header="MANUFACTURER" Binding="{Binding Manufacturer}" Width="Auto" /> <DataGridTextColumn Header="MATERIAL" Binding="{Binding MediaMaterial.Name}" Width="Auto" /> <DataGridTextColumn Header="PURPOSE" Binding="{Binding MediaPurpose.Name}" Width="Auto" /> - <DataGridTextColumn Header="CCT" Binding="{Binding Cct.FileName}" Width="Auto" /> + <DataGridTextColumn Header="CCT" Binding="{Binding Cct.FileName}" Width="110" /> <DataGridTextColumn Header="CCT VER" Binding="{Binding ColorConversionVersion}" Width="70" /> <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> <DataGridTemplateColumn Header="LIQUID FACTORS" Width="1*"> |
