public void Render(object sender, IDrawArgs drawArgs) { //左上角绘制信息列表 if (_infoItems.Count == 0) { return; } Graphics g = drawArgs.Graphics as Graphics; float x = 50; float y = 10; SizeF fontSize = g.MeasureString("100", _font); int rowStep = (int)(fontSize.Height + 2); foreach (InfoItem item in _infoItems) { g.DrawString(item.ToString(), _font, Brushes.Yellow, x, y); y += rowStep; } ICanvas canvas = sender as ICanvas; if (_visible) { ICoordinateTransform coordTran = canvas.CoordTransform; QuickTransform qt = drawArgs.QuickTransformArgs; //绘制拐点 foreach (InfoItem item in _infoItems) { int row = 0, col = 0; double geoX, geoY; coordTran.Geo2Prj(item.Longitude, item.Latitude, out geoX, out geoY); coordTran.Prj2Screen(geoX, geoY, out col, out row); g.FillEllipse(Brushes.Yellow, new RectangleF(col - 3, row - 3, 6, 6)); } //绘制冰缘线 if (_geoItems != null) { foreach (CodeCell.AgileMap.Core.Feature items in _geoItems) { GraphicsPath path = ToGraphicsPath(items, canvas); g.DrawPath(Pens.Red, path); } } } }
private static Core.DrawEngine.CoordEnvelope GetDrawingEnvelop(ICanvas canvas, IRasterDataProvider prd) { if (prd == null) { return(null); } GeoDo.RSS.Core.DF.CoordEnvelope cop = prd.CoordEnvelope.Clone(); ICoordinateTransform tans = canvas.CoordTransform; if (prd.CoordType == enumCoordType.PrjCoord) { return(new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(cop.MinX, cop.MaxX, cop.MinY, cop.MaxY)); } else { GeoDo.RSS.Core.DrawEngine.CoordEnvelope prjEvp = new Core.DrawEngine.CoordEnvelope(cop.MinX, cop.MaxX, cop.MinY, cop.MaxY); tans.Geo2Prj(prjEvp); return(prjEvp); } }
private void ComputeGridLines(ICoordinateTransform coordTran) { try { if (_gridLines != null) { _gridLines.Clear(); } else { _gridLines = new List <GridLine>(); } double span = _gridSpan; int idx = 0; double prjX, prjY; double maxLon = 0d; double maxLat = 0d; double x = 0d, y = 0d; //sample lon lines foreach (Range range in _validLonRanges) { x = Math.Max(range.MinValue, _beginLon); y = 0; maxLon = Math.Min(range.MaxValue, _endLon); maxLat = 0; while (x <= maxLon) { y = Math.Max(_validLatRange.MinValue, _beginLat); GridLine gridLine = new GridLine(); gridLine.BeginIndex = idx; maxLat = Math.Min(_validLatRange.MaxValue, _endLat); while (y <= maxLat) { coordTran.Geo2Prj(x, y, out prjX, out prjY); _allPrjPoints[idx].X = (float)prjX; _allPrjPoints[idx].Y = (float)prjY; idx++; y += span; } gridLine.SegmentCount = idx - gridLine.BeginIndex; _gridLines.Add(gridLine); x += span; } } _lonLines = _gridLines.Count; foreach (Range range in _validLonRanges) { //sample lat lines y = _validLatRange.MinValue; maxLat = Math.Min(_validLatRange.MaxValue, _endLat); while (y <= _validLatRange.MaxValue) { GridLine gridLine = new GridLine(); gridLine.BeginIndex = idx; x = range.MinValue; maxLon = Math.Min(range.MaxValue, _endLon); while (x <= maxLon) { coordTran.Geo2Prj(x, y, out prjX, out prjY); _allPrjPoints[idx].X = (float)prjX; _allPrjPoints[idx].Y = (float)prjY; idx++; x += span; } gridLine.SegmentCount = idx - gridLine.BeginIndex; _gridLines.Add(gridLine); y += span; } } _latLines = _gridLines.Count - _lonLines; } catch (Exception ex) { Console.WriteLine(ex.Message); } }