blob: 40ee5847633e7470c4b01e6c4415690fa5767863 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.Pulse
{
/// <summary>
/// Represents a Pulse, twn embroidery file.
/// </summary>
public class TwnFile
{
/// <summary>
/// Format Version (Default is 1.0).
/// </summary>
public float Version { get; set; }
/// <summary>
/// The name of the design or other labeling information as UTF-8 text.
/// </summary>
public String Name { get; set; }
/// <summary>
/// Number of copies. (The number 0 will be treated as 1, so the default is 0)
/// </summary>
public int NumberOfCopies { get; set; }
/// <summary>
/// 0 - Spool per segment. (default)
/// 1 - Spool per copy.
/// 2 - Single spool for all segments.
/// </summary>
public SpoolingMethods SpoolingMethod { get; set; }
/// <summary>
/// A unique code representing an optional media ID from Twine’s recommended media list
/// </summary>
public int MediaID { get; set; }
/// <summary>
/// 3 ASCII characters representing the embedded embroidery file extension (e.g dst, pes).
/// </summary>
public String EmbroideryFileFormat { get; set; }
/// <summary>
/// preview image in
/// PNG format(transparent background). The size of the PNG byte array must be defined in the header.
/// Recommended image width is 1280 pixels while maintaining aspect ratio.
/// </summary>
public Bitmap Thumbnail { get; set; }
/// <summary>
/// Gets or sets the thumbnail data.
/// </summary>
public byte[] ThumbnailData { get; set; }
/// <summary>
/// Array of Brush Segment. The number of brush segments must be defined in the header.
/// </summary>
public List<TwnSegment> Segments { get; set; }
/// <summary>
/// Byte array representing the standard embroidery file which can be extracted and inserted into an embroidery machine.
/// </summary>
public byte[] EmbroideryFile { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="TwnFile"/> class.
/// </summary>
public TwnFile()
{
Version = 1.0f;
Segments = new List<TwnSegment>();
}
/// <summary>
/// Writes the <see cref="TwnFile"/> to the specified output stream.
/// </summary>
/// <param name="output">The output stream.</param>
public void ToStream(Stream output)
{
new TwnFileWriter().Write(this, output);
}
/// <summary>
/// Writes the <see cref="TwnFile"/> to the specified file path.
/// </summary>
/// <param name="filePath">The file path.</param>
public void ToFile(String filePath)
{
using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
ToStream(fs);
}
}
/// <summary>
/// Loads a <see cref="TwnFile"/> from the specified stream.
/// </summary>
/// <param name="twnStream">The TWN stream.</param>
/// <returns></returns>
public static TwnFile FromStream(Stream twnStream)
{
return new TwnFileReader().Read(twnStream);
}
/// <summary>
/// Loads a <see cref="TwnFile"/> from the specified file path.
/// </summary>
/// <param name="twnFilePath">The TWN file path.</param>
/// <returns></returns>
public static TwnFile FromFile(String twnFilePath)
{
using (FileStream fs = new FileStream(twnFilePath, FileMode.Open))
{
return FromStream(fs);
}
}
}
}
|