diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-05-16 08:59:08 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-05-16 08:59:08 +0300 |
| commit | 4fdb3d2406b16a95e15fe24d6f562e666b3258af (patch) | |
| tree | 71be3e45606851677f6fc6be129e1d026619f25d /Software/Visual_Studio/Tango.UnitTesting | |
| parent | 724893cd6bd9e564a74d7c6d2c3a0d75b20f112c (diff) | |
| parent | 29c0bfe1969cb1f755f8dd11326fc3828c08b866 (diff) | |
| download | Tango-4fdb3d2406b16a95e15fe24d6f562e666b3258af.tar.gz Tango-4fdb3d2406b16a95e15fe24d6f562e666b3258af.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs | 94 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs | 3 |
2 files changed, 94 insertions, 3 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; + } } } diff --git a/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs index 59237b4a0..c4332a146 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/TCC/TCC_TST.cs @@ -32,7 +32,6 @@ namespace Tango.UnitTesting.TCC { DetectionInput input = new DetectionInput() { - Number = 5, Columns = 10, Rows = 11, TargetIndex = 99, @@ -78,8 +77,6 @@ namespace Tango.UnitTesting.TCC } Helper.ShowInExplorer(benchmarksCsvFile); - - Assert.IsTrue(output.Number == 15); } } } |
