From a9ff7b58ab54a6cfc87164c07808b2997b94c489 Mon Sep 17 00:00:00 2001 From: Nathan Crawford Date: Thu, 18 Jun 2009 17:19:06 +0000 Subject: [PATCH] Set eol and mime type properties that were wiped out during repository split --- PesFile/PesFile.cs | 1576 ++++++++--------- PesFile/Properties/AssemblyInfo.cs | 118 +- embroideryInfo/Program.cs | 146 +- embroideryInfo/Properties/AssemblyInfo.cs | 114 +- embroideryReader/Program.cs | 88 +- embroideryReader/Properties/AssemblyInfo.cs | 116 +- .../Properties/Resources.Designer.cs | 192 +- .../Properties/Settings.Designer.cs | 110 +- embroideryReader/frmMain.Designer.cs | 826 ++++----- embroideryReader/frmMain.cs | 994 +++++------ .../frmSettingsDialog.Designer.cs | 512 +++--- embroideryReader/frmSettingsDialog.cs | 348 ++-- embroideryReader/frmTextbox.Designer.cs | 164 +- embroideryReader/frmTextbox.cs | 96 +- embroideryTester/Form1.Designer.cs | 190 +- embroideryTester/Form1.cs | 240 +-- embroideryTester/Program.cs | 86 +- embroideryTester/Properties/AssemblyInfo.cs | 66 +- .../Properties/Resources.Designer.cs | 126 +- .../Properties/Settings.Designer.cs | 52 +- embroideryThumbs/PESThumbnail.cs | 334 ++-- 21 files changed, 3247 insertions(+), 3247 deletions(-) diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index 10647f0..44502f0 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -1,788 +1,788 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace PesFile -{ - public enum statusEnum { NotOpen, IOError, ReadError, Ready }; - public class stitchBlock - { - public Color color; - public Int32 colorIndex; - public Int32 stitchesTotal; - public Point[] stitches; - public stitchBlock() - { - color = System.Drawing.Color.Black; - } - } - - public struct intPair - { - public int a; - public int b; - } - - public class PesFile - { - System.IO.BinaryReader fileIn; - int imageWidth; - int imageHeight; - string _filename; - public List pesHeader = new List(); - public List embOneHeader = new List(); - public List sewSegHeader = new List(); - public List embPunchHeader = new List(); - public List sewFigSegHeader = new List(); - public List blocks = new List(); - public List colorTable = new List(); - private statusEnum readyStatus = statusEnum.NotOpen; - Int64 startStitches = 0; - string lastError = ""; - string pesNum = ""; - Point translateStart; - - - //means we couldn't figure out some or all - //of the colors, best guess will be used - private bool colorWarning = false; - - private bool formatWarning = false; - - private bool classWarning = false; - - public PesFile(string filename) - { - OpenFile(filename); - } - - private void OpenFile(string filename) - { -#if !DEBUG - try - { -#endif - _filename = filename; - fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)); - - string startFileSig = ""; - for (int i = 0; i < 8; i++)//8 bytes - { - startFileSig += fileIn.ReadChar(); - } - if (!startFileSig.StartsWith("#PES"))//this is not a file that we can read - { - readyStatus = statusEnum.ReadError; - lastError = "Missing #PES at beginning of file"; - fileIn.Close(); - return; - } - int pecstart = fileIn.ReadInt32(); - - fileIn.BaseStream.Position = pecstart + 48; - int numColors = fileIn.ReadByte() +1; - List colorList = new List(); - for (int x = 0; x < numColors; x++) - { - colorList.Add(fileIn.ReadByte()); - } - - fileIn.BaseStream.Position = pecstart + 532; - bool thisPartIsDone = false; - stitchBlock curBlock; - int prevX = 0; - int prevY = 0; - int maxX = 0; - int minX = 0; - int maxY = 0; - int minY = 0; - int colorNum = -1; - int colorIndex = 0; - List tempStitches = new List(); - while (!thisPartIsDone) - { - byte val1; - byte val2; - val1 = fileIn.ReadByte(); - val2 = fileIn.ReadByte(); - if (val1 == 255 && val2 == 0) - { - //end of stitches - thisPartIsDone = true; - - //add the last block - curBlock = new stitchBlock(); - curBlock.stitches = new Point[tempStitches.Count]; - tempStitches.CopyTo(curBlock.stitches); - curBlock.stitchesTotal = tempStitches.Count; - colorNum++; - colorIndex = colorList[colorNum]; - curBlock.colorIndex = colorIndex; - curBlock.color = getColorFromIndex(colorIndex); - blocks.Add(curBlock); - } - else if (val1 == 254 && val2 == 176) - { - //color switch, start a new block - - curBlock = new stitchBlock(); - curBlock.stitches = new Point[tempStitches.Count]; - tempStitches.CopyTo(curBlock.stitches); - curBlock.stitchesTotal = tempStitches.Count; - colorNum++; - colorIndex = colorList[colorNum]; - curBlock.colorIndex = colorIndex; - curBlock.color = getColorFromIndex(colorIndex); - blocks.Add(curBlock); - - tempStitches = new List(); - - //read useless(?) byte - fileIn.ReadByte(); - } - else - { - int deltaX = 0; - int deltaY = 0; - if ((val1 & 128) == 128)//$80 - { - //this is a jump stitch - deltaX = ((val1 & 15) * 256) + val2; - if ((deltaX & 2048) == 2048) //$0800 - { - deltaX = deltaX - 4096; - } - //read next byte for Y value - val2 = fileIn.ReadByte(); - } - else - { - //normal stitch - deltaX = val1; - if (deltaX > 63) - { - deltaX = deltaX - 128; - } - } - - if ((val2 & 128) == 128)//$80 - { - //this is a jump stitch - int val3 = fileIn.ReadByte(); - deltaY = ((val2 & 15) * 256) + val3; - if ((deltaY & 2048) == 2048) - { - deltaY = deltaY - 4096; - } - } - else - { - //normal stitch - deltaY = val2; - if (deltaY > 63) - { - deltaY = deltaY - 128; - } - } - tempStitches.Add(new Point(prevX + deltaX, prevY + deltaY)); - prevX = prevX + deltaX; - prevY = prevY + deltaY; - if (prevX > maxX) - { - maxX = prevX; - } - else if (prevX < minX) - { - minX = prevX; - } - - if (prevY > maxY) - { - maxY = prevY; - } - else if (prevY < minY) - { - minY = prevY; - } - } - } - imageWidth = maxX - minX; - imageHeight = maxY - minY; - translateStart.X = -minX; - translateStart.Y = -minY; - readyStatus = statusEnum.Ready; - -#if !DEBUG - } - catch (System.IO.IOException ioex) - { - readyStatus = statusEnum.IOError; - lastError = ioex.Message; - if (fileIn != null) - { - fileIn.Close(); - } - } - catch (Exception ex) - { - readyStatus = statusEnum.ReadError; - lastError = ex.Message; - if (fileIn != null) - { - fileIn.Close(); - } - } -#endif - } - - void readCSewFigSeg(System.IO.BinaryReader file) - { - startStitches = fileIn.BaseStream.Position; - - bool doneWithStitches = false; - int xValue = -100; - int yValue = -100; - stitchBlock currentBlock; - int blockType; //if this is equal to newColorMarker, it's time to change color - int colorIndex = 0; - int remainingStitches; - List stitchData; - stitchData = new List(); - currentBlock = new stitchBlock(); - - while (!doneWithStitches) - { - //reset variables - xValue = 0; - yValue = 0; - - blockType = file.ReadInt16(); - if (blockType == 16716) - break; - colorIndex = file.ReadInt16(); - if (colorIndex == 16716) - break; - remainingStitches = file.ReadInt16(); - if (remainingStitches == 16716) - break; - while (remainingStitches >= 0) - { - xValue = file.ReadInt16(); - if (xValue == -32765) - { - break;//drop out before we start eating into the next section - } - if (remainingStitches == 0) - { - int junk2 = 0; - junk2 = blocks.Count; - - file.ReadBytes(24); - if (file.ReadInt16() == -1) - doneWithStitches = true; - - currentBlock.stitches = new Point[stitchData.Count]; - stitchData.CopyTo(currentBlock.stitches); - currentBlock.colorIndex = colorIndex; - currentBlock.color = getColorFromIndex(colorIndex); - currentBlock.stitchesTotal = stitchData.Count; - blocks.Add(currentBlock); - stitchData = new List(); - currentBlock = new stitchBlock(); - - file.ReadBytes(48); - - break; - } - else if (xValue == 16716 || xValue == 8224) - { - doneWithStitches = true; - break; - } - yValue = fileIn.ReadInt16(); - if (yValue == 16716 || yValue == 8224) - { - doneWithStitches = true; - break; - } - stitchData.Add(new Point(xValue - translateStart.X, yValue + imageHeight - translateStart.Y)); - remainingStitches--; - } - } - if (stitchData.Count > 1) - { - currentBlock.stitches = new Point[stitchData.Count]; - stitchData.CopyTo(currentBlock.stitches); - currentBlock.colorIndex = colorIndex; - currentBlock.color = getColorFromIndex(colorIndex); - currentBlock.stitchesTotal = stitchData.Count; - blocks.Add(currentBlock); - } - } - - List filterStitches(List input, int threshold) - { - List retval = new List(); - List tempStitchData = new List(); - for (int x = 0; x < input.Count; x++) - { - - for (int i = 0; i < input[x].stitches.Length; i++) - { - if (i > 0)//need a previous point to check against, can't check the first - { - double diffx = Math.Abs(input[x].stitches[i].X - input[x].stitches[i - 1].X); - double diffy = Math.Abs(input[x].stitches[i].Y - input[x].stitches[i - 1].Y); - if (Math.Sqrt(Math.Pow(diffx, 2.0) + Math.Pow(diffy, 2.0)) < threshold) //check distance between this point and the last one - { - if (tempStitchData.Count == 0 && i > 1)//first stitch of block gets left out without this, except for very first stitch - { - tempStitchData.Add(input[x].stitches[i - 1]); - } - tempStitchData.Add(input[x].stitches[i]); - } - else//stitch is too far from the previous one - { - if (tempStitchData.Count > 2)//add the block and start a new one - { - stitchBlock tempBlock = new stitchBlock(); - tempBlock.color = input[x].color; - tempBlock.colorIndex = input[x].colorIndex; - tempBlock.stitches = new Point[tempStitchData.Count]; - tempStitchData.CopyTo(tempBlock.stitches); - retval.Add(tempBlock); - tempStitchData = new List(); - } - else//reset variables - { - tempStitchData = new List(); - } - } - } - else //just add the first one, don't have anything to compare against - { - tempStitchData.Add(input[x].stitches[i]); - } - } - if (tempStitchData.Count > 2) - { - stitchBlock tempBlock = new stitchBlock(); - tempBlock.color = input[x].color; - tempBlock.colorIndex = input[x].colorIndex; - tempBlock.stitches = new Point[tempStitchData.Count]; - tempStitchData.CopyTo(tempBlock.stitches); - retval.Add(tempBlock); - tempStitchData = new List(); - } - } - return retval; - } - - public int GetWidth() - { - return imageWidth; - } - - public int GetHeight() - { - return imageHeight; - } - - public string GetFileName() - { - if (_filename == null) - { - return ""; - } - else - { - return _filename; - } - } - - public void saveDebugInfo() - { - System.IO.StreamWriter outfile = new System.IO.StreamWriter(System.IO.Path.ChangeExtension(_filename, ".txt")); - outfile.Write(getDebugInfo()); - outfile.Close(); - } - - public string getDebugInfo() - { - System.IO.StringWriter outfile = new System.IO.StringWriter(); - string name = ""; - outfile.WriteLine("PES header"); - outfile.WriteLine("PES number:\t" + pesNum); - for (int i = 0; i < pesHeader.Count; i++) - { - name = (i + 1).ToString(); - outfile.WriteLine(name + "\t" + pesHeader[i].ToString()); - } - if (embOneHeader.Count > 0) - { - outfile.WriteLine("CEmbOne header"); - for (int i = 0; i < embOneHeader.Count; i++) - { - switch (i + 1) - { - case 22: - name = "translate x"; - break; - case 23: - name = "translate y"; - break; - case 24: - name = "width"; - break; - case 25: - name = "height"; - break; - default: - name = (i + 1).ToString(); - break; - } - - outfile.WriteLine(name + "\t" + embOneHeader[i].ToString()); - } - } - if (embPunchHeader.Count > 0) - { - outfile.WriteLine("CEmbPunch header"); - for (int i = 0; i < embPunchHeader.Count; i++) - { - switch (i + 1) - { - default: - name = (i + 1).ToString(); - break; - } - - outfile.WriteLine(name + "\t" + embPunchHeader[i].ToString()); - } - } - - outfile.WriteLine("stitches start: " + startStitches.ToString()); - outfile.WriteLine("block info"); - outfile.WriteLine("number\tcolor\tstitches"); - for (int i = 0; i < this.blocks.Count; i++) - { - outfile.WriteLine((i + 1).ToString() + "\t" + blocks[i].colorIndex.ToString() + "\t" + blocks[i].stitchesTotal.ToString()); - } - outfile.WriteLine("color table"); - outfile.WriteLine("number\ta\tb"); - for (int i = 0; i < colorTable.Count; i++) - { - outfile.WriteLine((i + 1).ToString() + "\t" + colorTable[i].a.ToString() + ", " + colorTable[i].b.ToString()); - } - if (blocks.Count > 0) - { - outfile.WriteLine("Extended stitch debug info"); - for (int blocky = 0; blocky < blocks.Count; blocky++) - { - outfile.WriteLine("block " + (blocky + 1).ToString() + " start"); - for (int stitchy = 0; stitchy < blocks[blocky].stitches.Length; stitchy++) - { - outfile.WriteLine(blocks[blocky].stitches[stitchy].X.ToString() + ", " + blocks[blocky].stitches[stitchy].Y.ToString()); - } - } - } - outfile.Close(); - return outfile.ToString(); - } - - public statusEnum getStatus() - { - return readyStatus; - } - - public string getLastError() - { - return lastError; - } - - public bool getColorWarning() - { - return colorWarning; - } - - public bool getFormatWarning() - { - return formatWarning; - } - - public bool getClassWarning() - { - return classWarning; - } - - private Color getColorFromIndex(int index) - { - Color retval;// = Color.White; - switch (index) - { - case 1: - retval = Color.FromArgb(14, 31, 124); - break; - case 2: - retval = Color.FromArgb(10, 85, 163); - break; - case 3: - retval = Color.FromArgb(48, 135, 119); - break; - case 4: - retval = Color.FromArgb(75, 107, 175); - break; - case 5: - retval = Color.FromArgb(237, 23, 31); - break; - case 6: - retval = Color.FromArgb(209, 92, 0); - break; - case 7: - retval = Color.FromArgb(145, 54, 151); - break; - case 8: - retval = Color.FromArgb(228, 154, 203); - break; - case 9: - retval = Color.FromArgb(145, 95, 172); - break; - case 10: - retval = Color.FromArgb(157, 214, 125); - break; - case 11: - retval = Color.FromArgb(232, 169, 0); - break; - case 12: - retval = Color.FromArgb(254, 186, 53); - break; - case 13: - retval = Color.FromArgb(255, 255, 0); - break; - case 14: - retval = Color.FromArgb(112, 188, 31); - break; - case 15: - retval = Color.FromArgb(186, 152, 0); - break; - case 16: - retval = Color.FromArgb(168, 168, 168); - break; - case 17: - retval = Color.FromArgb(123, 111, 0); - break; - case 18: - retval = Color.FromArgb(255, 255, 179); - break; - case 19: - retval = Color.FromArgb(79, 85, 86); - break; - case 20: - retval = Color.FromArgb(0, 0, 0); - break; - case 21: - retval = Color.FromArgb(11, 61, 145); - break; - case 22: - retval = Color.FromArgb(119, 1, 118); - break; - case 23: - retval = Color.FromArgb(41, 49, 51); - break; - case 24: - retval = Color.FromArgb(42, 19, 1); - break; - case 25: - retval = Color.FromArgb(246, 74, 138); - break; - case 26: - retval = Color.FromArgb(178, 118, 36); - break; - case 27: - retval = Color.FromArgb(252, 187, 196); - break; - case 28: - retval = Color.FromArgb(254, 55, 15); - break; - case 29: - retval = Color.FromArgb(240, 240, 240); - break; - case 30: - retval = Color.FromArgb(106, 28, 138); - break; - case 31: - retval = Color.FromArgb(168, 221, 196); - break; - case 32: - retval = Color.FromArgb(37, 132, 187); - break; - case 33: - retval = Color.FromArgb(254, 179, 67); - break; - case 34: - retval = Color.FromArgb(255, 240, 141); - break; - case 35: - retval = Color.FromArgb(208, 166, 96); - break; - case 36: - retval = Color.FromArgb(209, 84, 0); - break; - case 37: - retval = Color.FromArgb(102, 186, 73); - break; - case 38: - retval = Color.FromArgb(19, 74, 70); - break; - case 39: - retval = Color.FromArgb(135, 135, 135); - break; - case 40: - retval = Color.FromArgb(216, 202, 198); - break; - case 41: - retval = Color.FromArgb(67, 86, 7); - break; - case 42: - retval = Color.FromArgb(254, 227, 197); - break; - case 43: - retval = Color.FromArgb(249, 147, 188); - break; - case 44: - retval = Color.FromArgb(0, 56, 34); - break; - case 45: - retval = Color.FromArgb(178, 175, 212); - break; - case 46: - retval = Color.FromArgb(104, 106, 176); - break; - case 47: - retval = Color.FromArgb(239, 227, 185); - break; - case 48: - retval = Color.FromArgb(247, 56, 102); - break; - case 49: - retval = Color.FromArgb(181, 76, 100); - break; - case 50: - retval = Color.FromArgb(19, 43, 26); - break; - case 51: - retval = Color.FromArgb(199, 1, 85); - break; - case 52: - retval = Color.FromArgb(254, 158, 50); - break; - case 53: - retval = Color.FromArgb(168, 222, 235); - break; - case 54: - retval = Color.FromArgb(0, 103, 26); - break; - case 55: - retval = Color.FromArgb(78, 41, 144); - break; - case 56: - retval = Color.FromArgb(47, 126, 32); - break; - case 57: - retval = Color.FromArgb(253, 217, 222); - break; - case 58: - retval = Color.FromArgb(255, 217, 17); - break; - case 59: - retval = Color.FromArgb(9, 91, 166); - break; - case 60: - retval = Color.FromArgb(240, 249, 112); - break; - case 61: - retval = Color.FromArgb(227, 243, 91); - break; - case 62: - retval = Color.FromArgb(255, 200, 100); - break; - case 63: - retval = Color.FromArgb(255, 200, 150); - break; - case 64: - retval = Color.FromArgb(255, 200, 200); - break; - default: - retval = Color.White; - colorWarning = true; - break; - } - return retval; - } - - public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, int filterUglyStitchesThreshold) - { - Bitmap DrawArea; - Graphics xGraph; - - DrawArea = new Bitmap(GetWidth() + (int)(threadThickness * 2), GetHeight() + (int)(threadThickness * 2)); - //panel1.Width = design.GetWidth() + (int)(threadThickness * 2); - //panel1.Height = design.GetHeight() + (int)(threadThickness * 2); - xGraph = Graphics.FromImage(DrawArea); - xGraph.TranslateTransform(threadThickness+translateStart.X, threadThickness+translateStart.Y); - //xGraph.FillRectangle(Brushes.White, 0, 0, DrawArea.Width, DrawArea.Height); - List tmpblocks; -#if DEBUG - tmpblocks = blocks; -#else - if (filterUglyStitches && !formatWarning) //only filter stitches if we think we understand the format - { - tmpblocks = filterStitches(blocks, filterUglyStitchesThreshold); - } - else - { - tmpblocks = blocks; - } -#endif - for (int i = 0; i < tmpblocks.Count; i++) - { - if (tmpblocks[i].stitches.Length > 1)//must have 2 points to make a line - { - Pen tempPen = new Pen(tmpblocks[i].color, threadThickness); - tempPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; - tempPen.EndCap = System.Drawing.Drawing2D.LineCap.Round; - tempPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; - xGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; - xGraph.DrawLines(tempPen, tmpblocks[i].stitches); - } - } - xGraph.Dispose(); - return DrawArea; - } - } -} +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; + +namespace PesFile +{ + public enum statusEnum { NotOpen, IOError, ReadError, Ready }; + public class stitchBlock + { + public Color color; + public Int32 colorIndex; + public Int32 stitchesTotal; + public Point[] stitches; + public stitchBlock() + { + color = System.Drawing.Color.Black; + } + } + + public struct intPair + { + public int a; + public int b; + } + + public class PesFile + { + System.IO.BinaryReader fileIn; + int imageWidth; + int imageHeight; + string _filename; + public List pesHeader = new List(); + public List embOneHeader = new List(); + public List sewSegHeader = new List(); + public List embPunchHeader = new List(); + public List sewFigSegHeader = new List(); + public List blocks = new List(); + public List colorTable = new List(); + private statusEnum readyStatus = statusEnum.NotOpen; + Int64 startStitches = 0; + string lastError = ""; + string pesNum = ""; + Point translateStart; + + + //means we couldn't figure out some or all + //of the colors, best guess will be used + private bool colorWarning = false; + + private bool formatWarning = false; + + private bool classWarning = false; + + public PesFile(string filename) + { + OpenFile(filename); + } + + private void OpenFile(string filename) + { +#if !DEBUG + try + { +#endif + _filename = filename; + fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)); + + string startFileSig = ""; + for (int i = 0; i < 8; i++)//8 bytes + { + startFileSig += fileIn.ReadChar(); + } + if (!startFileSig.StartsWith("#PES"))//this is not a file that we can read + { + readyStatus = statusEnum.ReadError; + lastError = "Missing #PES at beginning of file"; + fileIn.Close(); + return; + } + int pecstart = fileIn.ReadInt32(); + + fileIn.BaseStream.Position = pecstart + 48; + int numColors = fileIn.ReadByte() +1; + List colorList = new List(); + for (int x = 0; x < numColors; x++) + { + colorList.Add(fileIn.ReadByte()); + } + + fileIn.BaseStream.Position = pecstart + 532; + bool thisPartIsDone = false; + stitchBlock curBlock; + int prevX = 0; + int prevY = 0; + int maxX = 0; + int minX = 0; + int maxY = 0; + int minY = 0; + int colorNum = -1; + int colorIndex = 0; + List tempStitches = new List(); + while (!thisPartIsDone) + { + byte val1; + byte val2; + val1 = fileIn.ReadByte(); + val2 = fileIn.ReadByte(); + if (val1 == 255 && val2 == 0) + { + //end of stitches + thisPartIsDone = true; + + //add the last block + curBlock = new stitchBlock(); + curBlock.stitches = new Point[tempStitches.Count]; + tempStitches.CopyTo(curBlock.stitches); + curBlock.stitchesTotal = tempStitches.Count; + colorNum++; + colorIndex = colorList[colorNum]; + curBlock.colorIndex = colorIndex; + curBlock.color = getColorFromIndex(colorIndex); + blocks.Add(curBlock); + } + else if (val1 == 254 && val2 == 176) + { + //color switch, start a new block + + curBlock = new stitchBlock(); + curBlock.stitches = new Point[tempStitches.Count]; + tempStitches.CopyTo(curBlock.stitches); + curBlock.stitchesTotal = tempStitches.Count; + colorNum++; + colorIndex = colorList[colorNum]; + curBlock.colorIndex = colorIndex; + curBlock.color = getColorFromIndex(colorIndex); + blocks.Add(curBlock); + + tempStitches = new List(); + + //read useless(?) byte + fileIn.ReadByte(); + } + else + { + int deltaX = 0; + int deltaY = 0; + if ((val1 & 128) == 128)//$80 + { + //this is a jump stitch + deltaX = ((val1 & 15) * 256) + val2; + if ((deltaX & 2048) == 2048) //$0800 + { + deltaX = deltaX - 4096; + } + //read next byte for Y value + val2 = fileIn.ReadByte(); + } + else + { + //normal stitch + deltaX = val1; + if (deltaX > 63) + { + deltaX = deltaX - 128; + } + } + + if ((val2 & 128) == 128)//$80 + { + //this is a jump stitch + int val3 = fileIn.ReadByte(); + deltaY = ((val2 & 15) * 256) + val3; + if ((deltaY & 2048) == 2048) + { + deltaY = deltaY - 4096; + } + } + else + { + //normal stitch + deltaY = val2; + if (deltaY > 63) + { + deltaY = deltaY - 128; + } + } + tempStitches.Add(new Point(prevX + deltaX, prevY + deltaY)); + prevX = prevX + deltaX; + prevY = prevY + deltaY; + if (prevX > maxX) + { + maxX = prevX; + } + else if (prevX < minX) + { + minX = prevX; + } + + if (prevY > maxY) + { + maxY = prevY; + } + else if (prevY < minY) + { + minY = prevY; + } + } + } + imageWidth = maxX - minX; + imageHeight = maxY - minY; + translateStart.X = -minX; + translateStart.Y = -minY; + readyStatus = statusEnum.Ready; + +#if !DEBUG + } + catch (System.IO.IOException ioex) + { + readyStatus = statusEnum.IOError; + lastError = ioex.Message; + if (fileIn != null) + { + fileIn.Close(); + } + } + catch (Exception ex) + { + readyStatus = statusEnum.ReadError; + lastError = ex.Message; + if (fileIn != null) + { + fileIn.Close(); + } + } +#endif + } + + void readCSewFigSeg(System.IO.BinaryReader file) + { + startStitches = fileIn.BaseStream.Position; + + bool doneWithStitches = false; + int xValue = -100; + int yValue = -100; + stitchBlock currentBlock; + int blockType; //if this is equal to newColorMarker, it's time to change color + int colorIndex = 0; + int remainingStitches; + List stitchData; + stitchData = new List(); + currentBlock = new stitchBlock(); + + while (!doneWithStitches) + { + //reset variables + xValue = 0; + yValue = 0; + + blockType = file.ReadInt16(); + if (blockType == 16716) + break; + colorIndex = file.ReadInt16(); + if (colorIndex == 16716) + break; + remainingStitches = file.ReadInt16(); + if (remainingStitches == 16716) + break; + while (remainingStitches >= 0) + { + xValue = file.ReadInt16(); + if (xValue == -32765) + { + break;//drop out before we start eating into the next section + } + if (remainingStitches == 0) + { + int junk2 = 0; + junk2 = blocks.Count; + + file.ReadBytes(24); + if (file.ReadInt16() == -1) + doneWithStitches = true; + + currentBlock.stitches = new Point[stitchData.Count]; + stitchData.CopyTo(currentBlock.stitches); + currentBlock.colorIndex = colorIndex; + currentBlock.color = getColorFromIndex(colorIndex); + currentBlock.stitchesTotal = stitchData.Count; + blocks.Add(currentBlock); + stitchData = new List(); + currentBlock = new stitchBlock(); + + file.ReadBytes(48); + + break; + } + else if (xValue == 16716 || xValue == 8224) + { + doneWithStitches = true; + break; + } + yValue = fileIn.ReadInt16(); + if (yValue == 16716 || yValue == 8224) + { + doneWithStitches = true; + break; + } + stitchData.Add(new Point(xValue - translateStart.X, yValue + imageHeight - translateStart.Y)); + remainingStitches--; + } + } + if (stitchData.Count > 1) + { + currentBlock.stitches = new Point[stitchData.Count]; + stitchData.CopyTo(currentBlock.stitches); + currentBlock.colorIndex = colorIndex; + currentBlock.color = getColorFromIndex(colorIndex); + currentBlock.stitchesTotal = stitchData.Count; + blocks.Add(currentBlock); + } + } + + List filterStitches(List input, int threshold) + { + List retval = new List(); + List tempStitchData = new List(); + for (int x = 0; x < input.Count; x++) + { + + for (int i = 0; i < input[x].stitches.Length; i++) + { + if (i > 0)//need a previous point to check against, can't check the first + { + double diffx = Math.Abs(input[x].stitches[i].X - input[x].stitches[i - 1].X); + double diffy = Math.Abs(input[x].stitches[i].Y - input[x].stitches[i - 1].Y); + if (Math.Sqrt(Math.Pow(diffx, 2.0) + Math.Pow(diffy, 2.0)) < threshold) //check distance between this point and the last one + { + if (tempStitchData.Count == 0 && i > 1)//first stitch of block gets left out without this, except for very first stitch + { + tempStitchData.Add(input[x].stitches[i - 1]); + } + tempStitchData.Add(input[x].stitches[i]); + } + else//stitch is too far from the previous one + { + if (tempStitchData.Count > 2)//add the block and start a new one + { + stitchBlock tempBlock = new stitchBlock(); + tempBlock.color = input[x].color; + tempBlock.colorIndex = input[x].colorIndex; + tempBlock.stitches = new Point[tempStitchData.Count]; + tempStitchData.CopyTo(tempBlock.stitches); + retval.Add(tempBlock); + tempStitchData = new List(); + } + else//reset variables + { + tempStitchData = new List(); + } + } + } + else //just add the first one, don't have anything to compare against + { + tempStitchData.Add(input[x].stitches[i]); + } + } + if (tempStitchData.Count > 2) + { + stitchBlock tempBlock = new stitchBlock(); + tempBlock.color = input[x].color; + tempBlock.colorIndex = input[x].colorIndex; + tempBlock.stitches = new Point[tempStitchData.Count]; + tempStitchData.CopyTo(tempBlock.stitches); + retval.Add(tempBlock); + tempStitchData = new List(); + } + } + return retval; + } + + public int GetWidth() + { + return imageWidth; + } + + public int GetHeight() + { + return imageHeight; + } + + public string GetFileName() + { + if (_filename == null) + { + return ""; + } + else + { + return _filename; + } + } + + public void saveDebugInfo() + { + System.IO.StreamWriter outfile = new System.IO.StreamWriter(System.IO.Path.ChangeExtension(_filename, ".txt")); + outfile.Write(getDebugInfo()); + outfile.Close(); + } + + public string getDebugInfo() + { + System.IO.StringWriter outfile = new System.IO.StringWriter(); + string name = ""; + outfile.WriteLine("PES header"); + outfile.WriteLine("PES number:\t" + pesNum); + for (int i = 0; i < pesHeader.Count; i++) + { + name = (i + 1).ToString(); + outfile.WriteLine(name + "\t" + pesHeader[i].ToString()); + } + if (embOneHeader.Count > 0) + { + outfile.WriteLine("CEmbOne header"); + for (int i = 0; i < embOneHeader.Count; i++) + { + switch (i + 1) + { + case 22: + name = "translate x"; + break; + case 23: + name = "translate y"; + break; + case 24: + name = "width"; + break; + case 25: + name = "height"; + break; + default: + name = (i + 1).ToString(); + break; + } + + outfile.WriteLine(name + "\t" + embOneHeader[i].ToString()); + } + } + if (embPunchHeader.Count > 0) + { + outfile.WriteLine("CEmbPunch header"); + for (int i = 0; i < embPunchHeader.Count; i++) + { + switch (i + 1) + { + default: + name = (i + 1).ToString(); + break; + } + + outfile.WriteLine(name + "\t" + embPunchHeader[i].ToString()); + } + } + + outfile.WriteLine("stitches start: " + startStitches.ToString()); + outfile.WriteLine("block info"); + outfile.WriteLine("number\tcolor\tstitches"); + for (int i = 0; i < this.blocks.Count; i++) + { + outfile.WriteLine((i + 1).ToString() + "\t" + blocks[i].colorIndex.ToString() + "\t" + blocks[i].stitchesTotal.ToString()); + } + outfile.WriteLine("color table"); + outfile.WriteLine("number\ta\tb"); + for (int i = 0; i < colorTable.Count; i++) + { + outfile.WriteLine((i + 1).ToString() + "\t" + colorTable[i].a.ToString() + ", " + colorTable[i].b.ToString()); + } + if (blocks.Count > 0) + { + outfile.WriteLine("Extended stitch debug info"); + for (int blocky = 0; blocky < blocks.Count; blocky++) + { + outfile.WriteLine("block " + (blocky + 1).ToString() + " start"); + for (int stitchy = 0; stitchy < blocks[blocky].stitches.Length; stitchy++) + { + outfile.WriteLine(blocks[blocky].stitches[stitchy].X.ToString() + ", " + blocks[blocky].stitches[stitchy].Y.ToString()); + } + } + } + outfile.Close(); + return outfile.ToString(); + } + + public statusEnum getStatus() + { + return readyStatus; + } + + public string getLastError() + { + return lastError; + } + + public bool getColorWarning() + { + return colorWarning; + } + + public bool getFormatWarning() + { + return formatWarning; + } + + public bool getClassWarning() + { + return classWarning; + } + + private Color getColorFromIndex(int index) + { + Color retval;// = Color.White; + switch (index) + { + case 1: + retval = Color.FromArgb(14, 31, 124); + break; + case 2: + retval = Color.FromArgb(10, 85, 163); + break; + case 3: + retval = Color.FromArgb(48, 135, 119); + break; + case 4: + retval = Color.FromArgb(75, 107, 175); + break; + case 5: + retval = Color.FromArgb(237, 23, 31); + break; + case 6: + retval = Color.FromArgb(209, 92, 0); + break; + case 7: + retval = Color.FromArgb(145, 54, 151); + break; + case 8: + retval = Color.FromArgb(228, 154, 203); + break; + case 9: + retval = Color.FromArgb(145, 95, 172); + break; + case 10: + retval = Color.FromArgb(157, 214, 125); + break; + case 11: + retval = Color.FromArgb(232, 169, 0); + break; + case 12: + retval = Color.FromArgb(254, 186, 53); + break; + case 13: + retval = Color.FromArgb(255, 255, 0); + break; + case 14: + retval = Color.FromArgb(112, 188, 31); + break; + case 15: + retval = Color.FromArgb(186, 152, 0); + break; + case 16: + retval = Color.FromArgb(168, 168, 168); + break; + case 17: + retval = Color.FromArgb(123, 111, 0); + break; + case 18: + retval = Color.FromArgb(255, 255, 179); + break; + case 19: + retval = Color.FromArgb(79, 85, 86); + break; + case 20: + retval = Color.FromArgb(0, 0, 0); + break; + case 21: + retval = Color.FromArgb(11, 61, 145); + break; + case 22: + retval = Color.FromArgb(119, 1, 118); + break; + case 23: + retval = Color.FromArgb(41, 49, 51); + break; + case 24: + retval = Color.FromArgb(42, 19, 1); + break; + case 25: + retval = Color.FromArgb(246, 74, 138); + break; + case 26: + retval = Color.FromArgb(178, 118, 36); + break; + case 27: + retval = Color.FromArgb(252, 187, 196); + break; + case 28: + retval = Color.FromArgb(254, 55, 15); + break; + case 29: + retval = Color.FromArgb(240, 240, 240); + break; + case 30: + retval = Color.FromArgb(106, 28, 138); + break; + case 31: + retval = Color.FromArgb(168, 221, 196); + break; + case 32: + retval = Color.FromArgb(37, 132, 187); + break; + case 33: + retval = Color.FromArgb(254, 179, 67); + break; + case 34: + retval = Color.FromArgb(255, 240, 141); + break; + case 35: + retval = Color.FromArgb(208, 166, 96); + break; + case 36: + retval = Color.FromArgb(209, 84, 0); + break; + case 37: + retval = Color.FromArgb(102, 186, 73); + break; + case 38: + retval = Color.FromArgb(19, 74, 70); + break; + case 39: + retval = Color.FromArgb(135, 135, 135); + break; + case 40: + retval = Color.FromArgb(216, 202, 198); + break; + case 41: + retval = Color.FromArgb(67, 86, 7); + break; + case 42: + retval = Color.FromArgb(254, 227, 197); + break; + case 43: + retval = Color.FromArgb(249, 147, 188); + break; + case 44: + retval = Color.FromArgb(0, 56, 34); + break; + case 45: + retval = Color.FromArgb(178, 175, 212); + break; + case 46: + retval = Color.FromArgb(104, 106, 176); + break; + case 47: + retval = Color.FromArgb(239, 227, 185); + break; + case 48: + retval = Color.FromArgb(247, 56, 102); + break; + case 49: + retval = Color.FromArgb(181, 76, 100); + break; + case 50: + retval = Color.FromArgb(19, 43, 26); + break; + case 51: + retval = Color.FromArgb(199, 1, 85); + break; + case 52: + retval = Color.FromArgb(254, 158, 50); + break; + case 53: + retval = Color.FromArgb(168, 222, 235); + break; + case 54: + retval = Color.FromArgb(0, 103, 26); + break; + case 55: + retval = Color.FromArgb(78, 41, 144); + break; + case 56: + retval = Color.FromArgb(47, 126, 32); + break; + case 57: + retval = Color.FromArgb(253, 217, 222); + break; + case 58: + retval = Color.FromArgb(255, 217, 17); + break; + case 59: + retval = Color.FromArgb(9, 91, 166); + break; + case 60: + retval = Color.FromArgb(240, 249, 112); + break; + case 61: + retval = Color.FromArgb(227, 243, 91); + break; + case 62: + retval = Color.FromArgb(255, 200, 100); + break; + case 63: + retval = Color.FromArgb(255, 200, 150); + break; + case 64: + retval = Color.FromArgb(255, 200, 200); + break; + default: + retval = Color.White; + colorWarning = true; + break; + } + return retval; + } + + public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, int filterUglyStitchesThreshold) + { + Bitmap DrawArea; + Graphics xGraph; + + DrawArea = new Bitmap(GetWidth() + (int)(threadThickness * 2), GetHeight() + (int)(threadThickness * 2)); + //panel1.Width = design.GetWidth() + (int)(threadThickness * 2); + //panel1.Height = design.GetHeight() + (int)(threadThickness * 2); + xGraph = Graphics.FromImage(DrawArea); + xGraph.TranslateTransform(threadThickness+translateStart.X, threadThickness+translateStart.Y); + //xGraph.FillRectangle(Brushes.White, 0, 0, DrawArea.Width, DrawArea.Height); + List tmpblocks; +#if DEBUG + tmpblocks = blocks; +#else + if (filterUglyStitches && !formatWarning) //only filter stitches if we think we understand the format + { + tmpblocks = filterStitches(blocks, filterUglyStitchesThreshold); + } + else + { + tmpblocks = blocks; + } +#endif + for (int i = 0; i < tmpblocks.Count; i++) + { + if (tmpblocks[i].stitches.Length > 1)//must have 2 points to make a line + { + Pen tempPen = new Pen(tmpblocks[i].color, threadThickness); + tempPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; + tempPen.EndCap = System.Drawing.Drawing2D.LineCap.Round; + tempPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; + xGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + xGraph.DrawLines(tempPen, tmpblocks[i].stitches); + } + } + xGraph.Dispose(); + return DrawArea; + } + } +} diff --git a/PesFile/Properties/AssemblyInfo.cs b/PesFile/Properties/AssemblyInfo.cs index 02a0616..b78812b 100644 --- a/PesFile/Properties/AssemblyInfo.cs +++ b/PesFile/Properties/AssemblyInfo.cs @@ -1,59 +1,59 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PesFile")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PesFile")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f0f809da-4d68-4682-aed3-c8c38979e509")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PesFile")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PesFile")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f0f809da-4d68-4682-aed3-c8c38979e509")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/embroideryInfo/Program.cs b/embroideryInfo/Program.cs index cfc6fc8..403601d 100644 --- a/embroideryInfo/Program.cs +++ b/embroideryInfo/Program.cs @@ -1,73 +1,73 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace embroideryInfo -{ - class Program - { - static void Main(string[] args) - { - if (args.Length > 0) - { - try - { - - if (args[0] == "--image" && args.Length > 1) - { - PesFile.PesFile design = new PesFile.PesFile(args[1]); - Bitmap DrawArea = design.designToBitmap(5, false, 0); - Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - Graphics tempGraph = Graphics.FromImage(temp); - tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); - tempGraph.DrawImageUnscaled(DrawArea, 0, 0); - tempGraph.Dispose(); - temp.Save(System.IO.Path.ChangeExtension(args[1], ".png")); - } - else - { - PesFile.PesFile design = new PesFile.PesFile(args[0]); - design.saveDebugInfo(); - } - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - else - { - Console.WriteLine("Specify input file"); - for (int x = 0; x < args.Length; x++) - { - Console.WriteLine(args[x]); - } - } - } - } -} +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; + +namespace embroideryInfo +{ + class Program + { + static void Main(string[] args) + { + if (args.Length > 0) + { + try + { + + if (args[0] == "--image" && args.Length > 1) + { + PesFile.PesFile design = new PesFile.PesFile(args[1]); + Bitmap DrawArea = design.designToBitmap(5, false, 0); + Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + Graphics tempGraph = Graphics.FromImage(temp); + tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); + tempGraph.DrawImageUnscaled(DrawArea, 0, 0); + tempGraph.Dispose(); + temp.Save(System.IO.Path.ChangeExtension(args[1], ".png")); + } + else + { + PesFile.PesFile design = new PesFile.PesFile(args[0]); + design.saveDebugInfo(); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + else + { + Console.WriteLine("Specify input file"); + for (int x = 0; x < args.Length; x++) + { + Console.WriteLine(args[x]); + } + } + } + } +} diff --git a/embroideryInfo/Properties/AssemblyInfo.cs b/embroideryInfo/Properties/AssemblyInfo.cs index ef2a35a..852195a 100644 --- a/embroideryInfo/Properties/AssemblyInfo.cs +++ b/embroideryInfo/Properties/AssemblyInfo.cs @@ -1,57 +1,57 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("embroideryInfo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("embroideryInfo")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4f0ed79b-33dc-4066-9a65-6d44d2b94332")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("embroideryInfo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("embroideryInfo")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4f0ed79b-33dc-4066-9a65-6d44d2b94332")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/embroideryReader/Program.cs b/embroideryReader/Program.cs index 6695c1e..e02f553 100644 --- a/embroideryReader/Program.cs +++ b/embroideryReader/Program.cs @@ -1,45 +1,45 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - - -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace embroideryReader -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmMain()); - } - } +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + + +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace embroideryReader +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmMain()); + } + } } \ No newline at end of file diff --git a/embroideryReader/Properties/AssemblyInfo.cs b/embroideryReader/Properties/AssemblyInfo.cs index 3e7d0dc..48a1a79 100644 --- a/embroideryReader/Properties/AssemblyInfo.cs +++ b/embroideryReader/Properties/AssemblyInfo.cs @@ -1,58 +1,58 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("embroideryReader")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("embroideryReader")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3a23ec6d-56f8-4048-acae-0454abb9aa5f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.4.0.5")] -[assembly: AssemblyFileVersion("1.4.0.5")] +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("embroideryReader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("embroideryReader")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3a23ec6d-56f8-4048-acae-0454abb9aa5f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.4.0.5")] +[assembly: AssemblyFileVersion("1.4.0.5")] diff --git a/embroideryReader/Properties/Resources.Designer.cs b/embroideryReader/Properties/Resources.Designer.cs index 1e0a96f..7793fe1 100644 --- a/embroideryReader/Properties/Resources.Designer.cs +++ b/embroideryReader/Properties/Resources.Designer.cs @@ -1,96 +1,96 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace embroideryReader.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("embroideryReader.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace embroideryReader.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("embroideryReader.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/embroideryReader/Properties/Settings.Designer.cs b/embroideryReader/Properties/Settings.Designer.cs index 455fcf6..7ab7428 100644 --- a/embroideryReader/Properties/Settings.Designer.cs +++ b/embroideryReader/Properties/Settings.Designer.cs @@ -1,55 +1,55 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace embroideryReader.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace embroideryReader.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/embroideryReader/frmMain.Designer.cs b/embroideryReader/frmMain.Designer.cs index fa7910d..4f029ea 100644 --- a/embroideryReader/frmMain.Designer.cs +++ b/embroideryReader/frmMain.Designer.cs @@ -1,413 +1,413 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -namespace embroideryReader -{ - partial class frmMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.panel1 = new System.Windows.Forms.Panel(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveAsBitmapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.rotateLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.rotateRightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.checkForUpdateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveDebugInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showDebugInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.panel2 = new System.Windows.Forms.Panel(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); - this.printDocument1 = new System.Drawing.Printing.PrintDocument(); - this.printDialog1 = new System.Windows.Forms.PrintDialog(); - this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.menuStrip1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.statusStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // panel1 - // - this.panel1.Location = new System.Drawing.Point(3, 3); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(44, 25); - this.panel1.TabIndex = 7; - this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileToolStripMenuItem, - this.editToolStripMenuItem, - this.viewToolStripMenuItem, - this.helpToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(572, 24); - this.menuStrip1.TabIndex = 8; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.openToolStripMenuItem, - this.saveAsBitmapToolStripMenuItem, - this.toolStripSeparator2, - this.printToolStripMenuItem, - this.printPreviewToolStripMenuItem, - this.toolStripSeparator3, - this.exitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20); - this.fileToolStripMenuItem.Text = "File"; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.openToolStripMenuItem.Text = "Open..."; - this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); - // - // saveAsBitmapToolStripMenuItem - // - this.saveAsBitmapToolStripMenuItem.Enabled = false; - this.saveAsBitmapToolStripMenuItem.Name = "saveAsBitmapToolStripMenuItem"; - this.saveAsBitmapToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.saveAsBitmapToolStripMenuItem.Text = "Save as image..."; - this.saveAsBitmapToolStripMenuItem.Click += new System.EventHandler(this.saveAsBitmapToolStripMenuItem_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(163, 6); - // - // printToolStripMenuItem - // - this.printToolStripMenuItem.Enabled = false; - this.printToolStripMenuItem.Name = "printToolStripMenuItem"; - this.printToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.printToolStripMenuItem.Text = "Print..."; - this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click); - // - // printPreviewToolStripMenuItem - // - this.printPreviewToolStripMenuItem.Enabled = false; - this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem"; - this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.printPreviewToolStripMenuItem.Text = "Print Preview..."; - this.printPreviewToolStripMenuItem.Click += new System.EventHandler(this.printPreviewToolStripMenuItem_Click); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(163, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(166, 22); - this.exitToolStripMenuItem.Text = "Exit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.copyToolStripMenuItem, - this.toolStripSeparator4, - this.preferencesToolStripMenuItem}); - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.editToolStripMenuItem.Text = "Edit"; - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Enabled = false; - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.Size = new System.Drawing.Size(155, 22); - this.copyToolStripMenuItem.Text = "Copy"; - this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(152, 6); - // - // preferencesToolStripMenuItem - // - this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; - this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(155, 22); - this.preferencesToolStripMenuItem.Text = "Preferences..."; - this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); - // - // viewToolStripMenuItem - // - this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.rotateLeftToolStripMenuItem, - this.rotateRightToolStripMenuItem, - this.refreshToolStripMenuItem}); - this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; - this.viewToolStripMenuItem.Size = new System.Drawing.Size(41, 20); - this.viewToolStripMenuItem.Text = "View"; - // - // rotateLeftToolStripMenuItem - // - this.rotateLeftToolStripMenuItem.Enabled = false; - this.rotateLeftToolStripMenuItem.Name = "rotateLeftToolStripMenuItem"; - this.rotateLeftToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.rotateLeftToolStripMenuItem.Text = "Rotate left"; - this.rotateLeftToolStripMenuItem.Click += new System.EventHandler(this.rotateLeftToolStripMenuItem_Click); - // - // rotateRightToolStripMenuItem - // - this.rotateRightToolStripMenuItem.Enabled = false; - this.rotateRightToolStripMenuItem.Name = "rotateRightToolStripMenuItem"; - this.rotateRightToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.rotateRightToolStripMenuItem.Text = "Rotate right"; - this.rotateRightToolStripMenuItem.Click += new System.EventHandler(this.rotateRightToolStripMenuItem_Click); - // - // refreshToolStripMenuItem - // - this.refreshToolStripMenuItem.Enabled = false; - this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem"; - this.refreshToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.refreshToolStripMenuItem.Text = "Reset"; - this.refreshToolStripMenuItem.Click += new System.EventHandler(this.refreshToolStripMenuItem_Click); - // - // helpToolStripMenuItem - // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.checkForUpdateToolStripMenuItem, - this.saveDebugInfoToolStripMenuItem, - this.showDebugInfoToolStripMenuItem, - this.toolStripSeparator1, - this.aboutToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20); - this.helpToolStripMenuItem.Text = "Help"; - // - // checkForUpdateToolStripMenuItem - // - this.checkForUpdateToolStripMenuItem.Name = "checkForUpdateToolStripMenuItem"; - this.checkForUpdateToolStripMenuItem.Size = new System.Drawing.Size(199, 22); - this.checkForUpdateToolStripMenuItem.Text = "Check for update"; - this.checkForUpdateToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdateToolStripMenuItem_Click); - // - // saveDebugInfoToolStripMenuItem - // - this.saveDebugInfoToolStripMenuItem.Enabled = false; - this.saveDebugInfoToolStripMenuItem.Name = "saveDebugInfoToolStripMenuItem"; - this.saveDebugInfoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); - this.saveDebugInfoToolStripMenuItem.Text = "Save design debug info"; - this.saveDebugInfoToolStripMenuItem.Click += new System.EventHandler(this.saveDebugInfoToolStripMenuItem_Click); - // - // showDebugInfoToolStripMenuItem - // - this.showDebugInfoToolStripMenuItem.Enabled = false; - this.showDebugInfoToolStripMenuItem.Name = "showDebugInfoToolStripMenuItem"; - this.showDebugInfoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); - this.showDebugInfoToolStripMenuItem.Text = "Show design debug info"; - this.showDebugInfoToolStripMenuItem.Click += new System.EventHandler(this.showDebugInfoToolStripMenuItem_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(196, 6); - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(199, 22); - this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); - // - // panel2 - // - this.panel2.AutoScroll = true; - this.panel2.Controls.Add(this.panel1); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(0, 24); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(572, 332); - this.panel2.TabIndex = 10; - // - // statusStrip1 - // - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1, - this.toolStripStatusLabel2}); - this.statusStrip1.Location = new System.Drawing.Point(0, 356); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(572, 22); - this.statusStrip1.TabIndex = 11; - this.statusStrip1.Text = "statusStrip1"; - // - // toolStripStatusLabel1 - // - this.toolStripStatusLabel1.BackColor = System.Drawing.Color.Transparent; - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); - // - // toolStripStatusLabel2 - // - this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; - this.toolStripStatusLabel2.Size = new System.Drawing.Size(557, 17); - this.toolStripStatusLabel2.Spring = true; - this.toolStripStatusLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // printDocument1 - // - this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage); - // - // printDialog1 - // - this.printDialog1.UseEXDialog = true; - // - // printPreviewDialog1 - // - this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0); - this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0); - this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300); - this.printPreviewDialog1.Enabled = true; - this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon"))); - this.printPreviewDialog1.Name = "printPreviewDialog1"; - this.printPreviewDialog1.Visible = false; - // - // timer1 - // - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // frmMain - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(572, 378); - this.Controls.Add(this.panel2); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.menuStrip1); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MainMenuStrip = this.menuStrip1; - this.Name = "frmMain"; - this.Text = "Form1"; - this.Load += new System.EventHandler(this.Form1_Load); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.panel2.ResumeLayout(false); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem checkForUpdateToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.ToolStripMenuItem saveDebugInfoToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem printToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Drawing.Printing.PrintDocument printDocument1; - private System.Windows.Forms.PrintDialog printDialog1; - private System.Windows.Forms.ToolStripMenuItem printPreviewToolStripMenuItem; - private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem rotateLeftToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem rotateRightToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showDebugInfoToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveAsBitmapToolStripMenuItem; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; - private System.Windows.Forms.Timer timer1; - } -} - +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +namespace embroideryReader +{ + partial class frmMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.panel1 = new System.Windows.Forms.Panel(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveAsBitmapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rotateLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rotateRightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.checkForUpdateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveDebugInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showDebugInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.panel2 = new System.Windows.Forms.Panel(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); + this.printDocument1 = new System.Drawing.Printing.PrintDocument(); + this.printDialog1 = new System.Windows.Forms.PrintDialog(); + this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.menuStrip1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // panel1 + // + this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(44, 25); + this.panel1.TabIndex = 7; + this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.editToolStripMenuItem, + this.viewToolStripMenuItem, + this.helpToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(572, 24); + this.menuStrip1.TabIndex = 8; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openToolStripMenuItem, + this.saveAsBitmapToolStripMenuItem, + this.toolStripSeparator2, + this.printToolStripMenuItem, + this.printPreviewToolStripMenuItem, + this.toolStripSeparator3, + this.exitToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.openToolStripMenuItem.Text = "Open..."; + this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); + // + // saveAsBitmapToolStripMenuItem + // + this.saveAsBitmapToolStripMenuItem.Enabled = false; + this.saveAsBitmapToolStripMenuItem.Name = "saveAsBitmapToolStripMenuItem"; + this.saveAsBitmapToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.saveAsBitmapToolStripMenuItem.Text = "Save as image..."; + this.saveAsBitmapToolStripMenuItem.Click += new System.EventHandler(this.saveAsBitmapToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(163, 6); + // + // printToolStripMenuItem + // + this.printToolStripMenuItem.Enabled = false; + this.printToolStripMenuItem.Name = "printToolStripMenuItem"; + this.printToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.printToolStripMenuItem.Text = "Print..."; + this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click); + // + // printPreviewToolStripMenuItem + // + this.printPreviewToolStripMenuItem.Enabled = false; + this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem"; + this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.printPreviewToolStripMenuItem.Text = "Print Preview..."; + this.printPreviewToolStripMenuItem.Click += new System.EventHandler(this.printPreviewToolStripMenuItem_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(163, 6); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.exitToolStripMenuItem.Text = "Exit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyToolStripMenuItem, + this.toolStripSeparator4, + this.preferencesToolStripMenuItem}); + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.editToolStripMenuItem.Text = "Edit"; + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Enabled = false; + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(155, 22); + this.copyToolStripMenuItem.Text = "Copy"; + this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(152, 6); + // + // preferencesToolStripMenuItem + // + this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; + this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(155, 22); + this.preferencesToolStripMenuItem.Text = "Preferences..."; + this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); + // + // viewToolStripMenuItem + // + this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.rotateLeftToolStripMenuItem, + this.rotateRightToolStripMenuItem, + this.refreshToolStripMenuItem}); + this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; + this.viewToolStripMenuItem.Size = new System.Drawing.Size(41, 20); + this.viewToolStripMenuItem.Text = "View"; + // + // rotateLeftToolStripMenuItem + // + this.rotateLeftToolStripMenuItem.Enabled = false; + this.rotateLeftToolStripMenuItem.Name = "rotateLeftToolStripMenuItem"; + this.rotateLeftToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.rotateLeftToolStripMenuItem.Text = "Rotate left"; + this.rotateLeftToolStripMenuItem.Click += new System.EventHandler(this.rotateLeftToolStripMenuItem_Click); + // + // rotateRightToolStripMenuItem + // + this.rotateRightToolStripMenuItem.Enabled = false; + this.rotateRightToolStripMenuItem.Name = "rotateRightToolStripMenuItem"; + this.rotateRightToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.rotateRightToolStripMenuItem.Text = "Rotate right"; + this.rotateRightToolStripMenuItem.Click += new System.EventHandler(this.rotateRightToolStripMenuItem_Click); + // + // refreshToolStripMenuItem + // + this.refreshToolStripMenuItem.Enabled = false; + this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem"; + this.refreshToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.refreshToolStripMenuItem.Text = "Reset"; + this.refreshToolStripMenuItem.Click += new System.EventHandler(this.refreshToolStripMenuItem_Click); + // + // helpToolStripMenuItem + // + this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.checkForUpdateToolStripMenuItem, + this.saveDebugInfoToolStripMenuItem, + this.showDebugInfoToolStripMenuItem, + this.toolStripSeparator1, + this.aboutToolStripMenuItem}); + this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20); + this.helpToolStripMenuItem.Text = "Help"; + // + // checkForUpdateToolStripMenuItem + // + this.checkForUpdateToolStripMenuItem.Name = "checkForUpdateToolStripMenuItem"; + this.checkForUpdateToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.checkForUpdateToolStripMenuItem.Text = "Check for update"; + this.checkForUpdateToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdateToolStripMenuItem_Click); + // + // saveDebugInfoToolStripMenuItem + // + this.saveDebugInfoToolStripMenuItem.Enabled = false; + this.saveDebugInfoToolStripMenuItem.Name = "saveDebugInfoToolStripMenuItem"; + this.saveDebugInfoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.saveDebugInfoToolStripMenuItem.Text = "Save design debug info"; + this.saveDebugInfoToolStripMenuItem.Click += new System.EventHandler(this.saveDebugInfoToolStripMenuItem_Click); + // + // showDebugInfoToolStripMenuItem + // + this.showDebugInfoToolStripMenuItem.Enabled = false; + this.showDebugInfoToolStripMenuItem.Name = "showDebugInfoToolStripMenuItem"; + this.showDebugInfoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.showDebugInfoToolStripMenuItem.Text = "Show design debug info"; + this.showDebugInfoToolStripMenuItem.Click += new System.EventHandler(this.showDebugInfoToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(196, 6); + // + // aboutToolStripMenuItem + // + this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.aboutToolStripMenuItem.Text = "About"; + this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); + // + // panel2 + // + this.panel2.AutoScroll = true; + this.panel2.Controls.Add(this.panel1); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(0, 24); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(572, 332); + this.panel2.TabIndex = 10; + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel1, + this.toolStripStatusLabel2}); + this.statusStrip1.Location = new System.Drawing.Point(0, 356); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(572, 22); + this.statusStrip1.TabIndex = 11; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.BackColor = System.Drawing.Color.Transparent; + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); + // + // toolStripStatusLabel2 + // + this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; + this.toolStripStatusLabel2.Size = new System.Drawing.Size(557, 17); + this.toolStripStatusLabel2.Spring = true; + this.toolStripStatusLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // printDocument1 + // + this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage); + // + // printDialog1 + // + this.printDialog1.UseEXDialog = true; + // + // printPreviewDialog1 + // + this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300); + this.printPreviewDialog1.Enabled = true; + this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon"))); + this.printPreviewDialog1.Name = "printPreviewDialog1"; + this.printPreviewDialog1.Visible = false; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // frmMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(572, 378); + this.Controls.Add(this.panel2); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.menuStrip1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.Name = "frmMain"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.panel2.ResumeLayout(false); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem checkForUpdateToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.ToolStripMenuItem saveDebugInfoToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem printToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Drawing.Printing.PrintDocument printDocument1; + private System.Windows.Forms.PrintDialog printDialog1; + private System.Windows.Forms.ToolStripMenuItem printPreviewToolStripMenuItem; + private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem rotateLeftToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem rotateRightToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showDebugInfoToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveAsBitmapToolStripMenuItem; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/embroideryReader/frmMain.cs b/embroideryReader/frmMain.cs index 2097a36..50affaf 100644 --- a/embroideryReader/frmMain.cs +++ b/embroideryReader/frmMain.cs @@ -1,497 +1,497 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace embroideryReader -{ - public partial class frmMain : Form - { - private string[] args; - private Pen drawPen = Pens.Black; - private Bitmap DrawArea; - private PesFile.PesFile design; - private nc_settings.IniFile settings = new nc_settings.IniFile("embroideryreader.ini"); - - - public frmMain() - { - InitializeComponent(); - args = Environment.GetCommandLineArgs(); - } - - private void checkSettings() - { - string updateLoc; - updateLoc = settings.getValue("update location"); - if (String.IsNullOrEmpty(updateLoc) || updateLoc == "http://www.njcrawford.com/embreader/") - { - settings.setValue("update location", "http://www.njcrawford.com/embroidery-reader/"); - } - if (settings.getValue("background color", "enabled") == "yes") - { - if (checkColorFromStrings(settings.getValue("background color", "red"), - settings.getValue("background color", "green"), - settings.getValue("background color", "blue"))) - { - this.BackColor = makeColorFromStrings(settings.getValue("background color", "red"), - settings.getValue("background color", "green"), - settings.getValue("background color", "blue")); - } - else - { - this.BackColor = Color.FromKnownColor(KnownColor.Control); - } - } - else - { - this.BackColor = Color.FromKnownColor(KnownColor.Control); - } - } - - private void Form1_Load(object sender, EventArgs e) - { - checkSettings(); - this.Text = "Embroidery Reader"; - if (args.Length > 1) - { - openFile(args[1]); - } - } - - public static bool checkColorFromStrings(string red, string green, string blue) - { - byte redByte; - byte greenByte; - byte blueByte; - bool retval = false; - if (String.IsNullOrEmpty(red) || String.IsNullOrEmpty(green) || String.IsNullOrEmpty(blue)) - { - retval = false; - } - else - { - try - { - redByte = Convert.ToByte(red); - greenByte = Convert.ToByte(green); - blueByte = Convert.ToByte(blue); - retval = true; - } - catch (Exception ex) - { -#if DEBUG - Console.WriteLine(ex.Message); -#endif - retval = false; - } - } - return retval; - } - - public static Color makeColorFromStrings(string red, string green, string blue) - { - if (checkColorFromStrings(red, green, blue)) - { - return Color.FromArgb(Convert.ToByte(red), Convert.ToByte(green), Convert.ToByte(blue)); - } - else - { - return Color.Red; - } - } - - private void openFile(string filename) - { - if (!System.IO.File.Exists(filename)) - { - return; - } - design = new PesFile.PesFile(filename); - if (design.getStatus() == PesFile.statusEnum.Ready) - { - this.Text = System.IO.Path.GetFileName(filename) + " - Embroidery Reader"; - //sizePanel2(); - - double threadThickness = 5; - if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) - { - threadThickness = 5; - } - - double threshold = 10; - if (!Double.TryParse(settings.getValue("filter stitches threshold"), out threshold)) - { - threshold = 120; - } - DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue("filter stitches") == "true"), (int)threshold); - panel1.Width = design.GetWidth() + (int)(threadThickness * 2); - panel1.Height = design.GetHeight() + (int)(threadThickness * 2); - panel1.Invalidate(); - - if (design.getFormatWarning()) - { - toolStripStatusLabel1.Text = "The format of this file is not completely supported"; - } - else if (design.getColorWarning()) - { - toolStripStatusLabel1.Text = "Colors shown for this design may be inaccurate"; - } - else - { - toolStripStatusLabel1.Text = ""; - } - copyToolStripMenuItem.Enabled = true; - saveDebugInfoToolStripMenuItem.Enabled = true; - printPreviewToolStripMenuItem.Enabled = true; - printToolStripMenuItem.Enabled = true; - rotateLeftToolStripMenuItem.Enabled = true; - rotateRightToolStripMenuItem.Enabled = true; - refreshToolStripMenuItem.Enabled = true; - showDebugInfoToolStripMenuItem.Enabled = true; - saveAsBitmapToolStripMenuItem.Enabled = true; - panel2.Select(); - } - else - { - MessageBox.Show("An error occured while reading the file:" + Environment.NewLine + design.getLastError()); - copyToolStripMenuItem.Enabled = false; - saveDebugInfoToolStripMenuItem.Enabled = false; - printPreviewToolStripMenuItem.Enabled = false; - printToolStripMenuItem.Enabled = false; - rotateLeftToolStripMenuItem.Enabled = false; - rotateRightToolStripMenuItem.Enabled = false; - refreshToolStripMenuItem.Enabled = false; - showDebugInfoToolStripMenuItem.Enabled = false; - saveAsBitmapToolStripMenuItem.Enabled = false; - } - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - string filename; - if (settings.getValue("last open file folder") != null) - { - openFileDialog1.InitialDirectory = settings.getValue("last open file folder"); - } - openFileDialog1.FileName = ""; - openFileDialog1.Filter = "Embroidery Files (*.pes)|*.pes|All Files (*.*)|*.*"; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - filename = openFileDialog1.FileName; - if (!System.IO.File.Exists(filename)) - { - return; - } - else - { - settings.setValue("last open file folder", System.IO.Path.GetDirectoryName(filename)); - openFile(filename); - } - } - } - - private void exitToolStripMenuItem_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void panel1_Paint(object sender, PaintEventArgs e) - { - if (DrawArea != null) - { - e.Graphics.DrawImage(DrawArea, 0, 0); - } - } - - private void aboutToolStripMenuItem_Click(object sender, EventArgs e) - { - MessageBox.Show("EmbroideryReader version " + currentVersion() + ". This program reads and displays embroidery designs from .PES files."); - } - - private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e) - { - nc_Updater.IniFileUpdater updater = new nc_Updater.IniFileUpdater(settings.getValue("update location")); - updater.waitForInfo(); - - // this shouldn't be able to happen, the update location is checked at form load - if(settings.getValue("update location") == null) - { - MessageBox.Show("Cannot check for update because the 'update location'" + Environment.NewLine + "setting has been removed from the settings file."); - } - else if (updater.IsUpdateAvailable()) - { - if (MessageBox.Show("Version " + updater.VersionAvailable() + " is available." + Environment.NewLine + "You have version " + currentVersion() + ". Would you like to go to the Embroidery Reader website to download it?", "New version available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - try - { - System.Diagnostics.Process.Start(updater.getMoreInfoURL()); - } - catch (Exception ex) - { - MessageBox.Show("An error occured while trying to open the webpage:" + Environment.NewLine + ex.ToString()); - } - //if (!updater.InstallUpdate()) - //{ - // MessageBox.Show("Update failed, error message: " + updater.GetLastError()); - //} - //else - //{ - // Environment.Exit(0); - //} - } - } - else if (updater.GetLastError() != "") - { - MessageBox.Show("Encountered an error while checking for updates: " + updater.GetLastError()); - } - else - { - MessageBox.Show("No updates are available right now." + Environment.NewLine + "(Latest version is " + updater.VersionAvailable() + ", you have version " + currentVersion() + ")"); - } - - } - - private void Form1_FormClosing(object sender, FormClosingEventArgs e) - { - settings.save(); - } - - private string currentVersion() - { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } - - private void saveDebugInfoToolStripMenuItem_Click(object sender, EventArgs e) - { - if (design != null) - { - try - { - design.saveDebugInfo(); - } - catch (Exception ex) - { - MessageBox.Show("There was an error while saving debug info:" + Environment.NewLine + ex.ToString()); - } - } - else - { - MessageBox.Show("No design loaded."); - } - } - - private void preferencesToolStripMenuItem_Click(object sender, EventArgs e) - { - frmSettingsDialog tempForm = new frmSettingsDialog(); - tempForm.settings = settings; - if (tempForm.ShowDialog() == DialogResult.OK) - { - settings = tempForm.settings; - checkSettings(); - } - } - - private void printToolStripMenuItem_Click(object sender, EventArgs e) - { - if (printDialog1.ShowDialog() == DialogResult.OK) - { - printDocument1.Print(); - } - } - - private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) - { - if (DrawArea != null) - { - float dpiX = 100; - float dpiY = 100; - double mmPerInch = 0.03937007874015748031496062992126; - e.Graphics.ScaleTransform((float)(dpiX * mmPerInch * 0.1), (float)(dpiY * mmPerInch * 0.1)); - - e.Graphics.DrawImage(DrawArea, 30, 30); - } - } - - private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e) - { - printPreviewDialog1.Document = printDocument1; - printPreviewDialog1.ShowDialog(); - } - - private void copyToolStripMenuItem_Click(object sender, EventArgs e) - { - if (DrawArea != null) - { - Clipboard.Clear(); - Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - Graphics tempGraph = Graphics.FromImage(temp); - tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); - tempGraph.DrawImageUnscaled(DrawArea, 0, 0); - tempGraph.Dispose(); - Clipboard.SetImage(temp); - } - } - - private void refreshToolStripMenuItem_Click(object sender, EventArgs e) - { - if (design != null && design.getStatus() == PesFile.statusEnum.Ready) - { - double threadThickness = 5; - if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) - { - threadThickness = 5; - } - int threshold = Convert.ToInt32(settings.getValue("filter stitches threshold")); - DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue("filter stitches") == "true"), (int)threshold); - panel1.Width = design.GetWidth() + (int)(threadThickness * 2); - panel1.Height = design.GetHeight() + (int)(threadThickness * 2); - panel1.Invalidate(); - - if (design.getClassWarning()) - { - toolStripStatusLabel1.Text = "This file contains a class that is not yet supported"; - } - else if (design.getFormatWarning()) - { - toolStripStatusLabel1.Text = "The format of this file is not completely supported"; - } - else if (design.getColorWarning()) - { - toolStripStatusLabel1.Text = "Colors shown for this design may be inaccurate"; - } - else - { - toolStripStatusLabel1.Text = ""; - } - } - } - - private void rotateLeftToolStripMenuItem_Click(object sender, EventArgs e) - { - Bitmap temp = new Bitmap(DrawArea.Height, DrawArea.Width); - Graphics g = Graphics.FromImage(temp); - g.RotateTransform(270.0f); - g.DrawImage(DrawArea, -DrawArea.Width, 0); - g.Dispose(); - DrawArea = temp; - int temp2 = panel1.Width; - panel1.Width = panel1.Height; - panel1.Height = temp2; - panel1.Invalidate(); - } - - private void rotateRightToolStripMenuItem_Click(object sender, EventArgs e) - { - Bitmap temp = new Bitmap(DrawArea.Height, DrawArea.Width); - Graphics g = Graphics.FromImage(temp); - g.RotateTransform(90.0f); - g.DrawImage(DrawArea, 0, -DrawArea.Height); - g.Dispose(); - DrawArea = temp; - int temp2 = panel1.Width; - panel1.Width = panel1.Height; - panel1.Height = temp2; - panel1.Invalidate(); - } - - private void showDebugInfoToolStripMenuItem_Click(object sender, EventArgs e) - { - if (design != null) - { - try - { - frmTextbox theform = new frmTextbox(); - theform.showText(design.getDebugInfo()); - } - catch (Exception ex) - { - MessageBox.Show("There was an error while saving debug info:" + Environment.NewLine + ex.ToString()); - } - } - else - { - MessageBox.Show("No design loaded."); - } - } - - private void saveAsBitmapToolStripMenuItem_Click(object sender, EventArgs e) - { - if (DrawArea != null) - { - Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - - Graphics tempGraph = Graphics.FromImage(temp); - tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); - tempGraph.DrawImageUnscaled(DrawArea, 0, 0); - tempGraph.Dispose(); - saveFileDialog1.FileName = ""; - saveFileDialog1.Filter = "Bitmap (*.bmp)|*.bmp|PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|All Files (*.*)|*.*"; - if (settings.getValue("last save image location") != null) - { - saveFileDialog1.InitialDirectory = settings.getValue("last save image location"); - } - if (saveFileDialog1.ShowDialog() == DialogResult.OK) - { - string filename = ""; - filename = saveFileDialog1.FileName; - System.Drawing.Imaging.ImageFormat format; - switch (System.IO.Path.GetExtension(filename).ToLower()) - { - case ".bmp": format = System.Drawing.Imaging.ImageFormat.Bmp; break; - case ".png": format = System.Drawing.Imaging.ImageFormat.Png; break; - case ".jpg": format = System.Drawing.Imaging.ImageFormat.Jpeg; break; - case ".gif": format = System.Drawing.Imaging.ImageFormat.Gif; break; - case ".tif": format = System.Drawing.Imaging.ImageFormat.Tiff; break; - default: format = System.Drawing.Imaging.ImageFormat.Bmp; break; - } - temp.Save(filename, format); - showStatus("Image saved", 5000); - settings.setValue("last save image location", System.IO.Path.GetDirectoryName(filename)); - } - } - } - - private void showStatus(string text, int msec) - { - toolStripStatusLabel2.Text = text; - timer1.Interval = msec; - timer1.Enabled = true; - } - - private void timer1_Tick(object sender, EventArgs e) - { - toolStripStatusLabel2.Text = ""; - } - } -} +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace embroideryReader +{ + public partial class frmMain : Form + { + private string[] args; + private Pen drawPen = Pens.Black; + private Bitmap DrawArea; + private PesFile.PesFile design; + private nc_settings.IniFile settings = new nc_settings.IniFile("embroideryreader.ini"); + + + public frmMain() + { + InitializeComponent(); + args = Environment.GetCommandLineArgs(); + } + + private void checkSettings() + { + string updateLoc; + updateLoc = settings.getValue("update location"); + if (String.IsNullOrEmpty(updateLoc) || updateLoc == "http://www.njcrawford.com/embreader/") + { + settings.setValue("update location", "http://www.njcrawford.com/embroidery-reader/"); + } + if (settings.getValue("background color", "enabled") == "yes") + { + if (checkColorFromStrings(settings.getValue("background color", "red"), + settings.getValue("background color", "green"), + settings.getValue("background color", "blue"))) + { + this.BackColor = makeColorFromStrings(settings.getValue("background color", "red"), + settings.getValue("background color", "green"), + settings.getValue("background color", "blue")); + } + else + { + this.BackColor = Color.FromKnownColor(KnownColor.Control); + } + } + else + { + this.BackColor = Color.FromKnownColor(KnownColor.Control); + } + } + + private void Form1_Load(object sender, EventArgs e) + { + checkSettings(); + this.Text = "Embroidery Reader"; + if (args.Length > 1) + { + openFile(args[1]); + } + } + + public static bool checkColorFromStrings(string red, string green, string blue) + { + byte redByte; + byte greenByte; + byte blueByte; + bool retval = false; + if (String.IsNullOrEmpty(red) || String.IsNullOrEmpty(green) || String.IsNullOrEmpty(blue)) + { + retval = false; + } + else + { + try + { + redByte = Convert.ToByte(red); + greenByte = Convert.ToByte(green); + blueByte = Convert.ToByte(blue); + retval = true; + } + catch (Exception ex) + { +#if DEBUG + Console.WriteLine(ex.Message); +#endif + retval = false; + } + } + return retval; + } + + public static Color makeColorFromStrings(string red, string green, string blue) + { + if (checkColorFromStrings(red, green, blue)) + { + return Color.FromArgb(Convert.ToByte(red), Convert.ToByte(green), Convert.ToByte(blue)); + } + else + { + return Color.Red; + } + } + + private void openFile(string filename) + { + if (!System.IO.File.Exists(filename)) + { + return; + } + design = new PesFile.PesFile(filename); + if (design.getStatus() == PesFile.statusEnum.Ready) + { + this.Text = System.IO.Path.GetFileName(filename) + " - Embroidery Reader"; + //sizePanel2(); + + double threadThickness = 5; + if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) + { + threadThickness = 5; + } + + double threshold = 10; + if (!Double.TryParse(settings.getValue("filter stitches threshold"), out threshold)) + { + threshold = 120; + } + DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue("filter stitches") == "true"), (int)threshold); + panel1.Width = design.GetWidth() + (int)(threadThickness * 2); + panel1.Height = design.GetHeight() + (int)(threadThickness * 2); + panel1.Invalidate(); + + if (design.getFormatWarning()) + { + toolStripStatusLabel1.Text = "The format of this file is not completely supported"; + } + else if (design.getColorWarning()) + { + toolStripStatusLabel1.Text = "Colors shown for this design may be inaccurate"; + } + else + { + toolStripStatusLabel1.Text = ""; + } + copyToolStripMenuItem.Enabled = true; + saveDebugInfoToolStripMenuItem.Enabled = true; + printPreviewToolStripMenuItem.Enabled = true; + printToolStripMenuItem.Enabled = true; + rotateLeftToolStripMenuItem.Enabled = true; + rotateRightToolStripMenuItem.Enabled = true; + refreshToolStripMenuItem.Enabled = true; + showDebugInfoToolStripMenuItem.Enabled = true; + saveAsBitmapToolStripMenuItem.Enabled = true; + panel2.Select(); + } + else + { + MessageBox.Show("An error occured while reading the file:" + Environment.NewLine + design.getLastError()); + copyToolStripMenuItem.Enabled = false; + saveDebugInfoToolStripMenuItem.Enabled = false; + printPreviewToolStripMenuItem.Enabled = false; + printToolStripMenuItem.Enabled = false; + rotateLeftToolStripMenuItem.Enabled = false; + rotateRightToolStripMenuItem.Enabled = false; + refreshToolStripMenuItem.Enabled = false; + showDebugInfoToolStripMenuItem.Enabled = false; + saveAsBitmapToolStripMenuItem.Enabled = false; + } + } + + private void openToolStripMenuItem_Click(object sender, EventArgs e) + { + string filename; + if (settings.getValue("last open file folder") != null) + { + openFileDialog1.InitialDirectory = settings.getValue("last open file folder"); + } + openFileDialog1.FileName = ""; + openFileDialog1.Filter = "Embroidery Files (*.pes)|*.pes|All Files (*.*)|*.*"; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + filename = openFileDialog1.FileName; + if (!System.IO.File.Exists(filename)) + { + return; + } + else + { + settings.setValue("last open file folder", System.IO.Path.GetDirectoryName(filename)); + openFile(filename); + } + } + } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void panel1_Paint(object sender, PaintEventArgs e) + { + if (DrawArea != null) + { + e.Graphics.DrawImage(DrawArea, 0, 0); + } + } + + private void aboutToolStripMenuItem_Click(object sender, EventArgs e) + { + MessageBox.Show("EmbroideryReader version " + currentVersion() + ". This program reads and displays embroidery designs from .PES files."); + } + + private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e) + { + nc_Updater.IniFileUpdater updater = new nc_Updater.IniFileUpdater(settings.getValue("update location")); + updater.waitForInfo(); + + // this shouldn't be able to happen, the update location is checked at form load + if(settings.getValue("update location") == null) + { + MessageBox.Show("Cannot check for update because the 'update location'" + Environment.NewLine + "setting has been removed from the settings file."); + } + else if (updater.IsUpdateAvailable()) + { + if (MessageBox.Show("Version " + updater.VersionAvailable() + " is available." + Environment.NewLine + "You have version " + currentVersion() + ". Would you like to go to the Embroidery Reader website to download it?", "New version available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + System.Diagnostics.Process.Start(updater.getMoreInfoURL()); + } + catch (Exception ex) + { + MessageBox.Show("An error occured while trying to open the webpage:" + Environment.NewLine + ex.ToString()); + } + //if (!updater.InstallUpdate()) + //{ + // MessageBox.Show("Update failed, error message: " + updater.GetLastError()); + //} + //else + //{ + // Environment.Exit(0); + //} + } + } + else if (updater.GetLastError() != "") + { + MessageBox.Show("Encountered an error while checking for updates: " + updater.GetLastError()); + } + else + { + MessageBox.Show("No updates are available right now." + Environment.NewLine + "(Latest version is " + updater.VersionAvailable() + ", you have version " + currentVersion() + ")"); + } + + } + + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + settings.save(); + } + + private string currentVersion() + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + + private void saveDebugInfoToolStripMenuItem_Click(object sender, EventArgs e) + { + if (design != null) + { + try + { + design.saveDebugInfo(); + } + catch (Exception ex) + { + MessageBox.Show("There was an error while saving debug info:" + Environment.NewLine + ex.ToString()); + } + } + else + { + MessageBox.Show("No design loaded."); + } + } + + private void preferencesToolStripMenuItem_Click(object sender, EventArgs e) + { + frmSettingsDialog tempForm = new frmSettingsDialog(); + tempForm.settings = settings; + if (tempForm.ShowDialog() == DialogResult.OK) + { + settings = tempForm.settings; + checkSettings(); + } + } + + private void printToolStripMenuItem_Click(object sender, EventArgs e) + { + if (printDialog1.ShowDialog() == DialogResult.OK) + { + printDocument1.Print(); + } + } + + private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) + { + if (DrawArea != null) + { + float dpiX = 100; + float dpiY = 100; + double mmPerInch = 0.03937007874015748031496062992126; + e.Graphics.ScaleTransform((float)(dpiX * mmPerInch * 0.1), (float)(dpiY * mmPerInch * 0.1)); + + e.Graphics.DrawImage(DrawArea, 30, 30); + } + } + + private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e) + { + printPreviewDialog1.Document = printDocument1; + printPreviewDialog1.ShowDialog(); + } + + private void copyToolStripMenuItem_Click(object sender, EventArgs e) + { + if (DrawArea != null) + { + Clipboard.Clear(); + Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + Graphics tempGraph = Graphics.FromImage(temp); + tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); + tempGraph.DrawImageUnscaled(DrawArea, 0, 0); + tempGraph.Dispose(); + Clipboard.SetImage(temp); + } + } + + private void refreshToolStripMenuItem_Click(object sender, EventArgs e) + { + if (design != null && design.getStatus() == PesFile.statusEnum.Ready) + { + double threadThickness = 5; + if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) + { + threadThickness = 5; + } + int threshold = Convert.ToInt32(settings.getValue("filter stitches threshold")); + DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue("filter stitches") == "true"), (int)threshold); + panel1.Width = design.GetWidth() + (int)(threadThickness * 2); + panel1.Height = design.GetHeight() + (int)(threadThickness * 2); + panel1.Invalidate(); + + if (design.getClassWarning()) + { + toolStripStatusLabel1.Text = "This file contains a class that is not yet supported"; + } + else if (design.getFormatWarning()) + { + toolStripStatusLabel1.Text = "The format of this file is not completely supported"; + } + else if (design.getColorWarning()) + { + toolStripStatusLabel1.Text = "Colors shown for this design may be inaccurate"; + } + else + { + toolStripStatusLabel1.Text = ""; + } + } + } + + private void rotateLeftToolStripMenuItem_Click(object sender, EventArgs e) + { + Bitmap temp = new Bitmap(DrawArea.Height, DrawArea.Width); + Graphics g = Graphics.FromImage(temp); + g.RotateTransform(270.0f); + g.DrawImage(DrawArea, -DrawArea.Width, 0); + g.Dispose(); + DrawArea = temp; + int temp2 = panel1.Width; + panel1.Width = panel1.Height; + panel1.Height = temp2; + panel1.Invalidate(); + } + + private void rotateRightToolStripMenuItem_Click(object sender, EventArgs e) + { + Bitmap temp = new Bitmap(DrawArea.Height, DrawArea.Width); + Graphics g = Graphics.FromImage(temp); + g.RotateTransform(90.0f); + g.DrawImage(DrawArea, 0, -DrawArea.Height); + g.Dispose(); + DrawArea = temp; + int temp2 = panel1.Width; + panel1.Width = panel1.Height; + panel1.Height = temp2; + panel1.Invalidate(); + } + + private void showDebugInfoToolStripMenuItem_Click(object sender, EventArgs e) + { + if (design != null) + { + try + { + frmTextbox theform = new frmTextbox(); + theform.showText(design.getDebugInfo()); + } + catch (Exception ex) + { + MessageBox.Show("There was an error while saving debug info:" + Environment.NewLine + ex.ToString()); + } + } + else + { + MessageBox.Show("No design loaded."); + } + } + + private void saveAsBitmapToolStripMenuItem_Click(object sender, EventArgs e) + { + if (DrawArea != null) + { + Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + + Graphics tempGraph = Graphics.FromImage(temp); + tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height); + tempGraph.DrawImageUnscaled(DrawArea, 0, 0); + tempGraph.Dispose(); + saveFileDialog1.FileName = ""; + saveFileDialog1.Filter = "Bitmap (*.bmp)|*.bmp|PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|All Files (*.*)|*.*"; + if (settings.getValue("last save image location") != null) + { + saveFileDialog1.InitialDirectory = settings.getValue("last save image location"); + } + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + string filename = ""; + filename = saveFileDialog1.FileName; + System.Drawing.Imaging.ImageFormat format; + switch (System.IO.Path.GetExtension(filename).ToLower()) + { + case ".bmp": format = System.Drawing.Imaging.ImageFormat.Bmp; break; + case ".png": format = System.Drawing.Imaging.ImageFormat.Png; break; + case ".jpg": format = System.Drawing.Imaging.ImageFormat.Jpeg; break; + case ".gif": format = System.Drawing.Imaging.ImageFormat.Gif; break; + case ".tif": format = System.Drawing.Imaging.ImageFormat.Tiff; break; + default: format = System.Drawing.Imaging.ImageFormat.Bmp; break; + } + temp.Save(filename, format); + showStatus("Image saved", 5000); + settings.setValue("last save image location", System.IO.Path.GetDirectoryName(filename)); + } + } + } + + private void showStatus(string text, int msec) + { + toolStripStatusLabel2.Text = text; + timer1.Interval = msec; + timer1.Enabled = true; + } + + private void timer1_Tick(object sender, EventArgs e) + { + toolStripStatusLabel2.Text = ""; + } + } +} diff --git a/embroideryReader/frmSettingsDialog.Designer.cs b/embroideryReader/frmSettingsDialog.Designer.cs index 907c56d..0ead1a3 100644 --- a/embroideryReader/frmSettingsDialog.Designer.cs +++ b/embroideryReader/frmSettingsDialog.Designer.cs @@ -1,257 +1,257 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -namespace embroideryReader -{ - partial class frmSettingsDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.btnColor = new System.Windows.Forms.Button(); - this.lblColor = new System.Windows.Forms.Label(); - this.btnResetColor = new System.Windows.Forms.Button(); - this.btnOK = new System.Windows.Forms.Button(); - this.btnCancel = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.txtThreadThickness = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.chkUglyStitches = new System.Windows.Forms.CheckBox(); - this.txtThreshold = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // btnColor - // - this.btnColor.Location = new System.Drawing.Point(171, 16); - this.btnColor.Name = "btnColor"; - this.btnColor.Size = new System.Drawing.Size(75, 23); - this.btnColor.TabIndex = 0; - this.btnColor.Text = "Pick Color..."; - this.btnColor.UseVisualStyleBackColor = true; - this.btnColor.Click += new System.EventHandler(this.btnColor_Click); - // - // lblColor - // - this.lblColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lblColor.Location = new System.Drawing.Point(6, 16); - this.lblColor.Name = "lblColor"; - this.lblColor.Size = new System.Drawing.Size(130, 52); - this.lblColor.TabIndex = 1; - this.lblColor.Text = "Background Color"; - this.lblColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnResetColor - // - this.btnResetColor.Location = new System.Drawing.Point(171, 45); - this.btnResetColor.Name = "btnResetColor"; - this.btnResetColor.Size = new System.Drawing.Size(75, 23); - this.btnResetColor.TabIndex = 2; - this.btnResetColor.Text = "Reset Color"; - this.btnResetColor.UseVisualStyleBackColor = true; - this.btnResetColor.Click += new System.EventHandler(this.btnResetColor_Click); - // - // btnOK - // - this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOK.Location = new System.Drawing.Point(171, 190); - this.btnOK.Name = "btnOK"; - this.btnOK.Size = new System.Drawing.Size(75, 23); - this.btnOK.TabIndex = 3; - this.btnOK.Text = "OK"; - this.btnOK.UseVisualStyleBackColor = true; - this.btnOK.Click += new System.EventHandler(this.btnOK_Click); - // - // btnCancel - // - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(252, 190); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 4; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(92, 13); - this.label1.TabIndex = 5; - this.label1.Text = "Thread thickness:"; - // - // txtThreadThickness - // - this.txtThreadThickness.Location = new System.Drawing.Point(104, 13); - this.txtThreadThickness.Name = "txtThreadThickness"; - this.txtThreadThickness.Size = new System.Drawing.Size(32, 20); - this.txtThreadThickness.TabIndex = 6; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(142, 16); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(33, 13); - this.label2.TabIndex = 7; - this.label2.Text = "pixels"; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.lblColor); - this.groupBox1.Controls.Add(this.btnColor); - this.groupBox1.Controls.Add(this.btnResetColor); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(315, 79); - this.groupBox1.TabIndex = 8; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Background"; - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.label4); - this.groupBox2.Controls.Add(this.label3); - this.groupBox2.Controls.Add(this.txtThreshold); - this.groupBox2.Controls.Add(this.chkUglyStitches); - this.groupBox2.Controls.Add(this.label1); - this.groupBox2.Controls.Add(this.txtThreadThickness); - this.groupBox2.Controls.Add(this.label2); - this.groupBox2.Location = new System.Drawing.Point(12, 97); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(315, 87); - this.groupBox2.TabIndex = 3; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Stitch drawing"; - // - // chkUglyStitches - // - this.chkUglyStitches.AutoSize = true; - this.chkUglyStitches.Location = new System.Drawing.Point(9, 38); - this.chkUglyStitches.Name = "chkUglyStitches"; - this.chkUglyStitches.Size = new System.Drawing.Size(131, 17); - this.chkUglyStitches.TabIndex = 8; - this.chkUglyStitches.Text = "Remove \'ugly\' stitches"; - this.chkUglyStitches.UseVisualStyleBackColor = true; - // - // txtThreshold - // - this.txtThreshold.Location = new System.Drawing.Point(130, 55); - this.txtThreshold.Name = "txtThreshold"; - this.txtThreshold.Size = new System.Drawing.Size(32, 20); - this.txtThreshold.TabIndex = 9; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(168, 58); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(33, 13); - this.label3.TabIndex = 10; - this.label3.Text = "pixels"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(57, 58); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(67, 13); - this.label4.TabIndex = 11; - this.label4.Text = "Ugly Length:"; - // - // frmSettingsDialog - // - this.AcceptButton = this.btnOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(339, 225); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.btnOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "frmSettingsDialog"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "Embroidery Reader Settings"; - this.groupBox1.ResumeLayout(false); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.Button btnColor; - private System.Windows.Forms.Label lblColor; - private System.Windows.Forms.Button btnResetColor; - private System.Windows.Forms.Button btnOK; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtThreadThickness; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox txtThreshold; - private System.Windows.Forms.CheckBox chkUglyStitches; - private System.Windows.Forms.Label label4; - } +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +namespace embroideryReader +{ + partial class frmSettingsDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.btnColor = new System.Windows.Forms.Button(); + this.lblColor = new System.Windows.Forms.Label(); + this.btnResetColor = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.txtThreadThickness = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.chkUglyStitches = new System.Windows.Forms.CheckBox(); + this.txtThreshold = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // btnColor + // + this.btnColor.Location = new System.Drawing.Point(171, 16); + this.btnColor.Name = "btnColor"; + this.btnColor.Size = new System.Drawing.Size(75, 23); + this.btnColor.TabIndex = 0; + this.btnColor.Text = "Pick Color..."; + this.btnColor.UseVisualStyleBackColor = true; + this.btnColor.Click += new System.EventHandler(this.btnColor_Click); + // + // lblColor + // + this.lblColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblColor.Location = new System.Drawing.Point(6, 16); + this.lblColor.Name = "lblColor"; + this.lblColor.Size = new System.Drawing.Size(130, 52); + this.lblColor.TabIndex = 1; + this.lblColor.Text = "Background Color"; + this.lblColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // btnResetColor + // + this.btnResetColor.Location = new System.Drawing.Point(171, 45); + this.btnResetColor.Name = "btnResetColor"; + this.btnResetColor.Size = new System.Drawing.Size(75, 23); + this.btnResetColor.TabIndex = 2; + this.btnResetColor.Text = "Reset Color"; + this.btnResetColor.UseVisualStyleBackColor = true; + this.btnResetColor.Click += new System.EventHandler(this.btnResetColor_Click); + // + // btnOK + // + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(171, 190); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 3; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(252, 190); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(92, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Thread thickness:"; + // + // txtThreadThickness + // + this.txtThreadThickness.Location = new System.Drawing.Point(104, 13); + this.txtThreadThickness.Name = "txtThreadThickness"; + this.txtThreadThickness.Size = new System.Drawing.Size(32, 20); + this.txtThreadThickness.TabIndex = 6; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(142, 16); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(33, 13); + this.label2.TabIndex = 7; + this.label2.Text = "pixels"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.lblColor); + this.groupBox1.Controls.Add(this.btnColor); + this.groupBox1.Controls.Add(this.btnResetColor); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(315, 79); + this.groupBox1.TabIndex = 8; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Background"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Controls.Add(this.txtThreshold); + this.groupBox2.Controls.Add(this.chkUglyStitches); + this.groupBox2.Controls.Add(this.label1); + this.groupBox2.Controls.Add(this.txtThreadThickness); + this.groupBox2.Controls.Add(this.label2); + this.groupBox2.Location = new System.Drawing.Point(12, 97); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(315, 87); + this.groupBox2.TabIndex = 3; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Stitch drawing"; + // + // chkUglyStitches + // + this.chkUglyStitches.AutoSize = true; + this.chkUglyStitches.Location = new System.Drawing.Point(9, 38); + this.chkUglyStitches.Name = "chkUglyStitches"; + this.chkUglyStitches.Size = new System.Drawing.Size(131, 17); + this.chkUglyStitches.TabIndex = 8; + this.chkUglyStitches.Text = "Remove \'ugly\' stitches"; + this.chkUglyStitches.UseVisualStyleBackColor = true; + // + // txtThreshold + // + this.txtThreshold.Location = new System.Drawing.Point(130, 55); + this.txtThreshold.Name = "txtThreshold"; + this.txtThreshold.Size = new System.Drawing.Size(32, 20); + this.txtThreshold.TabIndex = 9; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(168, 58); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(33, 13); + this.label3.TabIndex = 10; + this.label3.Text = "pixels"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(57, 58); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(67, 13); + this.label4.TabIndex = 11; + this.label4.Text = "Ugly Length:"; + // + // frmSettingsDialog + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(339, 225); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmSettingsDialog"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "Embroidery Reader Settings"; + this.groupBox1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Button btnColor; + private System.Windows.Forms.Label lblColor; + private System.Windows.Forms.Button btnResetColor; + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtThreadThickness; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtThreshold; + private System.Windows.Forms.CheckBox chkUglyStitches; + private System.Windows.Forms.Label label4; + } } \ No newline at end of file diff --git a/embroideryReader/frmSettingsDialog.cs b/embroideryReader/frmSettingsDialog.cs index 95d8107..8805483 100644 --- a/embroideryReader/frmSettingsDialog.cs +++ b/embroideryReader/frmSettingsDialog.cs @@ -1,175 +1,175 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace embroideryReader -{ - public partial class frmSettingsDialog : Form - { - private bool colorChanged = false; - private nc_settings.IniFile _settings; - public nc_settings.IniFile settings - { - get - { - return _settings; - } - set - { - _settings = value; - if (settings.getValue("background color", "enabled") == "yes" && - frmMain.checkColorFromStrings( - settings.getValue("background color", "red"), - settings.getValue("background color", "green"), - settings.getValue("background color", "blue"))) - { - lblColor.BackColor = frmMain.makeColorFromStrings( - settings.getValue("background color", "red"), - settings.getValue("background color", "green"), - settings.getValue("background color", "blue")); - } - if (settings.getValue("thread thickness") != null) - { - double threadThickness = 1; - if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) - { - threadThickness = 5; - } - - if (threadThickness < 1) - { - threadThickness = 1; - } - txtThreadThickness.Text = threadThickness.ToString(); - } - else - { - txtThreadThickness.Text = "5"; - } - - if (settings.getValue("filter stitches") == "true") - { - chkUglyStitches.Checked = true; - } - else - { - chkUglyStitches.Checked = false; - } - - if (settings.getValue("filter stitches threshold") != null) - { - txtThreshold.Text= settings.getValue("filter stitches threshold"); - } - else - { - txtThreshold.Text = "120"; - } - } - } - - public frmSettingsDialog() - { - InitializeComponent(); - } - - private void btnCancel_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnColor_Click(object sender, EventArgs e) - { - colorDialog1.Color = lblColor.BackColor; - if (colorDialog1.ShowDialog() == DialogResult.OK && lblColor.BackColor != colorDialog1.Color) - { - lblColor.BackColor = colorDialog1.Color; - colorChanged = true; - } - } - - private void btnResetColor_Click(object sender, EventArgs e) - { - if (lblColor.BackColor != Color.FromKnownColor(KnownColor.Control)) - { - lblColor.BackColor = Color.FromKnownColor(KnownColor.Control); - colorChanged = true; - } - } - - private void btnOK_Click(object sender, EventArgs e) - { - if (colorChanged) - { - if (lblColor.BackColor != Color.FromKnownColor(KnownColor.Control)) - { - settings.setValue("background color", "enabled", "yes"); - settings.setValue("background color", "red", lblColor.BackColor.R.ToString()); - settings.setValue("background color", "green", lblColor.BackColor.G.ToString()); - settings.setValue("background color", "blue", lblColor.BackColor.B.ToString()); - - } - else - { - settings.setValue("background color", "enabled", "no"); - } - } - double threadThickness = 5; - if (Double.TryParse(txtThreadThickness.Text, out threadThickness)) - { - if (threadThickness < 1) - { - threadThickness = 1; - } - settings.setValue("thread thickness", threadThickness.ToString()); - } - - if (chkUglyStitches.Checked) - { - settings.setValue("filter stitches", "true"); - } - else - { - settings.setValue("filter stitches", "false"); - } - - double threshold = 120; - if (Double.TryParse(txtThreshold.Text, out threshold)) - { - if (threshold < 10) - { - threshold = 10; - } - settings.setValue("filter stitches threshold", threshold.ToString()); - } - } - } +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace embroideryReader +{ + public partial class frmSettingsDialog : Form + { + private bool colorChanged = false; + private nc_settings.IniFile _settings; + public nc_settings.IniFile settings + { + get + { + return _settings; + } + set + { + _settings = value; + if (settings.getValue("background color", "enabled") == "yes" && + frmMain.checkColorFromStrings( + settings.getValue("background color", "red"), + settings.getValue("background color", "green"), + settings.getValue("background color", "blue"))) + { + lblColor.BackColor = frmMain.makeColorFromStrings( + settings.getValue("background color", "red"), + settings.getValue("background color", "green"), + settings.getValue("background color", "blue")); + } + if (settings.getValue("thread thickness") != null) + { + double threadThickness = 1; + if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness)) + { + threadThickness = 5; + } + + if (threadThickness < 1) + { + threadThickness = 1; + } + txtThreadThickness.Text = threadThickness.ToString(); + } + else + { + txtThreadThickness.Text = "5"; + } + + if (settings.getValue("filter stitches") == "true") + { + chkUglyStitches.Checked = true; + } + else + { + chkUglyStitches.Checked = false; + } + + if (settings.getValue("filter stitches threshold") != null) + { + txtThreshold.Text= settings.getValue("filter stitches threshold"); + } + else + { + txtThreshold.Text = "120"; + } + } + } + + public frmSettingsDialog() + { + InitializeComponent(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnColor_Click(object sender, EventArgs e) + { + colorDialog1.Color = lblColor.BackColor; + if (colorDialog1.ShowDialog() == DialogResult.OK && lblColor.BackColor != colorDialog1.Color) + { + lblColor.BackColor = colorDialog1.Color; + colorChanged = true; + } + } + + private void btnResetColor_Click(object sender, EventArgs e) + { + if (lblColor.BackColor != Color.FromKnownColor(KnownColor.Control)) + { + lblColor.BackColor = Color.FromKnownColor(KnownColor.Control); + colorChanged = true; + } + } + + private void btnOK_Click(object sender, EventArgs e) + { + if (colorChanged) + { + if (lblColor.BackColor != Color.FromKnownColor(KnownColor.Control)) + { + settings.setValue("background color", "enabled", "yes"); + settings.setValue("background color", "red", lblColor.BackColor.R.ToString()); + settings.setValue("background color", "green", lblColor.BackColor.G.ToString()); + settings.setValue("background color", "blue", lblColor.BackColor.B.ToString()); + + } + else + { + settings.setValue("background color", "enabled", "no"); + } + } + double threadThickness = 5; + if (Double.TryParse(txtThreadThickness.Text, out threadThickness)) + { + if (threadThickness < 1) + { + threadThickness = 1; + } + settings.setValue("thread thickness", threadThickness.ToString()); + } + + if (chkUglyStitches.Checked) + { + settings.setValue("filter stitches", "true"); + } + else + { + settings.setValue("filter stitches", "false"); + } + + double threshold = 120; + if (Double.TryParse(txtThreshold.Text, out threshold)) + { + if (threshold < 10) + { + threshold = 10; + } + settings.setValue("filter stitches threshold", threshold.ToString()); + } + } + } } \ No newline at end of file diff --git a/embroideryReader/frmTextbox.Designer.cs b/embroideryReader/frmTextbox.Designer.cs index 3371ddb..e5385c8 100644 --- a/embroideryReader/frmTextbox.Designer.cs +++ b/embroideryReader/frmTextbox.Designer.cs @@ -1,83 +1,83 @@ -/* -Embridery Reader - an application to view .pes embroidery designs - -Copyright (C) 2008 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.html. -*/ - - -namespace embroideryReader -{ - partial class frmTextbox - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBox1 = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox1.Location = new System.Drawing.Point(0, 0); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox1.Size = new System.Drawing.Size(305, 351); - this.textBox1.TabIndex = 0; - // - // frmTextbox - // - this.ClientSize = new System.Drawing.Size(305, 351); - this.Controls.Add(this.textBox1); - this.Name = "frmTextbox"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBox1; - } +/* +Embridery Reader - an application to view .pes embroidery designs + +Copyright (C) 2008 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.html. +*/ + + +namespace embroideryReader +{ + partial class frmTextbox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Location = new System.Drawing.Point(0, 0); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBox1.Size = new System.Drawing.Size(305, 351); + this.textBox1.TabIndex = 0; + // + // frmTextbox + // + this.ClientSize = new System.Drawing.Size(305, 351); + this.Controls.Add(this.textBox1); + this.Name = "frmTextbox"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + } } \ No newline at end of file diff --git a/embroideryReader/frmTextbox.cs b/embroideryReader/frmTextbox.cs index c166172..867a509 100644 --- a/embroideryReader/frmTextbox.cs +++ b/embroideryReader/frmTextbox.cs @@ -1,49 +1,49 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace embroideryReader -{ - public partial class frmTextbox : Form - { - public frmTextbox() - { - InitializeComponent(); - } - - public void showText(string text) - { - textBox1.Text = text; - this.Show(); - } - } +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace embroideryReader +{ + public partial class frmTextbox : Form + { + public frmTextbox() + { + InitializeComponent(); + } + + public void showText(string text) + { + textBox1.Text = text; + this.Show(); + } + } } \ No newline at end of file diff --git a/embroideryTester/Form1.Designer.cs b/embroideryTester/Form1.Designer.cs index e90ad1b..b54961c 100644 --- a/embroideryTester/Form1.Designer.cs +++ b/embroideryTester/Form1.Designer.cs @@ -1,95 +1,95 @@ -namespace embroideryTester -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBox1 = new System.Windows.Forms.TextBox(); - this.btnOpen = new System.Windows.Forms.Button(); - this.btnNext = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(12, 12); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBox1.Size = new System.Drawing.Size(100, 249); - this.textBox1.TabIndex = 0; - // - // btnOpen - // - this.btnOpen.Location = new System.Drawing.Point(174, 10); - this.btnOpen.Name = "btnOpen"; - this.btnOpen.Size = new System.Drawing.Size(75, 23); - this.btnOpen.TabIndex = 1; - this.btnOpen.Text = "Open"; - this.btnOpen.UseVisualStyleBackColor = true; - this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click); - // - // btnNext - // - this.btnNext.Enabled = false; - this.btnNext.Location = new System.Drawing.Point(174, 50); - this.btnNext.Name = "btnNext"; - this.btnNext.Size = new System.Drawing.Size(75, 23); - this.btnNext.TabIndex = 2; - this.btnNext.Text = "Next byte"; - this.btnNext.UseVisualStyleBackColor = true; - this.btnNext.Click += new System.EventHandler(this.btnNext_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(292, 273); - this.Controls.Add(this.btnNext); - this.Controls.Add(this.btnOpen); - this.Controls.Add(this.textBox1); - this.Name = "Form1"; - this.Text = "Form1"; - this.Load += new System.EventHandler(this.Form1_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button btnOpen; - private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - } -} - +namespace embroideryTester +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.btnOpen = new System.Windows.Forms.Button(); + this.btnNext = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(12, 12); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox1.Size = new System.Drawing.Size(100, 249); + this.textBox1.TabIndex = 0; + // + // btnOpen + // + this.btnOpen.Location = new System.Drawing.Point(174, 10); + this.btnOpen.Name = "btnOpen"; + this.btnOpen.Size = new System.Drawing.Size(75, 23); + this.btnOpen.TabIndex = 1; + this.btnOpen.Text = "Open"; + this.btnOpen.UseVisualStyleBackColor = true; + this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click); + // + // btnNext + // + this.btnNext.Enabled = false; + this.btnNext.Location = new System.Drawing.Point(174, 50); + this.btnNext.Name = "btnNext"; + this.btnNext.Size = new System.Drawing.Size(75, 23); + this.btnNext.TabIndex = 2; + this.btnNext.Text = "Next byte"; + this.btnNext.UseVisualStyleBackColor = true; + this.btnNext.Click += new System.EventHandler(this.btnNext_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 273); + this.Controls.Add(this.btnNext); + this.Controls.Add(this.btnOpen); + this.Controls.Add(this.textBox1); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button btnOpen; + private System.Windows.Forms.Button btnNext; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + } +} + diff --git a/embroideryTester/Form1.cs b/embroideryTester/Form1.cs index 0eafb88..76428ae 100644 --- a/embroideryTester/Form1.cs +++ b/embroideryTester/Form1.cs @@ -1,121 +1,121 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.IO; -using System.Runtime.InteropServices; - -namespace embroideryTester -{ - public partial class Form1 : Form - { - //BinaryReader file; - //byte[] shorts; - - //int byteNume = 0; - //short itemNumber = 0; - public Form1() - { - InitializeComponent(); - } - - private void btnOpen_Click(object sender, EventArgs e) - { - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - //byte[] bytes; - - //bytes = File.ReadAllBytes(openFileDialog1.FileName); - //shorts = File.ReadAllBytes(openFileDialog1.FileName); - //GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); - //IntPtr ptr = handle.AddrOfPinnedObject(); - ////ReDim bytes((bytes.Length \ 2) - 1) - ////int temp = bytes.Length; - ////temp = temp /2 - //shorts = new short[bytes.Length / 2 - 1]; - //Marshal.Copy(ptr, shorts, 0, shorts.Length); - //handle.Free(); - //this.Text = openFileDialog1.FileName; - //btnNext.Enabled = true; - - System.IO.BinaryReader fileIn = new System.IO.BinaryReader(System.IO.File.Open(openFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)); - - long restorePos = fileIn.BaseStream.Position; - byte[] tempbytes = fileIn.ReadBytes(10240); - string tempstring = ""; - for (int ctr = 0; ctr < tempbytes.Length; ctr++) - { - tempstring += (char)tempbytes[ctr]; - } - if (tempstring.Contains("CEmbOne")) - { - fileIn.BaseStream.Position = restorePos + tempstring.IndexOf("CEmbOne") + 7; - } - else if (tempstring.Contains("CEmbPunch")) - { - fileIn.BaseStream.Position = restorePos + tempstring.IndexOf("CEmbPunch") + 9; - } - string temp = ""; - textBox1.Visible = false; - while(fileIn.BaseStream.Position +1< fileIn.BaseStream.Length) - { - temp += fileIn.ReadInt16().ToString() + Environment.NewLine; - } - textBox1.Text = temp; - textBox1.Visible = true; - } - - } - - private void btnNext_Click(object sender, EventArgs e) - { - ////textBox1.Text += file.BaseStream.Position.ToString() +" 0x"+ file.ReadByte().ToString("X")+Environment.NewLine; - //string temp = ""; - //textBox1.Visible = false; - //for (int i = 0; i < shorts.Length; i++) - //{ - // temp += shorts[i].ToString("X") + Environment.NewLine; - //} - //textBox1.Text = temp; - //textBox1.Visible = true; - //textBox1.Select(textBox1.Text.Length, 0); - //textBox1.ScrollToCaret(); - - ////itemNumber++; - } - - private void Form1_Load(object sender, EventArgs e) - { - textBox1.MaxLength = Int32.MaxValue; - this.BackColor = GetRGB(2037741); - } - - private Color getColorFromIndex(int index) - { - Color retval = Color.Black; - switch (index) - { - case 1: - retval = Color.FromArgb(8134414); - break; - case 2: - retval = Color.FromArgb(11561576); - break; - } - return retval; - } - - private Color GetRGB(long RGB) - { - long Red, Green, Blue; - Red = RGB & 255; - Green = RGB % 256 & 255; - Blue = RGB % 256 ^ 2 & 255; - Console.WriteLine("RGB: " + Blue.ToString() + ", " + Green.ToString() + ", " + Red.ToString()); - return Color.FromArgb((int)Blue, (int)Green, (int)Red); - } - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.IO; +using System.Runtime.InteropServices; + +namespace embroideryTester +{ + public partial class Form1 : Form + { + //BinaryReader file; + //byte[] shorts; + + //int byteNume = 0; + //short itemNumber = 0; + public Form1() + { + InitializeComponent(); + } + + private void btnOpen_Click(object sender, EventArgs e) + { + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + //byte[] bytes; + + //bytes = File.ReadAllBytes(openFileDialog1.FileName); + //shorts = File.ReadAllBytes(openFileDialog1.FileName); + //GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); + //IntPtr ptr = handle.AddrOfPinnedObject(); + ////ReDim bytes((bytes.Length \ 2) - 1) + ////int temp = bytes.Length; + ////temp = temp /2 + //shorts = new short[bytes.Length / 2 - 1]; + //Marshal.Copy(ptr, shorts, 0, shorts.Length); + //handle.Free(); + //this.Text = openFileDialog1.FileName; + //btnNext.Enabled = true; + + System.IO.BinaryReader fileIn = new System.IO.BinaryReader(System.IO.File.Open(openFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)); + + long restorePos = fileIn.BaseStream.Position; + byte[] tempbytes = fileIn.ReadBytes(10240); + string tempstring = ""; + for (int ctr = 0; ctr < tempbytes.Length; ctr++) + { + tempstring += (char)tempbytes[ctr]; + } + if (tempstring.Contains("CEmbOne")) + { + fileIn.BaseStream.Position = restorePos + tempstring.IndexOf("CEmbOne") + 7; + } + else if (tempstring.Contains("CEmbPunch")) + { + fileIn.BaseStream.Position = restorePos + tempstring.IndexOf("CEmbPunch") + 9; + } + string temp = ""; + textBox1.Visible = false; + while(fileIn.BaseStream.Position +1< fileIn.BaseStream.Length) + { + temp += fileIn.ReadInt16().ToString() + Environment.NewLine; + } + textBox1.Text = temp; + textBox1.Visible = true; + } + + } + + private void btnNext_Click(object sender, EventArgs e) + { + ////textBox1.Text += file.BaseStream.Position.ToString() +" 0x"+ file.ReadByte().ToString("X")+Environment.NewLine; + //string temp = ""; + //textBox1.Visible = false; + //for (int i = 0; i < shorts.Length; i++) + //{ + // temp += shorts[i].ToString("X") + Environment.NewLine; + //} + //textBox1.Text = temp; + //textBox1.Visible = true; + //textBox1.Select(textBox1.Text.Length, 0); + //textBox1.ScrollToCaret(); + + ////itemNumber++; + } + + private void Form1_Load(object sender, EventArgs e) + { + textBox1.MaxLength = Int32.MaxValue; + this.BackColor = GetRGB(2037741); + } + + private Color getColorFromIndex(int index) + { + Color retval = Color.Black; + switch (index) + { + case 1: + retval = Color.FromArgb(8134414); + break; + case 2: + retval = Color.FromArgb(11561576); + break; + } + return retval; + } + + private Color GetRGB(long RGB) + { + long Red, Green, Blue; + Red = RGB & 255; + Green = RGB % 256 & 255; + Blue = RGB % 256 ^ 2 & 255; + Console.WriteLine("RGB: " + Blue.ToString() + ", " + Green.ToString() + ", " + Red.ToString()); + return Color.FromArgb((int)Blue, (int)Green, (int)Red); + } + } } \ No newline at end of file diff --git a/embroideryTester/Program.cs b/embroideryTester/Program.cs index 0c72bdb..368b4eb 100644 --- a/embroideryTester/Program.cs +++ b/embroideryTester/Program.cs @@ -1,44 +1,44 @@ -/* -Embroidery Reader - an application to view .pes embroidery designs - -Copyright (C) 2009 Nathan Crawford - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -A copy of the full GPL 2 license can be found in the docs directory. -You can contact me at http://www.njcrawford.com/contact.php. -*/ - -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace embroideryTester -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } +/* +Embroidery Reader - an application to view .pes embroidery designs + +Copyright (C) 2009 Nathan Crawford + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +A copy of the full GPL 2 license can be found in the docs directory. +You can contact me at http://www.njcrawford.com/contact.php. +*/ + +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace embroideryTester +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } } \ No newline at end of file diff --git a/embroideryTester/Properties/AssemblyInfo.cs b/embroideryTester/Properties/AssemblyInfo.cs index f8dfbd9..889285b 100644 --- a/embroideryTester/Properties/AssemblyInfo.cs +++ b/embroideryTester/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("emroideryTester")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("emroideryTester")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4a7aaea6-31e9-473d-b174-ce5787227af5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("emroideryTester")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("emroideryTester")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4a7aaea6-31e9-473d-b174-ce5787227af5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/embroideryTester/Properties/Resources.Designer.cs b/embroideryTester/Properties/Resources.Designer.cs index f979cf0..ce82025 100644 --- a/embroideryTester/Properties/Resources.Designer.cs +++ b/embroideryTester/Properties/Resources.Designer.cs @@ -1,63 +1,63 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace embroideryTester.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("embroideryTester.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace embroideryTester.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("embroideryTester.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/embroideryTester/Properties/Settings.Designer.cs b/embroideryTester/Properties/Settings.Designer.cs index d227e80..57cadbb 100644 --- a/embroideryTester/Properties/Settings.Designer.cs +++ b/embroideryTester/Properties/Settings.Designer.cs @@ -1,26 +1,26 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace embroideryTester.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace embroideryTester.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/embroideryThumbs/PESThumbnail.cs b/embroideryThumbs/PESThumbnail.cs index f97648b..455845e 100644 --- a/embroideryThumbs/PESThumbnail.cs +++ b/embroideryThumbs/PESThumbnail.cs @@ -1,167 +1,167 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; - -namespace embroideryThumbs -{ - //[Guid("69EA0D51-1BD4-4c6e-9AE0-B13C915A59E3")] - //public interface EmbThumbnailInterface - //{ - // //COM visible function go here - //} - - [StructLayout(LayoutKind.Sequential)] - public struct SIZE - { - public int cx; - public int cy; - - public SIZE(int cx, int cy) - { - this.cx = cx; - this.cy = cy; - } - } - - [ComImport, Guid("0000010c-0000-0000-c000-000000000046"), - InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IPersist - { - [PreserveSig] - void GetClassID(out Guid pClassID); - } - - [ComImport, Guid("0000010b-0000-0000-C000-000000000046"), - InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IPersistFile : IPersist - { - //new void GetClassID(out Guid pClassID); - [PreserveSig] - int IsDirty(); - - [PreserveSig] - void Load([In, MarshalAs(UnmanagedType.LPWStr)] - string pszFileName, uint dwMode); - - [PreserveSig] - void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, - [In, MarshalAs(UnmanagedType.Bool)] bool fRemember); - - [PreserveSig] - void SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName); - - [PreserveSig] - void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName); - } - - [ComImportAttribute()] - [GuidAttribute("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - interface IExtractImage - { - void GetLocation( - [Out, MarshalAs(UnmanagedType.LPWStr)] - StringBuilder pszPathBuffer, - int cch, - ref int pdwPriority, - ref SIZE prgSize, - int dwRecClrDepth, - ref int pdwFlags); - - void Extract(out IntPtr phBmpThumbnail); - } - - //[Guid("xxxx"), - //InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - //public interface IExtractImage2 - //{ - // // from IExtractImage - // void Extract(); - // void GetLocation(); - - // HRESULT GetDateStamp([Out] System.Runtime.InteropServices.ComTypes.FILETIME* pDateStamp); - //} - - [Guid("EA7D5329-E9D7-49fb-9F55-A12D1A2ADB5D"), - InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] - public interface EmbThumbnailEvents - { - } - - - - [Guid("7E3EF3E8-39D4-4150-9EFF-58C71A1F4F9E"), - ClassInterface(ClassInterfaceType.None), - ComSourceInterfaces(typeof(EmbThumbnailEvents))] - public class EmbThumbnail : IPersistFile, IExtractImage - { - PesFile.PesFile designFile; - - public void GetClassID(out Guid pClassID) - { - // not implemented, but won't compile without this - pClassID = new Guid("7E3EF3E8-39D4-4150-9EFF-58C71A1F4F9E"); - } - - public int IsDirty() - { - return 0; - } - - public void Load([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode) - { - if(pszFileName.Substring(pszFileName.Length - 4).ToLower() == ".pes") - { - designFile = new PesFile.PesFile(pszFileName); - } - } - - public void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [In, MarshalAs(UnmanagedType.Bool)] bool fRemember) - { - //not implemented - } - - public void SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName) - { - //not implemented - } - - public void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName) - { - //not implemented - } - - public void GetLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPathBuffer, int cch, ref int pdwPriority, ref SIZE prgSize, int dwRecClrDepth, ref int pdwFlags) - { - //not implemented - } - - public unsafe void Extract(out IntPtr phBmpThumbnail) - { - System.Drawing.Bitmap designBitmap = designFile.designToBitmap(3, false, 0); - - IntPtr hBmp = designBitmap.GetHbitmap(); - - phBmpThumbnail = new IntPtr(); - - // Assuming you already have hBmp as the handle to your Bitmap object... - if (IntPtr.Size == 4) - { - int* pBuffer = (int*)phBmpThumbnail.ToPointer(); - *pBuffer = hBmp.ToInt32(); - - // IMO, casting back to (void*) is not necessary. - // I guess just for formality, that pBuffer points - // to an object, not an int. :) - phBmpThumbnail = new IntPtr((void*)pBuffer); - } - else // 8-bytes, or 64-bit - { - long* pBuffer = (long*)phBmpThumbnail.ToPointer(); - *pBuffer = hBmp.ToInt64(); - phBmpThumbnail = new IntPtr((void*)pBuffer); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace embroideryThumbs +{ + //[Guid("69EA0D51-1BD4-4c6e-9AE0-B13C915A59E3")] + //public interface EmbThumbnailInterface + //{ + // //COM visible function go here + //} + + [StructLayout(LayoutKind.Sequential)] + public struct SIZE + { + public int cx; + public int cy; + + public SIZE(int cx, int cy) + { + this.cx = cx; + this.cy = cy; + } + } + + [ComImport, Guid("0000010c-0000-0000-c000-000000000046"), + InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IPersist + { + [PreserveSig] + void GetClassID(out Guid pClassID); + } + + [ComImport, Guid("0000010b-0000-0000-C000-000000000046"), + InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IPersistFile : IPersist + { + //new void GetClassID(out Guid pClassID); + [PreserveSig] + int IsDirty(); + + [PreserveSig] + void Load([In, MarshalAs(UnmanagedType.LPWStr)] + string pszFileName, uint dwMode); + + [PreserveSig] + void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, + [In, MarshalAs(UnmanagedType.Bool)] bool fRemember); + + [PreserveSig] + void SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName); + + [PreserveSig] + void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName); + } + + [ComImportAttribute()] + [GuidAttribute("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")] + [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + interface IExtractImage + { + void GetLocation( + [Out, MarshalAs(UnmanagedType.LPWStr)] + StringBuilder pszPathBuffer, + int cch, + ref int pdwPriority, + ref SIZE prgSize, + int dwRecClrDepth, + ref int pdwFlags); + + void Extract(out IntPtr phBmpThumbnail); + } + + //[Guid("xxxx"), + //InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + //public interface IExtractImage2 + //{ + // // from IExtractImage + // void Extract(); + // void GetLocation(); + + // HRESULT GetDateStamp([Out] System.Runtime.InteropServices.ComTypes.FILETIME* pDateStamp); + //} + + [Guid("EA7D5329-E9D7-49fb-9F55-A12D1A2ADB5D"), + InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] + public interface EmbThumbnailEvents + { + } + + + + [Guid("7E3EF3E8-39D4-4150-9EFF-58C71A1F4F9E"), + ClassInterface(ClassInterfaceType.None), + ComSourceInterfaces(typeof(EmbThumbnailEvents))] + public class EmbThumbnail : IPersistFile, IExtractImage + { + PesFile.PesFile designFile; + + public void GetClassID(out Guid pClassID) + { + // not implemented, but won't compile without this + pClassID = new Guid("7E3EF3E8-39D4-4150-9EFF-58C71A1F4F9E"); + } + + public int IsDirty() + { + return 0; + } + + public void Load([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode) + { + if(pszFileName.Substring(pszFileName.Length - 4).ToLower() == ".pes") + { + designFile = new PesFile.PesFile(pszFileName); + } + } + + public void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [In, MarshalAs(UnmanagedType.Bool)] bool fRemember) + { + //not implemented + } + + public void SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName) + { + //not implemented + } + + public void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName) + { + //not implemented + } + + public void GetLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPathBuffer, int cch, ref int pdwPriority, ref SIZE prgSize, int dwRecClrDepth, ref int pdwFlags) + { + //not implemented + } + + public unsafe void Extract(out IntPtr phBmpThumbnail) + { + System.Drawing.Bitmap designBitmap = designFile.designToBitmap(3, false, 0); + + IntPtr hBmp = designBitmap.GetHbitmap(); + + phBmpThumbnail = new IntPtr(); + + // Assuming you already have hBmp as the handle to your Bitmap object... + if (IntPtr.Size == 4) + { + int* pBuffer = (int*)phBmpThumbnail.ToPointer(); + *pBuffer = hBmp.ToInt32(); + + // IMO, casting back to (void*) is not necessary. + // I guess just for formality, that pBuffer points + // to an object, not an int. :) + phBmpThumbnail = new IntPtr((void*)pBuffer); + } + else // 8-bytes, or 64-bit + { + long* pBuffer = (long*)phBmpThumbnail.ToPointer(); + *pBuffer = hBmp.ToInt64(); + phBmpThumbnail = new IntPtr((void*)pBuffer); + } + } + } +}