private void FillLineShape(LineShape shape, Color fillColor, MappingConverter converter) { SolidBrush brush = new SolidBrush(fillColor); PointF[] points = new PointF[shape.Vertexes.Count]; for (int i = 0; i < shape.Vertexes.Count; i++) { points[i] = converter.GetMappingPoint(shape.Vertexes[i]); } graphics.FillPolygon(brush, points); }
private void DrawLine(LineShape shape, MappingConverter converter) { Color color = Color.FromArgb(shape.Color.R, shape.Color.G, shape.Color.B); Pen pen = new Pen(color, converter.GetPenWidth(shape.Width)); PointF[] points = new PointF[shape.Vertexes.Count]; for (int i = 0; i < shape.Vertexes.Count; i++) { points[i] = converter.GetMappingPoint(shape.Vertexes[i]); } if (shape.Vertexes[0].GeometryEqual(shape.Vertexes[shape.Vertexes.Count - 1])) { graphics.DrawPolygon(pen, points); } else { graphics.DrawLines(pen, points); DrawPoint(new PointShape(shape.Vertexes[0], shape.Width, shape.Color), converter); DrawPoint(new PointShape(shape.Vertexes[shape.Vertexes.Count - 1], shape.Width, shape.Color), converter); } }
public Collection <DAIShape> GetShapes(Dictionary <string, RGBColor> colorRef) { Collection <DAIShape> shapes = new Collection <DAIShape>(); RGBColor color = colorSymbol.GetColor(colorRef); int width = widthSymbol.GetWidth(); Vertex startVertex = GetVertex(); Collection <Vertex> lineBuffer = new Collection <Vertex>(); lineBuffer.Insert(0, new Vertex(startVertex.X, startVertex.Y)); foreach (S52BaseSymbol drawingSymbol in drawingSymbols) { if (drawingSymbol is PDSymbol) { // line or point shape Collection <Vertex> vertexes = (drawingSymbol as PDSymbol).GetVertexes(); if (vertexes.Count == 0) { // it's a point shape PointShape shape = new PointShape(startVertex.X, startVertex.Y, width, color); shapes.Add(shape); // the next start vertex is the same as the current // clean line buffer, and start next buffer lineBuffer.Clear(); lineBuffer.Add(new Vertex(startVertex.X, startVertex.Y)); } else { // it's a line shape foreach (Vertex vertex in vertexes) { lineBuffer.Add(vertex); } // the next start vertex is the end of the line vertex startVertex = vertexes[vertexes.Count - 1]; } } else if (drawingSymbol is CISymbol) { // circle shape // the next start vertex is the same as the current int radius = (drawingSymbol as CISymbol).GetRadius(); CircleShape shape = new CircleShape(new Vertex(startVertex.X, startVertex.Y), radius, width, color); // clean line buffer, then start next buffer if (lineBuffer.Count > 1) { // add previous line shape LineShape lineShape = new LineShape(new Collection <Vertex>(lineBuffer), width, color); shapes.Add(lineShape); lineBuffer.Clear(); lineBuffer.Add(new Vertex(startVertex.X, startVertex.Y)); } // add circle shape shapes.Add(shape); } else if (drawingSymbol is AASymbol) { // ara angle shape Vertex centerVertex = (drawingSymbol as AASymbol).GetCenterVertex(); int angle = (drawingSymbol as AASymbol).GetAngle(); ArcAngleShape shape = new ArcAngleShape(centerVertex, new Vertex(startVertex.X, startVertex.Y), angle, width, color); // the next start vertex is the end of the ara angle vertex startVertex = shape.GetEndofVertex(); // clean line buffer, then start next buffer if (lineBuffer.Count > 1) { // add previous line shape LineShape lineShape = new LineShape(new Collection <Vertex>(lineBuffer), width, color); shapes.Add(lineShape); lineBuffer.Clear(); lineBuffer.Add(new Vertex(startVertex.X, startVertex.Y)); } // add angle shape shapes.Add(shape); } } // clean line buffer, then start next buffer if (lineBuffer.Count > 1) { // add last line shape LineShape lineShape = new LineShape(new Collection <Vertex>(lineBuffer), width, color); shapes.Add(lineShape); } return(shapes); }