//FILEBlock public SDAT(byte[] bytes) { using (var er = new EndianBinaryReader(new MemoryStream(bytes))) { FileHeader = er.ReadObject <FileHeader>(); SYMBOffset = er.ReadInt32(); SYMBLength = er.ReadInt32(); INFOOffset = er.ReadInt32(); INFOLength = er.ReadInt32(); FATOffset = er.ReadInt32(); FATLength = er.ReadInt32(); FILEOffset = er.ReadInt32(); FILELength = er.ReadInt32(); Padding = er.ReadBytes(16); if (SYMBOffset != 0 && SYMBLength != 0) { SYMBBlock = er.ReadObject <SYMB>(SYMBOffset); } INFOBlock = er.ReadObject <INFO>(INFOOffset); FATBlock = er.ReadObject <FAT>(FATOffset); } }
public SDAT(byte[] Data) { EndianBinaryReaderEx er = new EndianBinaryReaderEx(new MemoryStream(Data), Endianness.LittleEndian); try { Header = new SDATHeader(er); if (Header.SYMBOffset != 0 && Header.SYMBLength != 0) { er.BaseStream.Position = Header.SYMBOffset; SymbolBlock = new SYMB(er); } er.BaseStream.Position = Header.INFOOffset; InfoBlock = new INFO(er); er.BaseStream.Position = Header.FATOffset; FileAllocationTable = new FAT(er); er.BaseStream.Position = Header.FILEOffset; File = new FILE(er); } finally { er.Close(); } }
public VectorSymbol(string vectordata, ColorTable colortable) : base() { this.ColorTable = colortable; string[] lines = vectordata.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { try { switch (line.Substring(0, 4)) { case "SYMB": SYMB = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); //TODO: what does it mean? - means ID ObjectId = Convert.ToInt32(SYMB.Substring(2, 5)); break; case "SYMD": Code = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 8); SymbolType = RleParser.StripLenFromString(line.Substring(4).Trim())[8]; OffsetX = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(9, 5)); OffsetY = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(14, 5)); Width = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(19, 5)); Height = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(24, 5)); HotspotX = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(29, 5)); HotspotY = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(34, 5)); break; case "SXPO": Description = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); break; case "SCRF": string pal = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); while (pal.Length > 0) { try { Colors.Add(pal[0], colortable.Colors[pal.Substring(1, 5)]); } catch (Exception e) { _isvalid = false; Debug.Print( "Symbol {0}. The requested color {1} doesn't exist in the palette.", this.Code, pal.Substring(1, 5)); } pal = pal.Substring(6); } break; case "SVCT": AddLine(RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term)); break; } } catch (Exception ex) { Debug.Print("Error while parsing object: {0}", vectordata); } } }