public void DrawLines() { int skipped = 0; WriteableBitmap writeableBmp = BitmapFactory.New((int)ActualWidth, (int)ActualHeight); geoImage.Source = writeableBmp; using (writeableBmp.GetBitmapContext()) { var clearColor = Color.FromRgb( symbolSettings["Sector:inactive sector background"].R, symbolSettings["Sector:inactive sector background"].G, symbolSettings["Sector:inactive sector background"].B); writeableBmp.Clear(clearColor); skipped = 0; if (showRegions) { regions.ForEach(region => { var color = Colors.Black; sectorfileColors.TryGetValue(region.ColorName, out color); var points = new int[(region.Coordinates.Count + 1) * 2]; int i = 0; region.Coordinates.ForEach(c => { var p = LatLongUtil.Transform(c.Latitude, c.Longitude); points[i++] = (int)p.X; points[i++] = (int)p.Y; c.X = (int)p.X; c.Y = (int)p.Y; }); points[i++] = points[0]; points[i++] = points[1]; writeableBmp.FillPolygon(points, color); if (editRegions) { for (int j = 0; j < region.Coordinates.Count * 2; j += 2) { writeableBmp.FillRectangle(points[j] - editPointDelta, points[j + 1] - editPointDelta, points[j] + editPointDelta, points[j + 1] + editPointDelta, editColor); } } }); } if (showGeo) { skipped = 0; var geoColor = Color.FromRgb( symbolSettings["Geo:line"].R, symbolSettings["Geo:line"].G, symbolSettings["Geo:line"].B); geoLines.ForEach(geoLine => { var from = LatLongUtil.Transform(geoLine.Start.Latitude, geoLine.Start.Longitude); var to = LatLongUtil.Transform(geoLine.End.Latitude, geoLine.End.Longitude); if (ShouldDrawLine(from, to)) { var color = geoColor; if (!string.IsNullOrEmpty(geoLine.Color)) { sectorfileColors.TryGetValue(geoLine.Color, out color); } writeableBmp.DrawLine((int)from.X, (int)from.Y, (int)to.X, (int)to.Y, color); geoLine.Start.X = (int)from.X; geoLine.Start.Y = (int)from.Y; geoLine.End.X = (int)to.X; geoLine.End.Y = (int)to.Y; } else { skipped++; } }); Debug.WriteLine("Skipped " + skipped + " geo points "); } } }