aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-05-14 18:16:11 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-05-14 18:16:11 +0300
commitdad69951c0338be70949e823b1b0c321c862d3b9 (patch)
tree629b4127e26fba9a3b070613c1d31b32f01c54ab /Software/Visual_Studio
parenta9a2772e8159f65339d7c7405e988fe10d7589c8 (diff)
downloadTango-dad69951c0338be70949e823b1b0c321c862d3b9.tar.gz
Tango-dad69951c0338be70949e823b1b0c321c862d3b9.zip
Implemented Display & Export embroidery file to storage on PPC.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs38
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.pngbin0 -> 90271 bytes
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj3
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs48
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs20
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml21
-rw-r--r--Software/Visual_Studio/Resources/Pulse/TCap/T-CAP.dstbin0 -> 10737 bytes
-rw-r--r--Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.pngbin0 -> 129303 bytes
-rw-r--r--Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.pngbin0 -> 58648 bytes
-rw-r--r--Software/Visual_Studio/Resources/Pulse/TCap/T_Icon_embroidery_order.jpgbin0 -> 405188 bytes
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs94
11 files changed, 215 insertions, 9 deletions
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
new file mode 100644
index 000000000..f71bc2a70
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png
Binary files differ
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
new file mode 100644
index 000000000..3c89d3b99
--- /dev/null
+++ b/Software/Visual_Studio/Resources/Pulse/TCap/T-CAP.dst
Binary files differ
diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png
new file mode 100644
index 000000000..3b221c76d
--- /dev/null
+++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap.png
Binary files differ
diff --git a/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png
new file mode 100644
index 000000000..9bad2fb00
--- /dev/null
+++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Cap_Solid.png
Binary files differ
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
new file mode 100644
index 000000000..6131f55f2
--- /dev/null
+++ b/Software/Visual_Studio/Resources/Pulse/TCap/T_Icon_embroidery_order.jpg
Binary files differ
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;
+ }
}
}