private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width); Brush brush = GetBrush(mapBrush); GeoBounds bounds = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Point[] points = new Point[xpoints.Length]; for (int i = 0; i < points.Length; i++) { points[i] = new Point(xpoints[i], ypoints[i]); } SharedGraphics2D.Graphics.DrawPolygon(pen, points); SharedGraphics2D.Graphics.FillPolygon(brush, points); } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a region. * @param mapPen pen for the border of the region. * @param mapBrush brush to fill the region. * @param region the polygon object. */ private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(new Color(mapPen.Color, false), mapPen.Width); TextureBrush brush = GetImagePatternBrush(mapBrush); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polygon polygon = new Polygon { Xpoints = xpoints, Ypoints = ypoints, NumOfNpoints = xpoints.Length }; if (mapBrush.Pattern == 2) { SharedGraphics2D.SetPenAndBrush(pen, brush); SharedGraphics2D.DrawPolygon(null, polygon); SharedGraphics2D.FillPolygon(null, polygon); } else { SharedGraphics2D.SetDefaultPen(pen); SharedGraphics2D.DrawPolygon(null, polygon); } } } }