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 } }
public void Draw(XGraphics gfx) { TransformsProvider tp = new TransformsProvider(gfx); XRect rect = tp.FromCmsToPts(new XRect(_Left, _Top, _Width, _Height)); if (this._fillColorName == Color.Transparent.Name) { gfx.DrawRectangle(new XPen(XColor.FromName(_lineColorName), _lineWidth), rect); } else { gfx.DrawRectangle(new XPen(XColor.FromName(_lineColorName), _lineWidth), new XSolidBrush(XColor.FromName(_fillColorName)), rect); } }
public void Draw(XGraphics gfx) { TransformsProvider tp = new TransformsProvider(gfx); XFont font = new XFont(this._fontFamilyName, this._fontSize, this._fontStyle); XSolidBrush brush = new XSolidBrush(XColor.FromName(this._fontColorName)); if (this._rect == XRect.Empty) { double x = tp.CmsToPts(this._x); double y = tp.CmsToPts(this._y); gfx.DrawString(this._text, font, brush, x, y, XStringFormat.TopLeft); } else { XRect rect = tp.FromCmsToPts(this._rect); gfx.DrawString(this._text, font, brush, rect, this._format); } }
public new void Draw(XGraphics gfx) { TransformsProvider tp = new TransformsProvider(gfx); XFont font = new XFont(this.FontFamilyName, this.FontSize, this.FontStyle); XSolidBrush brush = new XSolidBrush(XColor.FromName(this.FontColorName)); string txt = string.Format("{0} {1}", this._prefix, DateTime.Today.ToShortDateString()); if (base.Rect == XRect.Empty) { double x = tp.CmsToPts(this.X); double y = tp.CmsToPts(this.Y); gfx.DrawString(txt, font, brush, x, y, XStringFormat.TopLeft); } else { XRect rect = tp.FromCmsToPts(base.Rect); gfx.DrawString(txt, font, brush, rect, base.Format); } }
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 } }
public void Draw(XGraphics gfx) { TransformsProvider tp = new TransformsProvider(gfx); if (this._rect != XRect.Empty) { XRect rect = tp.FromCmsToPts(this._rect); //Margen de seguridad del 5% rect.Inflate(-((5 * rect.Width) / 100), -((5 * rect.Height) / 100)); try { System.IO.Stream imgStream = this.GetType().Assembly.GetManifestResourceStream(this._rscName); Image img = Image.FromStream(imgStream); gfx.DrawImage(XImage.FromGdiPlusImage(img), rect); imgStream.Close(); } catch { //Do nothing } } }
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); } } }
public void Draw(XGraphics gfx, BoundingBox geombox, XRect mapframe) { if (this._visible) { TransformsProvider tp = new TransformsProvider(gfx); double geomScaleFactor = tp.WorldToPaperScale(geombox, mapframe); XRect geomFrame = tp.WorldToPaperRect(geombox, mapframe); double mapWorldXmin = geombox.Left - ((geomFrame.Left - mapframe.Left) / geomScaleFactor); double mapWorldYmin = geombox.Bottom - ((mapframe.Bottom - geomFrame.Bottom) / geomScaleFactor); double mapWorldXmax = geombox.Right + ((mapframe.Right - geomFrame.Right) / geomScaleFactor); double mapWorldYmax = geombox.Top + ((geomFrame.Top - mapframe.Top) / geomScaleFactor); XFont font = new XFont(this._fontFamilyName, this._fontSize, this._fontStyle); XBrush fontColor = new XSolidBrush(XColor.FromName(this._fontColorName)); XColor tickColor = XColor.FromName(this._tickColorName); gfx.DrawString(mapWorldXmin.ToString("0.00"), font, fontColor, mapframe.Left, mapframe.Top - (this._fontSize / 2), XStringFormat.BottomCenter); gfx.DrawString(mapWorldXmin.ToString("0.00"), font, fontColor, mapframe.Left, mapframe.Bottom + (this._fontSize / 2), XStringFormat.TopCenter); gfx.DrawString(mapWorldXmax.ToString("0.00"), font, fontColor, mapframe.Right, mapframe.Top - (this._fontSize / 2), XStringFormat.BottomCenter); gfx.DrawString(mapWorldXmax.ToString("0.00"), font, fontColor, mapframe.Right, mapframe.Bottom + (this._fontSize / 2), XStringFormat.TopCenter); gfx.DrawString(mapWorldYmin.ToString("0.00"), font, fontColor, mapframe.Left, mapframe.Bottom - (this._fontSize / 2), XStringFormat.BottomCenter); gfx.DrawString(mapWorldYmin.ToString("0.00"), font, fontColor, mapframe.Right, mapframe.Bottom - (this._fontSize / 2), XStringFormat.BottomCenter); gfx.DrawString(mapWorldYmax.ToString("0.00"), font, fontColor, mapframe.Left, mapframe.Top + (this._fontSize / 2), XStringFormat.TopCenter); gfx.DrawString(mapWorldYmax.ToString("0.00"), font, fontColor, mapframe.Right, mapframe.Top + (this._fontSize / 2), XStringFormat.TopCenter); gfx.DrawLine(new XPen(tickColor), mapframe.Left - (this._fontSize / 2), mapframe.Top, mapframe.Left + (this._fontSize / 2), mapframe.Top); gfx.DrawLine(new XPen(tickColor), mapframe.Left, mapframe.Top - (this._fontSize / 2), mapframe.Left, mapframe.Top + (this._fontSize / 2)); gfx.DrawLine(new XPen(tickColor), mapframe.Right - (this._fontSize / 2), mapframe.Top, mapframe.Right + (this._fontSize / 2), mapframe.Top); gfx.DrawLine(new XPen(tickColor), mapframe.Right, mapframe.Top - (this._fontSize / 2), mapframe.Right, mapframe.Top + (this._fontSize / 2)); gfx.DrawLine(new XPen(tickColor), mapframe.Left - (this._fontSize / 2), mapframe.Bottom, mapframe.Left + (this._fontSize / 2), mapframe.Bottom); gfx.DrawLine(new XPen(tickColor), mapframe.Left, mapframe.Bottom - (this._fontSize / 2), mapframe.Left, mapframe.Bottom + (this._fontSize / 2)); gfx.DrawLine(new XPen(tickColor), mapframe.Right - (this._fontSize / 2), mapframe.Bottom, mapframe.Right + (this._fontSize / 2), mapframe.Bottom); gfx.DrawLine(new XPen(tickColor), mapframe.Right, mapframe.Bottom - (this._fontSize / 2), mapframe.Right, mapframe.Bottom + (this._fontSize / 2)); //Algoritmo de cálculo de TickMarcks (4 intervalos) double sfX = mapframe.Width / (mapWorldXmax - mapWorldXmin); double tx = (mapWorldXmax - mapWorldXmin) / 4; double tx2 = tx + 10 - (tx % 10); double xtick = mapWorldXmin + tx2 - (mapWorldXmin % tx2); while (xtick < mapWorldXmax) { double xtickPts = mapframe.Left + ((xtick - mapWorldXmin) * sfX); //Control para evitar superposición de textos if ((xtickPts - mapframe.Left) > (this._fontSize * 9) & (mapframe.Right - xtickPts) > (this._fontSize * 9)) { gfx.DrawLine(new XPen(tickColor), xtickPts, mapframe.Top - (this._fontSize / 2), xtickPts, mapframe.Top); gfx.DrawString(xtick.ToString("0"), font, fontColor, xtickPts, mapframe.Top - (_fontSize / 2), XStringFormat.BottomCenter); gfx.DrawLine(new XPen(tickColor), xtickPts, mapframe.Bottom + (this._fontSize / 2), xtickPts, mapframe.Bottom); gfx.DrawString(xtick.ToString("0"), font, fontColor, xtickPts, mapframe.Bottom + (this._fontSize / 2), XStringFormat.TopCenter); } xtick += tx2; } double sfY = mapframe.Height / (mapWorldYmax - mapWorldYmin); double ty = (mapWorldYmax - mapWorldYmin) / 4; double ty2 = ty + 10 - (ty % 10); double ytick = mapWorldYmin + ty2 - (mapWorldYmin % ty2); while (ytick < mapWorldYmax) { double ytickPts = mapframe.Bottom - ((ytick - mapWorldYmin) * sfY); //Control para evitar superposición de textos if ((ytickPts - mapframe.Top) > (this._fontSize * 9) & (mapframe.Bottom - ytickPts) > (this._fontSize * 9)) { gfx.DrawLine(new XPen(tickColor), mapframe.Left - (this._fontSize / 2), ytickPts, mapframe.Left, ytickPts); gfx.DrawString(ytick.ToString("0"), font, fontColor, mapframe.Left, ytickPts - (this._fontSize / 2), XStringFormat.BottomCenter); gfx.DrawLine(new XPen(tickColor), mapframe.Right + (this._fontSize / 2), ytickPts, mapframe.Right, ytickPts); gfx.DrawString(ytick.ToString("0"), font, fontColor, mapframe.Right, ytickPts - (this._fontSize / 2), XStringFormat.BottomCenter); } ytick += ty2; } } }
public void Draw(XGraphics gfx, object param) { TransformsProvider tp = new TransformsProvider(gfx); XFont font = new XFont(this.FontFamilyName, this.FontSize, this.FontStyle); XSolidBrush brush = new XSolidBrush(XColor.FromName(this.FontColorName)); string s = string.Empty; if (param is DBNull) { s = string.Format("{0} {1} {2}", this._prefix, string.Empty, this._subfix); } if (param is string) { switch (_bindPropertyFormat) { case ValueParsingOption.None: s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim(); break; case ValueParsingOption.ParseInteger: int intVal; if (int.TryParse((string)param, out intVal)) { s = string.Format("{0} {1} {2}", this._prefix, intVal.ToString("#,###"), this._subfix).Trim(); } else { s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim(); } break; case ValueParsingOption.ParseFloat: double floatVal; CultureInfo culture = null; try { culture = CultureInfo.GetCultureInfo(this._bindPropertyCultureName); } catch { //Do nothing } if (culture == null) { s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim(); } else { if (double.TryParse((string)param, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, culture, out floatVal)) { s = string.Format("{0} {1} {2}", this._prefix, floatVal.ToString("#,###.##"), this._subfix).Trim(); } else { s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim(); } } break; } } if (param is int) { int intVal = (int)param; s = string.Format("{0} {1} {2}", this._prefix, (intVal).ToString("#,###"), this._subfix).Trim(); } if ((param is double) || (param is float)) { double floatVal = (double)param; s = string.Format("{0} {1} {2}", this._prefix, floatVal.ToString("#,###.##"), this._subfix).Trim(); } if (base.Rect == XRect.Empty) { double x = tp.CmsToPts(this.X); double y = tp.CmsToPts(this.Y); gfx.DrawString(s, font, brush, x, y, XStringFormat.TopLeft); } else { XRect rect = tp.FromCmsToPts(base.Rect); gfx.DrawString(s, font, brush, rect, base.Format); } }
public void Draw(XGraphics gfx, double mapSF) { if (_visible) { TransformsProvider tp = new TransformsProvider(gfx); double x = 0.0; double y = 0.0; double width = this._intervalSize * mapSF; XBrush fillColor = new XSolidBrush(XColor.FromName(this._fillColorName)); XFont font = new XFont(_fontFamilyName, _fontSize, _fontStyle); XBrush fontColor = new XSolidBrush(XColor.FromName(this._fontColorName)); XRect firstInterval = XRect.Empty; switch (Anchor) { case AnchorType.TopLeft: x = tp.CmsToPts(this._x); y = tp.CmsToPts(_y) + font.Height; break; case AnchorType.BottomLeft: x = tp.CmsToPts(this._x); y = tp.CmsToPts(_y) - this._height; break; case AnchorType.TopRight: x = tp.CmsToPts(this._x) - (width * this._numIntervals) - (font.Size * 1.5) - ((this._unit.Length + 1) * font.Size); y = tp.CmsToPts(_y) + font.Height; break; case AnchorType.BottomRight: x = tp.CmsToPts(this._x) - (width * this._numIntervals) - (font.Size * 1.5) - ((this._unit.Length + 1) * font.Size); y = tp.CmsToPts(_y) - this._height; break; default: x = tp.CmsToPts(this._x); y = tp.CmsToPts(_y) - this._height; break; } for (int i = 0; i <= this._numIntervals - 1; i++) { if (i == 0) { firstInterval = new XRect(x, y, width, this._height); gfx.DrawRectangle(new XPen(XColors.Black), firstInterval); } else { if (i % 2 == 0) { gfx.DrawRectangle(new XPen(XColors.Black), x + (width * i), y, width, this._height); } else { gfx.DrawRectangle(new XPen(XColors.Black), fillColor, x + (width * i), y, width, this._height); } } } x = firstInterval.Left; y = firstInterval.Top - font.Height; for (int i = 1; i <= this._numIntervals; i++) { gfx.DrawString((this._intervalSize * i).ToString(), font, fontColor, x + (width * i), y, XStringFormat.TopCenter); } gfx.DrawString(this._unit, font, fontColor, x + (width * this._numIntervals) + (font.Size * 1.5), y, XStringFormat.TopLeft); } }
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); } } } } }
public void Draw(XGraphics gfx, Map map) { TransformsProvider tp = new TransformsProvider(gfx); XRect rect = tp.FromCmsToPts(new XRect(this.Left, this.Top, this.Width, this.Height)); double geomScaleFactor; geomScaleFactor = tp.WorldToPaperScale(map.GetExtents(), rect); XRect geomFrame = tp.WorldToPaperRect(map.GetExtents(), rect); XGraphicsState state = gfx.Save(); gfx.TranslateTransform(geomFrame.X, geomFrame.Bottom); if (this._cacheIsEmpty) { foreach (Layer lyr in map.Layers) { if ((lyr) is VectorLayer) { if (this._overrideVectorLayerStyle) { this.DrawVectorLayer(gfx, map, geomScaleFactor, (VectorLayer)lyr, this._geomLineColorName, this._geomLineWidth, this._geomFillColorName); } else { if ((lyr as VectorLayer).Theme == null) { this.DrawVectorLayer(gfx, map, geomScaleFactor, (VectorLayer)lyr); } else { this.DrawThemeLayer(gfx, map, geomScaleFactor, (VectorLayer)lyr); } } } if (lyr is LabelLayer) { if (this._overrideLabelLayerStyle) { this.DrawLabelLayer(gfx, map, geomScaleFactor, (LabelLayer)lyr, _labelFontFamilyName, _labelFontSize, _labelFontStyle, _labelFontColorName); } else { LabelStyle simb = (lyr as LabelLayer).Style; this.DrawLabelLayer(gfx, map, geomScaleFactor, (LabelLayer)lyr, simb.Font.FontFamily.Name, simb.Font.Size, (XFontStyle)simb.Font.Style, simb.ForeColor.Name); } } } this._cacheIsEmpty = false; } else { foreach (PDFGeom g in this._geomCache) { if (g.FillStyle == null) { gfx.DrawPath(g.LineStyle, g.Geometry); } else if (g.LineStyle == null) { gfx.DrawPath(g.FillStyle, g.Geometry); } else { gfx.DrawPath(g.LineStyle, g.FillStyle, g.Geometry); } } foreach (PDFLabel l in this._labelCache) { gfx.DrawString(l.Text, l.Font, l.Brush, l.Point, XStringFormat.Center); } } gfx.Restore(state); _scale.Draw(gfx, geomScaleFactor); _geomarks.Draw(gfx, map.GetExtents(), rect); }