public static BaseSymbol ReadSymbol(FileStream fs, int symFilePosition, ColorInfo[] filecolors) { fs.Seek(symFilePosition, SeekOrigin.Begin); int dataSize = FileIOHelpers.ReadInt16FromStream(fs); int symbolNumber = FileIOHelpers.ReadInt16FromStream(fs); int objectType = FileIOHelpers.ReadInt16FromStream(fs); byte symType = FileIOHelpers.ReadBytesFromStream(fs, 1)[0]; BaseSymbol bs = GetSymbolFromType(objectType, symType); bs.SymbolNumber = symbolNumber; byte flags = FileIOHelpers.ReadBytesFromStream(fs, 1)[0]; bs.Extent = FileIOHelpers.ReadInt16FromStream(fs); bool selected = FileIOHelpers.ReadBoolFromStream(fs); byte status = FileIOHelpers.ReadBytesFromStream(fs, 1)[0]; int res2 = FileIOHelpers.ReadInt16FromStream(fs); int res3 = FileIOHelpers.ReadInt16FromStream(fs); long filePos = FileIOHelpers.ReadInt32FromStream(fs); byte[] colors = FileIOHelpers.ReadBytesFromStream(fs, 32); bs.Description = FileIOHelpers.ReadDelphiStringFromStream(fs,31); bs.Icon = FileIOHelpers.ReadBytesFromStream(fs, 264); if (bs is PointSymbol) readPointSymbol(bs, fs); else if (bs is LineSymbol) readLineSymbol(bs, fs, filecolors); return bs; }
public static List<BaseSymbol> ReadSymbols(FileStream fs, List<int> symIndexes, ColorInfo[] colors) { List<BaseSymbol> symbols = new List<BaseSymbol>(); foreach (var idx in symIndexes) { var bs = ReadSymbol(fs, idx, colors); symbols.Add(bs); } return symbols; }
private static void readLineSymbol(BaseSymbol bs, FileStream fs, ColorInfo[] colors) { int col = FileIOHelpers.ReadInt16FromStream(fs); (bs as LineSymbol).LineWidth = FileIOHelpers.ReadInt16FromStream(fs); if (colors.Where(x => x.ColorNum == col).Count() == 0) throw new ApplicationException("cant find color " + col + " for symbol: " + bs.Description + " [" + bs.SymbolNumber + "]"); (bs as LineSymbol).LineColor = colors.Where(x => x.ColorNum == col).Select(x=>x.Color).First(); }