private void DrawThemeLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr) { TransformsProvider tp = new TransformsProvider(gfx); BoundingBox geombox = map.GetExtents(); FeatureDataSet fds = new FeatureDataSet(); try { lyr.DataSource.ExecuteIntersectionQuery(geombox, fds); FeatureDataTable fdt = fds.Tables[0]; for (int i = 0; i < fdt.Count; i++) { FeatureDataRow fdr = fdt[i]; VectorStyle s = (VectorStyle)lyr.Theme.GetStyle(fdr); Geometry geom = fdr.Geometry; XPen xp = new XPen(XColor.FromArgb(s.Outline.Color), s.Outline.Width); xp.DashStyle = (XDashStyle)s.Outline.DashStyle; XSolidBrush xb = null; if (geom is MultiLineString) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox); this._geomCache.Add(new PDFGeom(g, xp, null)); gfx.DrawPath(xp, g); } if (geom is MultiPolygon) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox); if (s.Fill != null) { if ((s.Fill) is SolidBrush) { xb = new XSolidBrush(XColor.FromArgb((s.Fill as SolidBrush).Color)); } else { xb = new XSolidBrush(XColor.FromKnownColor(KnownColor.Transparent)); } this._geomCache.Add(new PDFGeom(g, xp, xb)); gfx.DrawPath(xp, xb, g); } else { this._geomCache.Add(new PDFGeom(g, xp, null)); gfx.DrawPath(xp, g); } } } } catch { //Do nothing, no render } }
private void DrawVectorLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr, string lineColor, double lineWidth, string fillColor) { TransformsProvider tp = new TransformsProvider(gfx); BoundingBox geombox = map.GetExtents(); XPen xp = new XPen(XColor.FromName(lineColor), lineWidth); XSolidBrush xb = new XSolidBrush(XColor.FromName(fillColor)); foreach (Geometry geom in (lyr as VectorLayer).DataSource.GetGeometriesInView(geombox)) { if ((geom) is MultiLineString) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox); this._geomCache.Add(new PDFGeom(g, xp, null)); gfx.DrawPath(xp, g); } if ((geom) is MultiPolygon) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox); this._geomCache.Add(new PDFGeom(g, xp, xb)); gfx.DrawPath(xp, xb, g); } } }
private void DrawLabelLayer(XGraphics gfx, Map map, double scaleFactor, LabelLayer lyr, string fontFamily, double fontSize, XFontStyle fontStyle, string fontColor) { TransformsProvider tp = new TransformsProvider(gfx); BoundingBox geombox = map.GetExtents(); XFont font = new XFont(fontFamily, fontSize, fontStyle); XSolidBrush brush = new XSolidBrush(XColor.FromName(fontColor)); FeatureDataSet fds = new FeatureDataSet(); try { lyr.DataSource.ExecuteIntersectionQuery(geombox, fds); FeatureDataTable fdt = fds.Tables[0]; for (int i = 0; i < fdt.Count; i++) { FeatureDataRow fdr = fdt[i]; object s = string.Empty; if (lyr.LabelStringDelegate == null) { s = fdr[lyr.LabelColumn]; } else { s = lyr.LabelStringDelegate(fdr); } Geometry geom = fdr.Geometry; if ((geom) is SharpMap.Geometries.Point) { XPoint p = tp.TransformGeom(scaleFactor, (SharpMap.Geometries.Point)geom, geombox); this._labelCache.Add(new PDFLabel(s.ToString(), p, font, brush)); gfx.DrawString(s.ToString(), font, brush, p, XStringFormat.Center); } } } catch { //Do nothing, no render } }
private void DrawVectorLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr) { TransformsProvider tp = new TransformsProvider(gfx); BoundingBox geombox = map.GetExtents(); XPen xp = new XPen(XColor.FromArgb(lyr.Style.Outline.Color), lyr.Style.Outline.Width); xp.DashStyle = (XDashStyle)lyr.Style.Outline.DashStyle; XSolidBrush xb = null; foreach (Geometry geom in lyr.DataSource.GetGeometriesInView(geombox)) { if (geom is MultiLineString) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox); this._geomCache.Add(new PDFGeom(g, xp, null)); gfx.DrawPath(xp, g); } if (geom is MultiPolygon) { XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox); if (lyr.Style.EnableOutline) { if (lyr.Style.Fill != null) { if ((lyr.Style.Fill) is SolidBrush) { xb = new XSolidBrush(XColor.FromArgb((lyr.Style.Fill as SolidBrush).Color)); } else { xb = new XSolidBrush(XColor.FromKnownColor(KnownColor.Transparent)); } this._geomCache.Add(new PDFGeom(g, xp, xb)); gfx.DrawPath(xp, xb, g); } else { this._geomCache.Add(new PDFGeom(g, xp, null)); gfx.DrawPath(xp, g); } } else { if (lyr.Style.Fill != null) { if ((lyr.Style.Fill) is SolidBrush) { xb = new XSolidBrush(XColor.FromArgb((lyr.Style.Fill as SolidBrush).Color)); } else { xb = new XSolidBrush(XColor.FromKnownColor(KnownColor.Transparent)); } this._geomCache.Add(new PDFGeom(g, null, xb)); gfx.DrawPath(xb, g); } } } } }