private void ReadSectorFile() { SctFileReader reader = new SctFileReader(); reader.GeoLineHandler += line => { var from = LatLongUtil.GetLatLongDecimalPointFromLatLongString(line.Start); var to = LatLongUtil.GetLatLongDecimalPointFromLatLongString(line.End); geoLines.Add(new LatLongDegreeLine(new LatLongDegreePoint(from.X, from.Y), new LatLongDegreePoint(to.X, to.Y), line.ColorName)); }; reader.DefineHandler += (key, color) => { byte blue = (byte)((color & 0xff0000) >> 16); byte green = (byte)((color & 0xff00) >> 8); byte red = (byte)(color & 0xff); if (!sectorfileColors.ContainsKey(key)) { sectorfileColors.Add(key, Color.FromRgb(red, green, blue)); } }; reader.RegionHandler += region => { regions.Add(new LatLongRegion(region.Name, region.ColorName, region.Coordinates .Select(c => { var point = LatLongUtil.GetLatLongDecimalPointFromLatLongString(c); return(new LatLongDegreePoint(point.X, point.Y)); } ) .ToList())); }; reader.SectorfileInfoHandler += info => fileInfo = info; reader.Parse("..\\..\\..\\UnitTestProject1\\Testdata\\EKDK_official_16_13.sct"); logger.Debug("Read " + geoLines.Count + " geo lines"); }
private string ReadInfoSection(StreamReader reader) { string line; int linenum = 0; var info = new SectorFileInfo(); do { line = reader.ReadLine(); if (IsCommentLine(line)) { continue; } if (line.StartsWith("[")) { return(line); } else if (!String.IsNullOrEmpty(line)) { linenum++; switch (linenum) { case 1: info.Name = line; break; case 2: info.DefaultCallsign = line; break; case 3: info.DefaultAirport = line; break; case 4: info.DefaultLatitude = line; break; case 5: info.DefaultLongitude = line; break; case 6: info.NMPerLatDegree = double.Parse(line, NumberStyles.Any, CultureInfo.InvariantCulture); break; case 7: info.NMPerLongDegree = double.Parse(line, NumberStyles.Any, CultureInfo.InvariantCulture); break; case 8: info.MagVar = double.Parse(line, NumberStyles.Any, CultureInfo.InvariantCulture); break; case 9: SectorfileInfoHandler(info); return(reader.ReadLine()); default: break; } } } while (!reader.EndOfStream); return(""); }