diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-14 18:16:11 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-14 18:16:11 +0300 |
| commit | dad69951c0338be70949e823b1b0c321c862d3b9 (patch) | |
| tree | 629b4127e26fba9a3b070613c1d31b32f01c54ab /Software | |
| parent | a9a2772e8159f65339d7c7405e988fe10d7589c8 (diff) | |
| download | Tango-dad69951c0338be70949e823b1b0c321c862d3b9.tar.gz Tango-dad69951c0338be70949e823b1b0c321c862d3b9.zip | |
Implemented Display & Export embroidery file to storage on PPC.
Diffstat (limited to 'Software')
16 files changed, 216 insertions, 10 deletions
diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle index 60fc89265..facd37772 100644 --- a/Software/Android_Studio/ColorCapture/app/build.gradle +++ b/Software/Android_Studio/ColorCapture/app/build.gradle @@ -23,7 +23,7 @@ android { buildTypes { debug { - buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://192.168.1.229:45457/api/\"" + buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://tcc.twine-srv.com/api/\"" buildConfigField "String", "WEB_SERVICE_APP_ID", "\"Tdf793i4ughsiduf8749509237885ehgfdlkghlT\"" } diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf Binary files differindex 997a03f9d..3f9ba04a4 100644 --- a/Software/DB/PPC/Tango.mdf +++ b/Software/DB/PPC/Tango.mdf diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf Binary files differindex 58b4d3b25..c0013d42f 100644 --- a/Software/DB/PPC/Tango_log.ldf +++ b/Software/DB/PPC/Tango_log.ldf diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf Binary files differindex 0dbf598dc..9d9b81a3d 100644 --- a/Software/DB/TCC/TCC.mdf +++ b/Software/DB/TCC/TCC.mdf diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf Binary files differindex f95b21cc9..8f059bbab 100644 --- a/Software/DB/TCC/TCC_log.ldf +++ b/Software/DB/TCC/TCC_log.ldf diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs new file mode 100644 index 000000000..fce5bedf6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobToEmbroideryImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Job job = value as Job; + + if (job != null && job.EmbroideryFileData != null) + { + try + { + return job.EmbroideryJpeg.ToBitmapSource(); + } + catch + { + return null; + } + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png Binary files differnew file mode 100644 index 000000000..f71bc2a70 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index b24313bbb..bbfef32fd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -172,6 +172,7 @@ <Compile Include="Converters\ColorSpaceToVisibilityConverter.cs" /> <Compile Include="Converters\JobProgressToPositionConverter.cs" /> <Compile Include="Converters\JobsCategoryToVisibilityConverter.cs" /> + <Compile Include="Converters\JobToEmbroideryImageConverter.cs" /> <Compile Include="Converters\JobToPieImageConverter.cs" /> <Compile Include="Converters\JobTypeToImageConverter.cs" /> <Compile Include="Dialogs\AdvancedColorCorrectionView.xaml.cs"> @@ -448,7 +449,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/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index edcc741e6..1e18fb14c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -34,6 +34,9 @@ using Tango.PPC.Jobs.AppButtons; using Tango.Core.Threading; using System.Diagnostics; using System.Runtime.ExceptionServices; +using Tango.Explorer; +using Tango.PPC.Storage; +using System.IO; namespace Tango.PPC.Jobs.ViewModels { @@ -306,6 +309,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand RepeatFineTuningCommand { get; set; } + /// <summary> + /// Gets or sets the export embroidery command. + /// </summary> + public RelayCommand ExportEmbroideryCommand { get; set; } + #endregion #region Constructors @@ -385,6 +393,7 @@ namespace Tango.PPC.Jobs.ViewModels RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); OpenTwineCatalogCommand = new RelayCommand<BrushStop>(OpenTwineCatalog); + ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); } #endregion @@ -1146,6 +1155,45 @@ namespace Tango.PPC.Jobs.ViewModels #endregion + #region Export Embroidery + + private async void ExportEmbroidery() + { + try + { + if (!StorageProvider.IsConnected) + { + await NotificationProvider.ShowError("No storage device connected."); + return; + } + + var result = await NavigationManager. + NavigateForResult<StorageModule, + Storage.Views.MainView, ExplorerFileItem, + Storage.Models.StorageNavigationRequest>( + new Storage.Models.StorageNavigationRequest() + { + Intent = Storage.Models.StorageNavigationIntent.SaveFile, + DefaultFileName = Job.Name + Path.GetExtension(Job.EmbroideryFileName), + Filter = Path.GetExtension(Job.EmbroideryFileName), + Title = "Export Embroidery File", + }); + + if (result != null) + { + File.WriteAllBytes(Path.HasExtension(result.Path) ? result.Path : result.Path + Path.GetExtension(Job.EmbroideryFileName), Job.EmbroideryFileData); + await NotificationProvider.ShowSuccess("Embroidery file exported successfully."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting embroidery file."); + await NotificationProvider.ShowError("An error occurred while trying to save the selected embroidery file."); + } + } + + #endregion + #region IPPC ViewModel Overrides /// <summary> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 530eae385..08d135e21 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -422,15 +422,18 @@ namespace Tango.PPC.Jobs.ViewModels vm.SelectedJobType = vm.SupportedJobTypes.First(); } - if (machine.SupportedJobTypes.Count != 1 || machine.SupportedColorSpaces.Count != 1) + if (twnFile == null) { - vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); - if (!vm.DialogResult) return; - } - else - { - vm.SelectedJobType = machine.SupportedJobTypes.First(); - vm.SelectedColorSpace = machine.SupportedColorSpaces.First(); + if (machine.SupportedJobTypes.Count != 1 || machine.SupportedColorSpaces.Count != 1) + { + vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); + if (!vm.DialogResult) return; + } + else + { + vm.SelectedJobType = machine.SupportedJobTypes.First(); + vm.SelectedColorSpace = machine.SupportedColorSpaces.First(); + } } settings.LastJobType = vm.SelectedJobType; @@ -498,6 +501,7 @@ namespace Tango.PPC.Jobs.ViewModels st.Red = stop.R; st.Green = stop.G; st.Blue = stop.B; + st.ColorSpaceGuid = job.ColorSpaceGuid; s.BrushStops.Add(st); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index aa04398f1..39a333a3d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -22,6 +22,7 @@ <UserControl.Resources> <localConverters:ColorSpaceToVisibilityConverter x:Key="ColorSpaceToVisibilityConverter" /> + <localConverters:JobToEmbroideryImageConverter x:Key="JobToEmbroideryImageConverter" /> <BitmapImage x:Key="Image_Out_Of_Gamut" UriSource="../Images/JobView/error.png" /> <BitmapImage x:Key="Image_Replace_Color" UriSource="../Images/JobView/replace-color.png" /> <BitmapImage x:Key="Image_Color_Picker" UriSource="../Images/JobView/color-picker.png" /> @@ -624,6 +625,26 @@ </Grid> </Border> + <Border Style="{StaticResource TangoTouchBorder}" Margin="0 20 0 0" Padding="0 0 0 50" Visibility="{Binding Job.EmbroideryFileData,Converter={StaticResource IsNullToVisibilityConverter}}"> + <StackPanel> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"> + <Image Source="../Images/embroidery.png" RenderOptions.BitmapScalingMode="Fant" Width="39" /> + <TextBlock FontWeight="Medium" Margin="20 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">Embroidery File</TextBlock> + </StackPanel> + + <StackPanel Style="{StaticResource Level2ContainerExtraMargin}"> + <DockPanel> + <Image Source="{Binding Job,Converter={StaticResource JobToEmbroideryImageConverter}}" Width="230" Stretch="Uniform" HorizontalAlignment="Left"></Image> + + <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right"> + <TextBlock TextWrapping="Wrap" TextAlignment="Right">Export the attached embroidery file to storage.</TextBlock> + <touch:TouchButton Command="{Binding ExportEmbroideryCommand}" Style="{StaticResource TangoHollowButton}" Width="240" Height="60" Margin="0 30 0 0" HorizontalAlignment="Right">EXPORT FILE</touch:TouchButton> + </StackPanel> + </DockPanel> + </StackPanel> + </StackPanel> + </Border> + <Border Style="{StaticResource TangoTouchBorder}" Margin="0 20 0 0" Padding="0 0 0 50"> <StackPanel> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"> diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T-CAP.dst b/Software/Visual_Studio/Resources/Pulse/TCap/T-CAP.dst Binary files differnew file mode 100644 index 000000000..3c89d3b99 --- /dev/null +++ b/Software/Visual_Studio/Resources/Pulse/TCap/T-CAP.dst diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png Binary files differnew file mode 100644 index 000000000..3b221c76d --- /dev/null +++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png Binary files differnew file mode 100644 index 000000000..9bad2fb00 --- /dev/null +++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T_Icon_embroidery_order.jpg b/Software/Visual_Studio/Resources/Pulse/TCap/T_Icon_embroidery_order.jpg Binary files differnew file mode 100644 index 000000000..6131f55f2 --- /dev/null +++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Icon_embroidery_order.jpg diff --git a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs index 65bb31208..9951d8d10 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs @@ -124,5 +124,99 @@ namespace Tango.UnitTesting.Pulse twnFilePath.Display(); } + + [TestMethod] + public void Compose_Artificial_Twn_File() + { + String dstFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T-CAP.dst"); + String imgSolidFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap_Solid.png"); + String imgGradientFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap.png"); + + TwnFile twnFile = new TwnFile(); + twnFile.Version = 1f; + twnFile.Name = "T Cap Solid"; + twnFile.NumberOfCopies = 1; + twnFile.MediaID = 0; + twnFile.SpoolingMethod = SpoolingMethods.SingleSpool; + + twnFile.EmbroideryFile = File.ReadAllBytes(dstFile); + twnFile.EmbroideryFileFormat = "dst"; + + + //Generate solid. + Bitmap thumbnail = new Bitmap(imgSolidFile); + twnFile.Thumbnail = thumbnail; + + twnFile.Segments.Add(CreateSolidSegment(10, 252, 224, 87)); + twnFile.Segments.Add(CreateSolidSegment(10, 251, 168, 45)); + twnFile.Segments.Add(CreateSolidSegment(10, 237, 19, 117)); + twnFile.Segments.Add(CreateSolidSegment(10, 234, 89, 56)); + + var tempFolder = TemporaryManager.Default.CreateFolder(); + twnFile.ToFile(Path.Combine(tempFolder, "t-cap solid.twn")); + + twnFile.Segments.Clear(); + + //Generate gradient. + twnFile.Name = "T Cap Gradient"; + + thumbnail = new Bitmap(imgGradientFile); + twnFile.Thumbnail = thumbnail; + + twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 242, 141, 172)); + + twnFile.ToFile(Path.Combine(tempFolder, "t-cap gradient.twn")); + + tempFolder.Display(); + } + + private TwnSegment CreateSolidSegment(float meter, byte r, byte g, byte b) + { + var segment = new TwnSegment() + { + Length = meter * 100, + BrushStops = new List<TwnStop>() + { + new TwnStop() + { + R = r, + G = g, + B = b + }, + } + }; + + return segment; + } + + private TwnSegment CreateGradientSegment(float meter, byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) + { + var segment = new TwnSegment() + { + Length = meter * 100, + BrushStops = new List<TwnStop>() + { + new TwnStop() + { + R = r1, + G = g1, + B = b1, + Offset = 0 + }, + new TwnStop() + { + R = r2, + G = g2, + B = b2, + Offset = 1 + }, + } + }; + + return segment; + } } } |
