private void DrawGeom(Geometry geom) { if (geom != null) { var g = m_GeoSearch.MapControl.CreateGraphics(); Color fillColor = Color.Transparent, outlineColor = Color.Aqua; if (geom is Polygon) { VectorRenderer.DrawPolygon(g, (Polygon)geom, new SolidBrush(fillColor), new Pen(Color.FromArgb(96, outlineColor), 7), false, m_GeoSearch.MapControl.Map); } else if (geom is MultiPolygon) { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)geom, new SolidBrush(fillColor), new Pen(Color.FromArgb(96, outlineColor), 7), false, m_GeoSearch.MapControl.Map); } else if (geom is SharpMap.Geometries.Point) { VectorRenderer.DrawPoint(g, (SharpMap.Geometries.Point)geom, MarkerTypes.Circle, new SolidBrush(Color.FromArgb(96, outlineColor)), false, new Pen(outlineColor), 25, new PointF(0, 0), m_GeoSearch.MapControl.Map); } else if (geom is MultiPoint) { VectorRenderer.DrawMultiPoint(g, (MultiPoint)geom, MarkerTypes.Circle, new SolidBrush(Color.FromArgb(96, outlineColor)), false, new Pen(outlineColor), 25, new PointF(0, 0), m_GeoSearch.MapControl.Map); } m_GeoSearch.MapControl.PaintMapTitleAndLegend(g); g.Dispose(); } }
protected void RenderGeometry(Graphics g, Map map, Geometry feature, VectorStyle style) { //ToDo: Add Property 'public GeometryType2 GeometryType { get; }' to remove this GeometryType2 geometryType = feature.GeometryType; //(GeometryType2)Enum.Parse(typeof(GeometryType2), feature.GetType().Name); switch (geometryType) //switch (feature.GetType().FullName) { case GeometryType2.Polygon: //case "SharpMap.Geometries.Polygon": if (style.EnableOutline) { VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, null, _clippingEnabled, map); } break; case GeometryType2.MultiPolygon: //case "SharpMap.Geometries.MultiPolygon": if (style.EnableOutline) { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, null, _clippingEnabled, map); } break; case GeometryType2.LineString: //case "SharpMap.Geometries.LineString": VectorRenderer.DrawLineString(g, (LineString)feature, style.Line, map); break; case GeometryType2.MultiLineString: //case "SharpMap.Geometries.MultiLineString": VectorRenderer.DrawMultiLineString(g, (MultiLineString)feature, style.Line, map); break; case GeometryType2.Point: //case "SharpMap.Geometries.Point": VectorRenderer.DrawPoint(g, (Point)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); break; case GeometryType2.MultiPoint: //case "SharpMap.Geometries.MultiPoint": VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); break; case GeometryType2.GeometryCollection: //case "SharpMap.Geometries.GeometryCollection": foreach (Geometry geom in (GeometryCollection)feature) { RenderGeometry(g, map, geom, style); } break; default: break; } }
/// <summary> /// Method to render <paramref name="feature"/> using <paramref name="style"/> /// </summary> /// <param name="g">The graphics object</param> /// <param name="map">The map</param> /// <param name="feature">The feature's geometry</param> /// <param name="style">The style to apply</param> protected void RenderGeometry(Graphics g, MapViewport map, IGeometry feature, VectorStyle style) { if (feature == null) { return; } var geometryType = feature.OgcGeometryType; switch (geometryType) { case OgcGeometryType.Polygon: if (style.EnableOutline) { VectorRenderer.DrawPolygon(g, (IPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawPolygon(g, (IPolygon)feature, style.Fill, null, _clippingEnabled, map); } break; case OgcGeometryType.MultiPolygon: if (style.EnableOutline) { VectorRenderer.DrawMultiPolygon(g, (IMultiPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawMultiPolygon(g, (IMultiPolygon)feature, style.Fill, null, _clippingEnabled, map); } break; case OgcGeometryType.LineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (ILineString)feature, g); return; } VectorRenderer.DrawLineString(g, (ILineString)feature, style.Line, map, style.LineOffset); return; case OgcGeometryType.MultiLineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (IMultiLineString)feature, g); return; } VectorRenderer.DrawMultiLineString(g, (IMultiLineString)feature, style.Line, map, style.LineOffset); break; case OgcGeometryType.Point: if (style.PointSymbolizer != null) { VectorRenderer.DrawPoint(style.PointSymbolizer, g, (IPoint)feature, map); return; } if (style.Symbol != null || style.PointColor == null) { VectorRenderer.DrawPoint(g, (IPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); return; } VectorRenderer.DrawPoint(g, (IPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); break; case OgcGeometryType.MultiPoint: if (style.PointSymbolizer != null) { VectorRenderer.DrawMultiPoint(style.PointSymbolizer, g, (IMultiPoint)feature, map); } if (style.Symbol != null || style.PointColor == null) { VectorRenderer.DrawMultiPoint(g, (IMultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); } else { VectorRenderer.DrawMultiPoint(g, (IMultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); } break; case OgcGeometryType.GeometryCollection: var coll = (IGeometryCollection)feature; for (var i = 0; i < coll.NumGeometries; i++) { IGeometry geom = coll[i]; RenderGeometry(g, map, geom, style); } break; default: break; } }
protected void RenderGeometry(Graphics g, Map map, Geometry feature, VectorStyle style) { GeometryType2 geometryType = feature.GeometryType; switch (geometryType) { case GeometryType2.Polygon: if (style.EnableOutline) { VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, null, _clippingEnabled, map); } break; case GeometryType2.MultiPolygon: if (style.EnableOutline) { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); } else { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, null, _clippingEnabled, map); } break; case GeometryType2.LineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (LineString)feature, g); return; } VectorRenderer.DrawLineString(g, (LineString)feature, style.Line, map, style.LineOffset); return; case GeometryType2.MultiLineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (MultiLineString)feature, g); return; } VectorRenderer.DrawMultiLineString(g, (MultiLineString)feature, style.Line, map, style.LineOffset); break; case GeometryType2.Point: if (style.PointSymbolizer != null) { VectorRenderer.DrawPoint(style.PointSymbolizer, g, (Point)feature, map); return; } if (style.Symbol != null || style.PointColor == null) { VectorRenderer.DrawPoint(g, (Point)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); return; } VectorRenderer.DrawPoint(g, (Point)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); break; case GeometryType2.MultiPoint: //case "SharpMap.Geometries.MultiPoint": if (style.PointSymbolizer != null) { VectorRenderer.DrawMultiPoint(style.PointSymbolizer, g, (MultiPoint)feature, map); } if (style.Symbol != null || style.PointColor == null) { VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); } else { VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); } break; case GeometryType2.GeometryCollection: //case "SharpMap.Geometries.GeometryCollection": foreach (Geometry geom in (GeometryCollection)feature) { RenderGeometry(g, map, geom, style); } break; default: break; } }
protected void RenderGeometry(Graphics g, Map map, Geometry feature, VectorStyle layerstyle, RenderType renderType) { VectorStyle style = layerstyle; if (feature.StyleType == 1) { style = new VectorStyle(); style.EnableOutline = feature.EnableOutline; style.Fill = new SolidBrush(Color.FromArgb(feature.Fill)); style.Line = new Pen(Color.Black); if (feature.DashStyle >= 0 && feature.DashStyle <= 4) { style.Line.DashStyle = (DashStyle)(feature.DashStyle); } else { style.Line.DashStyle = DashStyle.Solid; } style.Outline = new Pen(Color.FromArgb(feature.Outline), feature.OutlineWidth); style.Outline.DashStyle = style.Line.DashStyle; style.HatchStyle = feature.HatchStyle; style.Penstyle = feature.Penstyle; } if (feature.PointSymbol != null) { style.PointSymbol = feature.PointSymbol; } if (feature.PointSelectSymbol != null) { style.PointSelectSymbol = feature.PointSelectSymbol; } if (style.Penstyle == 6) { style.Outline.CompoundArray = new float[] { 0, 2f / style.Outline.Width, 1 - 2f / style.Outline.Width, 1 }; } GeometryType2 geometryType = feature.GeometryType; string key = this.ID.ToString() + "_" + feature.ID.ToString(); switch (geometryType) { case GeometryType2.Polygon: Brush brush = style.Fill; if (PriceTable.ContainsKey(key)) { brush = PriceTable[key] as SolidBrush; } else if (GeometryColor.ContainsKey(feature)) { brush = new SolidBrush((Color)GeometryColor[feature]); } else if (style.HatchStyle >= 0) { brush = new HatchBrush((HatchStyle)style.HatchStyle, style.Outline.Color, style.Fill.Color); } if (style.EnableOutline) { VectorRenderer.DrawPolygon(g, (Polygon)feature, brush, style.Outline, _clippingEnabled, map, style, renderType, Type.ToString()); } else { VectorRenderer.DrawPolygon(g, (Polygon)feature, brush, null, _clippingEnabled, map, style, renderType, Type.ToString()); } break; case GeometryType2.MultiPolygon: Brush brush1 = style.Fill; if (PriceTable.ContainsKey(key)) { brush1 = PriceTable[key] as SolidBrush; } else if (GeometryColor.ContainsKey(feature)) { brush1 = new SolidBrush((Color)GeometryColor[feature]); } else if (style.HatchStyle >= 0) { brush1 = new HatchBrush((HatchStyle)style.HatchStyle, style.Outline.Color, style.Fill.Color); } if (style.EnableOutline) { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, brush1, style.Outline, _clippingEnabled, map, style, renderType, Type.ToString()); } else { VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, brush1, null, _clippingEnabled, map, style, renderType, Type.ToString()); } break; case GeometryType2.LineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (LineString)feature, g); return; } //VectorRenderer.zoom = zoom; VectorRenderer.DrawLineString(g, (LineString)feature, style.Outline, map, style.LineOffset, style, renderType); return; case GeometryType2.MultiLineString: if (style.LineSymbolizer != null) { style.LineSymbolizer.Render(map, (MultiLineString)feature, g); return; } VectorRenderer.DrawMultiLineString(g, (MultiLineString)feature, style.Outline, map, style.LineOffset, style, renderType); break; case GeometryType2.Point: if (style.PointSymbolizer != null) { VectorRenderer.DrawPoint(style.PointSymbolizer, g, (Point)feature, map, style, renderType); return; } if (style.Symbol != null || style.PointColor == null) { Image image = style.Symbol; Point point = (Point)feature; if (style.PointSymbol != null) { image = style.PointSymbol; if (point.Select && style.PointSelectSymbol != null) { image = style.PointSelectSymbol; } } if (point.IsAreaPriceMonitor) { if (style.PointPriceSymbol != null) { image = style.PointPriceSymbol; } if (point.Select && style.PointPriceSelectSymbol != null) { image = style.PointPriceSelectSymbol; } } VectorRenderer.DrawPoint(g, (Point)feature, image, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map, style, renderType); return; } VectorRenderer.DrawPoint(g, (Point)feature, style.PointColor, style.PointSize, style.SymbolOffset, map, style, renderType); break; case GeometryType2.MultiPoint: if (style.PointSymbolizer != null) { VectorRenderer.DrawMultiPoint(style.PointSymbolizer, g, (MultiPoint)feature, map, style, renderType); } if (style.Symbol != null || style.PointColor == null) { VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map, style, renderType); } else { VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map, style, renderType); } break; case GeometryType2.GeometryCollection: foreach (Geometry geom in (GeometryCollection)feature) { RenderGeometry(g, map, geom, style, renderType); } break; default: break; } }