diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-02 16:59:05 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-02 16:59:05 +0300 |
| commit | ebd971a77a5fdabdf4040f07ac0e63e687abb8aa (patch) | |
| tree | f3a8cee479a4a43ecbe1f9712a18a3e759aa9982 /Software/Visual_Studio/MachineStudio | |
| parent | b8a170ddc60d2bcb06db9f88680ae632c7d646d8 (diff) | |
| download | Tango-ebd971a77a5fdabdf4040f07ac0e63e687abb8aa.tar.gz Tango-ebd971a77a5fdabdf4040f07ac0e63e687abb8aa.zip | |
Another fix for SetLiquidVolumes.
Changed JobFile PMR.
Implemented new JobFile with Liquid Volume awareness.
Implemented Import/Export jobs on research module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
7 files changed, 169 insertions, 19 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f57f83d7e..012ed8d0d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -52,6 +52,15 @@ <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> </Reference> + <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath> + </Reference> + <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> + </Reference> + <Reference Include="Microsoft.WindowsAPICodePack.ShellExtensions, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> @@ -196,8 +205,12 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> - <None Include="app.config" /> - <None Include="packages.config" /> + <None Include="app.config"> + <SubType>Designer</SubType> + </None> + <None Include="packages.config"> + <SubType>Designer</SubType> + </None> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> @@ -373,7 +386,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 2d04866d8..27d43bd20 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -48,6 +48,8 @@ using Tango.MachineStudio.Common.Navigation; using System.Diagnostics; using Tango.Core.ExtensionMethods; using Tango.ColorConversion; +using Tango.PMR.Exports; +using Microsoft.WindowsAPICodePack.Dialogs; namespace Tango.MachineStudio.Developer.ViewModels { @@ -725,6 +727,16 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> public RelayCommand ResetProcessParametersCommand { get; set; } + /// <summary> + /// Gets or sets the import job file command. + /// </summary> + public RelayCommand ImportJobFileCommand { get; set; } + + /// <summary> + /// Gets or sets the export job file command. + /// </summary> + public RelayCommand ExportJobFileCommand { get; set; } + #endregion #region Constructors @@ -786,6 +798,8 @@ namespace Tango.MachineStudio.Developer.ViewModels DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile, () => CanWork); ReloadMachinesCommand = new RelayCommand(() => LoadMachine(), () => CanWork && SelectedMachine != null); ResetProcessParametersCommand = new RelayCommand(ResetProcessParameters, () => CanWork && MachineOperator != null); + ImportJobFileCommand = new RelayCommand(ImportJobFile, () => SelectedMachine != null && CanWork); + ExportJobFileCommand = new RelayCommand(ExportJobFile, () => SelectedMachine != null && SelectedMachineJob != null && CanWork); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; @@ -2488,6 +2502,112 @@ namespace Tango.MachineStudio.Developer.ViewModels #endregion + #region Job Import/Export + + private async void ExportJobFile() + { + if (SelectedJobs != null && SelectedJobs.Count > 1) + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select a folder to place all job files."; + dlg.IsFolderPicker = true; + + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + foreach (var job in SelectedJobs) + { + using (_notification.PushTaskItem($"Exporting job '{job.Name}'...")) + { + try + { + LogManager.Log($"Exporting job file {job.Name}"); + + var jobFile = await job.ToJobFile(); + File.WriteAllBytes(Path.Combine(dlg.FileName, job.Name + ".job"), jobFile.ToBytes()); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting job file."); + _notification.ShowError($"An error occurred while trying to export job '{job.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + } + else + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Export Job File"; + dlg.Filter = "Twine Job Files|*.job"; + dlg.DefaultExt = ".job"; + dlg.FileName = SelectedMachineJob.Name; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Exporting job '{SelectedMachineJob.Name}'...")) + { + try + { + LogManager.Log($"Exporting job file {SelectedMachineJob.Name}"); + + var jobFile = await SelectedMachineJob.ToJobFile(); + File.WriteAllBytes(dlg.FileName, jobFile.ToBytes()); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting job file."); + _notification.ShowError($"An error occurred while trying to export job '{SelectedMachineJob.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + } + + private async void ImportJobFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Import Job File"; + dlg.Filter = "Twine Job Files|*.job"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Importing job files...")) + { + try + { + IsFree = false; + + LogManager.Log($"Importing job files..."); + + foreach (var file in dlg.FileNames) + { + var bytes = File.ReadAllBytes(file); + var jobFile = JobFile.Parser.ParseFrom(bytes); + var job = await Job.FromJobFile(jobFile, SelectedMachine.Guid, AuthenticationProvider.CurrentUser.Guid); + + _machineDbContext.Jobs.Add(job); + } + + await _machineDbContext.SaveChangesAsync(); + + IsFree = true; + + _notification.ShowInfo($"Jobs imported successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing job file."); + _notification.ShowError($"An error occurred while trying to import the selected job file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + + #endregion + #region Override Methods protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 70d5b6180..f8a10e7c4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -260,12 +260,27 @@ </Grid> </DockPanel> - <Button Command="{Binding ImportEmbroideryFileCommand}" Margin="20 0 0 -100" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" VerticalAlignment="Bottom" HorizontalAlignment="Left" Style="{StaticResource emptyButton}" Cursor="Hand"> - <StackPanel Orientation="Horizontal"> - <Image Source="../Images/sewing-machine.png" Width="32"></Image> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Import Embroidery File</TextBlock> - </StackPanel> - </Button> + <StackPanel Margin="20 0 0 -100" VerticalAlignment="Bottom" HorizontalAlignment="Left" Orientation="Horizontal"> + <Button Command="{Binding ImportJobFileCommand}" 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 Job File</TextBlock> + </StackPanel> + </Button> + + <Button Margin="30 0 0 0" Command="{Binding ExportJobFileCommand}" 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 Job File</TextBlock> + </StackPanel> + </Button> + <Button Margin="30 0 0 0" Command="{Binding ImportEmbroideryFileCommand}" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" Style="{StaticResource emptyButton}" Cursor="Hand"> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/sewing-machine.png" Width="32"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Import Embroidery File</TextBlock> + </StackPanel> + </Button> + </StackPanel> </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config index ff251eb7d..1fafd5ffd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config @@ -20,7 +20,7 @@ </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> @@ -28,27 +28,27 @@ </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> @@ -72,7 +72,7 @@ </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config index 999461d6a..85174f848 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config @@ -8,6 +8,8 @@ <package id="MahApps.Metro" version="1.5.0" targetFramework="net46" /> <package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" /> <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" /> + <package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net461" /> + <package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net461" /> <package id="System.Reactive" version="3.1.1" targetFramework="net46" /> <package id="System.Reactive.Core" version="3.1.1" targetFramework="net46" /> <package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net46" /> 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 719167679..fdfc00ba6 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 @@ -40,7 +40,7 @@ <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 RML</TextBlock> + <TextBlock Margin="5 0 0 0" FontSize="16">NEW MEDIA</TextBlock> </StackPanel> </Button> </StackPanel> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index b8ad73b04..59f92d6b9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -78,7 +78,7 @@ </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
