public ColorTable(string palettedata) { Colors = new Dictionary <string, ColorRecord>(); string[] lines = palettedata.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.StartsWith("COLS")) { COLS = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); //TODO: what does it mean? Name = line.Trim(RleParser.Term).Substring(line.LastIndexOf("NIL") + 3); ObjectId = Convert.ToInt32(COLS.Substring(2, 5)); } if (line.StartsWith("CCIE")) { // Yxy -> XYZ conversion double x = double.Parse( RleParser.StripLenFromString(line.Substring(4).Trim()).Substring( 5).Split(RleParser.Term)[0], CultureInfo.InvariantCulture); double y = double.Parse(line.Trim().Split(RleParser.Term)[1], CultureInfo.InvariantCulture); double Y = double.Parse(line.Trim().Split(RleParser.Term)[2], CultureInfo.InvariantCulture); CIEYxy color = new CIEYxy(Y, x, y); Colors.Add(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 5), new ColorRecord(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 5), line.Trim().Split(RleParser.Term)[3], color )); } } }
private void FillObjectFromText(string objecttext) { string[] lines = objecttext.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { switch (line.Substring(0, 4)) { case "0001": break; case "####": break; case "LUPT": LUPT = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); //TODO: what does it mean? ObjectId = Convert.ToInt32(LUPT.Substring(2, 5)); Code = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(10, 6); //replaced by smarter property - SymbolizationLetter = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(16, 1); DisplayPriority = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(21, 1); if (line.Length > 31) { Radar = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(22, 1); } if (line.Length > 32) { Symbolization = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(23).Trim(RleParser.Term); } break; case "ATTC": AttributeCombination = RleParser.StripLenFromString(line.Substring(4).Trim()).Replace(RleParser.Term, '|'); if (AttributeCombination == "|") { AttributeCombination = string.Empty; } break; case "INST": SymbolizationInstructions = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); break; case "DISC": ImoDisplayCategory = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); break; case "LUCM": ViewingGroup = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); break; default: //Debug.WriteLine(line); break; } } }
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); } } }
public VectorPattern(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 "PATT": PATT = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); //TODO: what does it mean? - means ID ObjectId = Convert.ToInt32(PATT.Substring(2, 5)); break; case "PATD": Code = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 8); SymbolType = RleParser.StripLenFromString(line.Substring(4).Trim())[8]; Value2 = RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(9, 6); Value3 = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(15, 5)); Value4 = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(20, 5)); OffsetX = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(25, 5)); OffsetY = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(30, 5)); Width = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(35, 5)); Height = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(40, 5)); HotspotX = Convert.ToInt32(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(45, 5)); HotspotY = Convert.ToInt32( RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(50).Trim( RleParser.Term)); //TODO: it looks shorter, should be 55 in total, but is just 54! break; case "PXPO": Description = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); break; case "PCRF": 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) { 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 "PVCT": AddLine(RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term)); break; } } catch (Exception ex) { Debug.Print("Error while parsing object: {0}", vectordata); } } }