diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index b7e5edd..3f2d8af 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -29,7 +29,7 @@ using System.IO; namespace PesFile { - public class PECFormatException : System.Exception + public class PECFormatException : Exception { public PECFormatException(string message) : base(message) { } } @@ -200,8 +200,14 @@ namespace PesFile curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; + colorNum++; + if(colorNum >= colorList.Count) + { + throw new IndexOutOfRangeException("colorNum (" + colorNum + ") out of range (" + colorList.Count + ") in end of stitches block"); + } colorIndex = colorList[colorNum]; + curBlock.colorIndex = colorIndex; curBlock.color = GetColorFromIndex(colorIndex); blocks.Add(curBlock); @@ -214,8 +220,14 @@ namespace PesFile curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; + colorNum++; + if (colorNum >= colorList.Count) + { + throw new IndexOutOfRangeException("colorNum (" + colorNum + ") out of range (" + colorList.Count + ") in color switch block"); + } colorIndex = colorList[colorNum]; + curBlock.colorIndex = colorIndex; curBlock.color = GetColorFromIndex(colorIndex); //read useless(?) byte diff --git a/PesFile/StitchBlock.cs b/PesFile/StitchBlock.cs index 9779907..015a814 100644 --- a/PesFile/StitchBlock.cs +++ b/PesFile/StitchBlock.cs @@ -36,7 +36,7 @@ namespace PesFile public byte unknownStartByte; public StitchBlock() { - color = System.Drawing.Color.Black; + color = Color.Black; } } } diff --git a/embroideryReader/GuiResources.cs b/embroideryReader/GuiResources.cs index 2e20938..9f3acee 100644 --- a/embroideryReader/GuiResources.cs +++ b/embroideryReader/GuiResources.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; namespace embroideryReader {