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
{
///
/// Represents a Pulse, twn embroidery file.
///
public class TwnFile
{
///
/// Format Version (Default is 1.0).
///
public float Version { get; set; }
///
/// The name of the design or other labeling information as UTF-8 text.
///
public String Name { get; set; }
///
/// Number of copies. (The number 0 will be treated as 1, so the default is 0)
///
public int NumberOfCopies { get; set; }
///
/// 0 - Spool per segment. (default)
/// 1 - Spool per copy.
/// 2 - Single spool for all segments.
///
public SpoolingMethods SpoolingMethod { get; set; }
///
/// A unique code representing an optional media ID from Twine’s recommended media list
///
public int MediaID { get; set; }
///
/// 3 ASCII characters representing the embedded embroidery file extension (e.g dst, pes).
///
public String EmbroideryFileFormat { get; set; }
///
/// 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.
///
public Bitmap Thumbnail { get; set; }
///
/// Gets or sets the thumbnail data.
///
public byte[] ThumbnailData { get; set; }
///
/// Array of Brush Segment. The number of brush segments must be defined in the header.
///
public List Segments { get; set; }
///
/// Byte array representing the standard embroidery file which can be extracted and inserted into an embroidery machine.
///
public byte[] EmbroideryFile { get; set; }
///
/// Initializes a new instance of the class.
///
public TwnFile()
{
Version = 1.0f;
Segments = new List();
}
///
/// Writes the to the specified output stream.
///
/// The output stream.
public void ToStream(Stream output)
{
new TwnFileWriter().Write(this, output);
}
///
/// Writes the to the specified file path.
///
/// The file path.
public void ToFile(String filePath)
{
using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
ToStream(fs);
}
}
///
/// Loads a from the specified stream.
///
/// The TWN stream.
///
public static TwnFile FromStream(Stream twnStream)
{
return new TwnFileReader().Read(twnStream);
}
///
/// Loads a from the specified file path.
///
/// The TWN file path.
///
public static TwnFile FromFile(String twnFilePath)
{
using (FileStream fs = new FileStream(twnFilePath, FileMode.Open))
{
return FromStream(fs);
}
}
}
}