aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
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/Tango.UnitTesting
parenta9a2772e8159f65339d7c7405e988fe10d7589c8 (diff)
downloadTango-dad69951c0338be70949e823b1b0c321c862d3b9.tar.gz
Tango-dad69951c0338be70949e823b1b0c321c862d3b9.zip
Implemented Display & Export embroidery file to storage on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs94
1 files changed, 94 insertions, 0 deletions
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;
+ }
}
}