kopia lustrzana https://github.com/njcrawford/EmbroideryReader
Try to catch errors when color number is out of range in PesFile.OpenFile()
Also cleanup some unneeded namespace specifiersmaster
rodzic
c16f3e7fb0
commit
afd3e80907
|
@ -29,7 +29,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace PesFile
|
namespace PesFile
|
||||||
{
|
{
|
||||||
public class PECFormatException : System.Exception
|
public class PECFormatException : Exception
|
||||||
{
|
{
|
||||||
public PECFormatException(string message) : base(message) { }
|
public PECFormatException(string message) : base(message) { }
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,14 @@ namespace PesFile
|
||||||
curBlock.stitches = new Stitch[tempStitches.Count];
|
curBlock.stitches = new Stitch[tempStitches.Count];
|
||||||
tempStitches.CopyTo(curBlock.stitches);
|
tempStitches.CopyTo(curBlock.stitches);
|
||||||
curBlock.stitchesTotal = tempStitches.Count;
|
curBlock.stitchesTotal = tempStitches.Count;
|
||||||
|
|
||||||
colorNum++;
|
colorNum++;
|
||||||
|
if(colorNum >= colorList.Count)
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("colorNum (" + colorNum + ") out of range (" + colorList.Count + ") in end of stitches block");
|
||||||
|
}
|
||||||
colorIndex = colorList[colorNum];
|
colorIndex = colorList[colorNum];
|
||||||
|
|
||||||
curBlock.colorIndex = colorIndex;
|
curBlock.colorIndex = colorIndex;
|
||||||
curBlock.color = GetColorFromIndex(colorIndex);
|
curBlock.color = GetColorFromIndex(colorIndex);
|
||||||
blocks.Add(curBlock);
|
blocks.Add(curBlock);
|
||||||
|
@ -214,8 +220,14 @@ namespace PesFile
|
||||||
curBlock.stitches = new Stitch[tempStitches.Count];
|
curBlock.stitches = new Stitch[tempStitches.Count];
|
||||||
tempStitches.CopyTo(curBlock.stitches);
|
tempStitches.CopyTo(curBlock.stitches);
|
||||||
curBlock.stitchesTotal = tempStitches.Count;
|
curBlock.stitchesTotal = tempStitches.Count;
|
||||||
|
|
||||||
colorNum++;
|
colorNum++;
|
||||||
|
if (colorNum >= colorList.Count)
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("colorNum (" + colorNum + ") out of range (" + colorList.Count + ") in color switch block");
|
||||||
|
}
|
||||||
colorIndex = colorList[colorNum];
|
colorIndex = colorList[colorNum];
|
||||||
|
|
||||||
curBlock.colorIndex = colorIndex;
|
curBlock.colorIndex = colorIndex;
|
||||||
curBlock.color = GetColorFromIndex(colorIndex);
|
curBlock.color = GetColorFromIndex(colorIndex);
|
||||||
//read useless(?) byte
|
//read useless(?) byte
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace PesFile
|
||||||
public byte unknownStartByte;
|
public byte unknownStartByte;
|
||||||
public StitchBlock()
|
public StitchBlock()
|
||||||
{
|
{
|
||||||
color = System.Drawing.Color.Black;
|
color = Color.Black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace embroideryReader
|
namespace embroideryReader
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue