public void Save(String fileName, FileMode fileMode, LC4Document document) { m_document = document; m_fileStream = new FileStream(fileName, fileMode); WriteBytes(m_header); WriteString(m_document.InternalName); WriteString(m_document.Description); WriteBytes(m_middlePad); WriteInt32(m_document.SomeInteger1); WriteBytes(m_middlePad); WriteInt32(document.Sheets.Count); // sheets count foreach (LC4Sheet sheet in document.Sheets) { SaveSheet(sheet); } WriteBytes(m_middlePad); WriteInt32(m_document.SomeInteger2); WriteBytes(m_middlePad); WriteInt32(document.Cuttings.Count); // cuts count foreach (LC4Cutting cutting in document.Cuttings) { SaveCutting(cutting); } WriteBytes(m_teil); m_fileStream.Close(); }
public LC4Document Load(Stream stm) { m_fmt = new LC4Formatter(stm); m_document = new LC4Document(); Byte[] pad; pad = m_fmt.ReadBytes(7); m_document.InternalName = m_fmt.ReadString(); m_document.Description = m_fmt.ReadString(); pad = m_fmt.ReadBytes(7); m_document.SomeInteger1 = m_fmt.ReadInt32(); pad = m_fmt.ReadBytes(7); Int32 sheetsCount = m_fmt.ReadInt32(); for (Int32 i = 0; i < sheetsCount; i++) { LoadSheet(); } pad = m_fmt.ReadBytes(7); m_document.SomeInteger2 = m_fmt.ReadInt32(); pad = m_fmt.ReadBytes(7); Int32 cutsCount = m_fmt.ReadInt32(); for (Int32 i = 0; i < cutsCount; i++) { LoadCutting(); } pad = m_fmt.ReadBytes(13); return m_document; }
static void Prog2() { LC4Document doc = parser.Load(@"..\..\sokolov21.LC4"); doc.Description = "manually generated"; doc.Cuttings[0].Name = "00001"; parser.Save(@"..\..\SOKOLOV21.LC4", FileMode.Create, doc); doc.Serialize(@"..\..\SOKOLOV21.xml"); }
static void Prog1() { LC4Document doc = parser.Load(@"..\..\sokolov2.LC4"); parser.Save(@"..\..\1loadsave.lc4", FileMode.Create, doc); // pass doc.Serialize(@"..\..\1loadsave.xml"); doc.Cuttings.RemoveRange(1, doc.Cuttings.Count - 1); parser.Save(@"..\..\2singleCutting.lc4", FileMode.Create, doc); doc.Serialize(@"..\..\2singleCutting.xml"); doc.Sheets.RemoveRange(1, doc.Sheets.Count - 1); parser.Save(@"..\..\3singleSheet.lc4", FileMode.Create, doc); doc.Serialize(@"..\..\3singleSheet.xml"); doc.Cuttings[0].Variables.Clear(); parser.Save(@"..\..\4noVariables.lc4", FileMode.Create, doc); doc.Serialize(@"..\..\4noVariables.xml"); doc.Description = "Other name"; parser.Save(@"..\..\5otherGen.lc4", FileMode.Create, doc); doc.Serialize(@"..\..\5otherGen.xml"); }
public LC4Document Load(String fileName) { m_document = new LC4Document(); m_fileStream = new FileStream(fileName, FileMode.Open); Byte[] pad; pad = ReadBytes(7); m_document.InternalName = ReadString(); m_document.Description = ReadString(); pad = ReadBytes(7); m_document.SomeInteger1 = ReadInt32(); pad = ReadBytes(7); Int32 sheetsCount = ReadInt32(); for (Int32 i = 0; i < sheetsCount; i++) { LoadSheet(); } pad = ReadBytes(7); m_document.SomeInteger2 = ReadInt32(); pad = ReadBytes(7); Int32 cutsCount = ReadInt32(); for (Int32 i = 0; i < cutsCount; i++) { LoadCutting(); } pad = ReadBytes(13); m_fileStream.Close(); return(m_document); }
public LC4Document Load(Stream stm) { m_fmt = new LC4Formatter(stm); m_document = new LC4Document(); Byte[] pad; pad = m_fmt.ReadBytes(7); m_document.InternalName = m_fmt.ReadString(); m_document.Description = m_fmt.ReadString(); pad = m_fmt.ReadBytes(7); m_document.SomeInteger1 = m_fmt.ReadInt32(); pad = m_fmt.ReadBytes(7); Int32 sheetsCount = m_fmt.ReadInt32(); for (Int32 i = 0; i < sheetsCount; i++) { LoadSheet(); } pad = m_fmt.ReadBytes(7); m_document.SomeInteger2 = m_fmt.ReadInt32(); pad = m_fmt.ReadBytes(7); Int32 cutsCount = m_fmt.ReadInt32(); for (Int32 i = 0; i < cutsCount; i++) { LoadCutting(); } pad = m_fmt.ReadBytes(13); return(m_document); }