protected override void Paint(UMD.HCIL.PocketPiccolo.Util.PPaintContext paintContext) { Graphics2D g = paintContext.Graphics; if (points.Count > 0) { if (Brush != null && closed) { g.FillPolygon(Brush, (PointF[])points.ToArray(typeof(PointF))); } if (pen != null) { if (closed) { g.DrawPolygon(pen, (PointF[])points.ToArray(typeof(PointF))); } else { for (int i = 0; i < points.Count - 1; i++) { g.DrawLine(pen, (PointF)points[i], (PointF)points[i + 1]); } } } } }
private static void DrawTile(Graphics2D g, Tile tile) { if (TileDebugInfoMode == TileDrawInfo.CollisionBoxes) { if (tile.IsSolid && tile.CollisionModel != null) { foreach (Rectangle2F box in tile.CollisionModel.Boxes) { Rectangle2F r = Rectangle2F.Translate(box, tile.Position); g.FillRectangle(r, Color.Red); //g.DrawRectangle(r, 1, Color.Maroon); } } } else if (TileDebugInfoMode == TileDrawInfo.GridArea) { Rectangle2F tileBounds = (Rectangle2F)tile.TileGridArea; tileBounds.Point *= GameSettings.TILE_SIZE; tileBounds.Size *= GameSettings.TILE_SIZE; Color c = Color.Yellow; if (tile.Layer == 1) { c = Color.Blue; } else if (tile.Layer == 2) { c = Color.Red; } g.FillRectangle(tileBounds, c); tileBounds = new Rectangle2F(tile.Position, tile.Size * GameSettings.TILE_SIZE); c = Color.Olive; if (tile.Layer == 1) { c = Color.Cyan; } else if (tile.Layer == 2) { c = Color.Maroon; } g.DrawLine(new Line2F(tileBounds.TopLeft, tileBounds.BottomRight - new Point2I(1, 1)), 1, c); g.DrawLine(new Line2F(tileBounds.TopRight - new Point2I(1, 0), tileBounds.BottomLeft - new Point2I(0, 1)), 1, c); g.DrawRectangle(tileBounds, 1, Color.Black); } }
//////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS -------------------------- // Date Name Tracking # Description // --------- ------------------- ------------- ------------------ // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////// /** * * @param mapDirection * @param X * @param Y * @param Width * @param Height */ private void DrawRouteImage(MapDirection mapDirection, int x, int y, int width, int height) { if (!_routeDrawWaypointOnly) { _sutherlandHodgman = new SutherlandHodgman(_screenBounds); ArrayList polyline = new ArrayList(); int minLevel = NeedShowLevel(mapDirection.Polyline.NumLevels, GetZoom()); for (int i = 0; i < mapDirection.Polyline.GetVertexCount(); i++) { int level = mapDirection.Polyline.GetLevel(i); if (level >= minLevel) { polyline.Add(mapDirection.Polyline.GetVertex(i)); } } ArrayList clippedPts = _sutherlandHodgman.ClipPline(polyline); GeoPoint newPt1; GeoPoint newPt2; GeoPoint drawPt1 = new GeoPoint(0, 0), drawPt2 = new GeoPoint(0, 0); const int steps = 1; int numOfTiles = MAP_TILE_WIDTH / _mapDrawingTileWidth; Rectangle drawArea = new Rectangle(); Rectangle intersectRect = new Rectangle(0, 0, width, height); int xIndex; for (xIndex = 0; xIndex < numOfTiles; xIndex++) { int yIndex; for (yIndex = 0; yIndex < numOfTiles; yIndex++) { bool hasPt1 = false; GeoLatLng pt1 = null; _routeGraphics2D.Clear(Color.White); drawArea.X = xIndex * _mapDrawingTileWidth; drawArea.Y = yIndex * _mapDrawingTileWidth; drawArea.Width = drawArea.Height = _mapDrawingTileWidth; drawArea = intersectRect.Intersection(drawArea); int totalPointSize = clippedPts.Count; if (!drawArea.IsEmpty()) { _routeGraphics2D.SetClip(0, 0, drawArea.Width, drawArea.Height); try { for (int j = 0; j < totalPointSize; j += steps) { GeoLatLng pt = (GeoLatLng)clippedPts[j]; int level = minLevel; if (hasPt1 == false) { if (level >= minLevel) { { { hasPt1 = true; pt1 = pt; continue; } } } } if (hasPt1) { if (level >= minLevel) { GeoLatLng pt2 = pt; newPt1 = FromLatLngToMapPixel(pt1); newPt2 = FromLatLngToMapPixel(pt2); newPt1.X -= x + xIndex * _mapDrawingTileWidth; newPt1.Y -= y + yIndex * _mapDrawingTileWidth; newPt2.X -= x + xIndex * _mapDrawingTileWidth; newPt2.Y -= y + yIndex * _mapDrawingTileWidth; drawPt1.X = (int)newPt1.X; drawPt1.Y = (int)newPt1.Y; drawPt2.X = (int)newPt2.X; drawPt2.Y = (int)newPt2.Y; if ((drawPt1.Distance(drawPt2) > 0)) { _routeGraphics2D.DrawLine(RoutePen, (int)drawPt1.X, (int)drawPt1.Y, (int)drawPt2.X, (int)drawPt2.Y); pt1 = pt2; if (_readListener != null) { _readListener.readProgress(j, totalPointSize); } } } } } } catch (Exception) { } } _routeGraphics.DrawRGB(_routeGraphics2D.GetRGB(), 0, _mapDrawingTileWidth, xIndex * _mapDrawingTileWidth, yIndex * _mapDrawingTileWidth, _mapDrawingTileWidth, _mapDrawingTileWidth, true); } } } else { _routeGraphics.SetColor(TRANSPARENCY); _routeGraphics.FillRect(0, 0, MAP_TILE_WIDTH, MAP_TILE_WIDTH); } }