private void CreatBitmap(IDrawArgs drawArgs) { if (_scale != _perScale || _perScale == 0 || _preSize != _size) { if (_scaleBarBmpCache != null) { _scaleBarBmpCache.Dispose(); } _scaleBarBmpCache = GetScaleBarBitmap(drawArgs, _size.Width, _size.Height); _perScale = _scale; _preSize = _size; } }
public override void Render(object sender, IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null || _action != enumAction.SelectByRect) { return; } g.DrawRectangle(Pens.CornflowerBlue, Math.Min(_beginPointScreen.X, _crtPointScreen.X), Math.Min(_beginPointScreen.Y, _crtPointScreen.Y), Math.Abs(_beginPointScreen.X - _crtPointScreen.X), Math.Abs(_beginPointScreen.Y - _crtPointScreen.Y)); }
public virtual void EndRotate(IDrawArgs drawArgs) { DrawLockIcon(drawArgs); if (_angle < float.Epsilon) { return; } Graphics g = drawArgs.Graphics as Graphics; g.Transform.Dispose(); g.Transform = _oldMatrix; _oldMatrix = null; }
private void RenderFreeCurve(object sender, IDrawArgs drawArgs) { if (_vertexts.Count < 3) { return; } Graphics g = drawArgs.Graphics as Graphics; using (GraphicsPath path = GetGraphicsPath()) { g.DrawPath(_pen, path); } }
public void DrawLockIcon(IDrawArgs drawArgs) { if (_isLocked && !DrawArgs.IsExporting) { if (_lockImage == null) { _lockImage = Bitmap.FromStream((typeof(SizableElement)).Assembly.GetManifestResourceStream("GeoDo.RSS.Layout.Lock.png")); } float x = _location.X, y = _location.Y, w = _size.Width, h = _size.Height; drawArgs.Runtime.Layout2Screen(ref x, ref y); (drawArgs.Graphics as Graphics).DrawImage(_lockImage, x, y); } }
private void RenderRectangle(object sender, IDrawArgs drawArgs) { if (_prePoint.IsEmpty || _crtPoint.IsEmpty) { return; } Graphics g = drawArgs.Graphics as Graphics; using (GraphicsPath path = GetGraphicsPath()) { g.DrawPath(_pen, path); } }
public override void Render(object sender, IDrawArgs drawArgs) { if (_elements == null || _elements.Count == 0) { return; } foreach (IElement ele in _elements) { if (ele.Visible) { ele.Render(sender, drawArgs); } } }
public void Render(object sender, IDrawArgs drawArgs) { ICanvas canvas = sender as ICanvas; if (canvas.PrimaryDrawObject == null || canvas.IsReverseDirection) { return; } Graphics g = drawArgs.Graphics as Graphics; IPrimaryDrawObject primaryObj = canvas.PrimaryDrawObject; int rasterWidth = primaryObj.Size.Width; int rasterHeight = primaryObj.Size.Height; DrawBarsAndRulers(rasterWidth, rasterHeight, g, canvas); }
public void Render(object sender, IDrawArgs drawArgs) { if (_canvas == null) { _canvas = sender as ICanvas; } if (_drawing == null) { return; } //Console.WriteLine("RenderRasterLayer:" + _canvas.CurrentEnvelope.ToString()); Bitmap bitmap = GetBitmap(drawArgs); DrawBitmap(bitmap, drawArgs); }
public override void Render(object sender, IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null) { return; } ILayoutRuntime runtime = sender as ILayoutRuntime; if (runtime == null) { return; } BeginRotate(drawArgs); if (_preSize != _size) { CreatBitmap(drawArgs, g); } if (_legendBmp == null) { return; } try { float x = _location.X, y = _location.Y; drawArgs.Runtime.Layout2Screen(ref x, ref y); float scale = runtime.Scale; float newWidth = _size.Width * scale + 0.1f; float newHeight = _size.Height * scale + 0.1f; if (newWidth < 1 || newHeight < 1 || newWidth > 10000 || newHeight > 10000) { return; } using (Bitmap bm = new Bitmap((int)newWidth, (int)newHeight)) { using (Graphics g1 = Graphics.FromImage(bm)) { g1.DrawImage(_legendBmp, 0, 0, bm.Width, bm.Height); } g.DrawImage(bm, (int)x, (int)y); } } finally { EndRotate(drawArgs); } }
public void Render(object sender, IDrawArgs drawArgs) { if (_cntLines == null || _cntLines.Length == 0 || _contourClassItems == null || _contourClassItems.Length == 0) { return; } if (_canvas == null) { _canvas = sender as ICanvas; _canvasSizeChanged = new EventHandler(Container_SizeChanged); _canvas.OnEnvelopeChanged += _canvasSizeChanged; _conflictor = new PixelConflictor(_canvas.Container.Size); } CoordEnvelope evp = _canvas.CurrentEnvelope; _crtCanvasEnvelope = new ContourLine.ContourEnvelope((float)evp.MinX, (float)evp.MaxX, (float)evp.MinY, (float)evp.MaxY); TryUpdateLabelBuffers(drawArgs); TryProject(); TrySetSmoothMode(drawArgs); TryResetConflictor(); float minWidth = MIN_WIDTH * _canvas.ResolutionX; float minHeight = MIN_WIDTH * _canvas.ResolutionY; ContourLine.ContourEnvelope thisEvp = null; int classIdx = 0; ContourClass cntClass = null; foreach (ContourLine cntLine in _cntLines) { if (cntLine == null) { continue; } classIdx = cntLine.ClassIndex; cntClass = _contourClassItems[classIdx]; thisEvp = cntLine.Envelope; //如果不在可视区域则绘制 if (!_crtCanvasEnvelope.IsInteractived(thisEvp)) { continue; } //如果在当前比例尺下太小则不显示 if (thisEvp.Width > minWidth || thisEvp.Height > minHeight) { DrawContour(drawArgs, cntLine, cntClass, _canvas); } } }
public void Render(object sender, IDrawArgs drawArgs) { if (_geometrys.Count == 0) { return; } Graphics g = drawArgs.Graphics as Graphics; ICanvas canvas = sender as ICanvas; foreach (object geo in _geometrys) { GraphicsPath path = ToGraphicsPath(geo, canvas); if (path == null) { continue; } g.DrawPath(_pen, path); // EditObject eobj; if (!_editObjects.ContainsKey(geo)) { eobj = new EditObject(); eobj.Geometry = geo; _editObjects.Add(geo, eobj); } else { eobj = _editObjects[geo]; } if (eobj.Path != null) { eobj.Path.Dispose(); } eobj.Path = path; // if (_isAllowEdit) { Brush boxBrush = eobj.IsSelected ? Brushes.Green : Brushes.Red; for (int i = 0; i < path.PointCount; i++) { g.FillRectangle(boxBrush, path.PathPoints[i].X - EDIT_BOX_HALF_WIDTH, path.PathPoints[i].Y - EDIT_BOX_HALF_WIDTH, EDIT_BOX_WIDTH, EDIT_BOX_WIDTH); } } } }
private void TryUpdateLabelBuffers(IDrawArgs arg) { if (!_isLabel || _contourClassItems == null || _contourClassItems.Length == 0) { return; } Graphics g = arg.Graphics as Graphics; foreach (ContourClass item in _contourClassItems) { if (item.LabelBuffer == null) { item.UpdateLabelBuffer(g, _font, _labelBrush, _maskBrush, _labelFormat); } } }
private void DrawFeature(Feature fet, Graphics g, IDrawArgs drawArgs, Brush brush) { if (fet == null) { return; } if (!fet.Projected) { ProjectFeature(fet); } Shape geometry = fet.Geometry; if (geometry is ShapePolygon) { _graphicsPath.Reset(); ShapePolygon plygon = geometry as ShapePolygon; ShapeRing[] rings = plygon.Rings; int length = rings.Length; Point[] pts = null; int errorCount = 0; for (int i = 0; i < length; i++) { try { pts = ToScreenPoints(rings[i].Points, drawArgs); if (pts != null && pts.Length > 3) { //_graphicsPath.AddPolygon(pts); g.FillPolygon(brush, pts); } } catch { errorCount++; if (errorCount > 10) { break; } else { continue; } } } //g.FillPath(brush, _graphicsPath); } }
private void RenderCircle(object sender, IDrawArgs drawArgs) { if (!_isDrawing || _prePoint.IsEmpty || _crtPoint.IsEmpty) { return; } Graphics g = drawArgs.Graphics as Graphics; using (GraphicsPath path = GetGraphicsPath()) { if (path == null) { return; } g.DrawPath(_pen, path); } }
private void DrawBitmap(IDrawArgs drawArgs) { if (_currentBmp == null) { return; } _enp = _currentBmp.Envelop; double x1 = _enp.MinX; double y1 = _enp.MinY; double x2 = _enp.MaxX; double y2 = _enp.MaxY; drawArgs.QuickTransformArgs.Transform(ref x1, ref y1); drawArgs.QuickTransformArgs.Transform(ref x2, ref y2); (drawArgs.Graphics as Graphics).DrawImage(_currentBmp.Bitmap, new PointF[] { new PointF((float)x1, (float)y2), new PointF((float)x2, (float)y2), new PointF((float)x1, (float)y1) }, new RectangleF(0, 0, _currentBmp.Bitmap.Width, _currentBmp.Bitmap.Height), GraphicsUnit.Pixel, _ia); }
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); } } } }
public void Render(object sender, IDrawArgs drawArgs) { if (_coordTransform == null) { _coordTransform = (sender as ICanvas).CoordTransform; } ICanvas canvas = sender as ICanvas; TryLoadFeatures(canvas); Graphics g = drawArgs.Graphics as Graphics; //draw sea g.Clear(_seaColor); //draw land DrawFeatures(g, drawArgs, _landBrush, _features); //draw waterbody DrawFeatures(g, drawArgs, _seaBrush, _waterBodyFeatures); }
public override void Render(object sender, IDrawArgs drawArgs) { if (!_visible) { return; } if (_startLocation.IsEmpty && _endLocation.IsEmpty) { return; } Graphics g = drawArgs.Graphics as Graphics; g.DrawRectangle(Pens.SkyBlue, Math.Min(_startLocation.X, _endLocation.X), Math.Min(_startLocation.Y, _endLocation.Y), Math.Abs(_startLocation.X - _endLocation.X), Math.Abs(_startLocation.Y - _endLocation.Y)); }
public void Render(object sender, IDrawArgs drawArgs) { if (_canvas == null) { _canvas = sender as ICanvas; } if (_bobjs == null || _bobjs.Length == 0) { return; } int count = _bobjs.Length; if (_currentBmp == null) { return; } DrawBitmap(drawArgs); }
public void Render(object sender, IDrawArgs drawArgs) { if (drawArgs.Graphics == null) { return; } if (_bPoint.IsEmpty || _prePoint.IsEmpty) { return; } Graphics g = drawArgs.Graphics as Graphics; int x = Math.Min(_bPoint.X, _prePoint.X); int y = Math.Min(_bPoint.Y, _prePoint.Y); int w = Math.Abs(_bPoint.X - _prePoint.X); int h = Math.Abs(_bPoint.Y - _prePoint.Y); g.DrawRectangle(Pens.Red, x, y, w, h); }
private void RenderControlFreeCurve(object sender, IDrawArgs drawArgs) { if (_vertexts.Count < 3) { return; } Graphics g = drawArgs.Graphics as Graphics; g.SmoothingMode = SmoothingMode.HighQuality; using (GraphicsPath path = GetGraphicsPath()) { g.DrawPath(_pen, path); } //画拐点 for (int i = 0; i < _controls.Count; i++) { g.FillEllipse(Brushes.Yellow, new Rectangle(_controls[i].X - 3, _controls[i].Y - 3, 6, 6)); } }
public void Render(object sender, IDrawArgs drawArgs) { if (_changing) { return; } if (_maskPoints.Count == 0) { return; } Graphics g = drawArgs.Graphics as Graphics; ICanvas canvas = sender as ICanvas; Point[] screenpts = RasterToScreen(_maskPoints.Values.ToArray(), canvas); foreach (PointF geo in screenpts) { //g.FillRectangle(_brush, geo.X - 2, geo.Y - 2, 4, 4); g.DrawRectangle(_pen, geo.X - 2, geo.Y - 2, 4, 4); } }
public override void Render(object sender, IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null) { return; } ILayoutRuntime runtime = sender as ILayoutRuntime; float screenX = _location.X, screenY = _location.Y; runtime.Layout2Screen(ref screenX, ref screenY); //Pen p = new Pen(Brushes.Black); //p.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset; //注释掉的语句不起作用,因此为了保证右边和下边的边框能够被导出,特意减了1 float w = _size.Width, h = _size.Height; runtime.Layout2Pixel(ref w, ref h); if (DrawArgs.IsExporting) { if (_backColor != Color.Empty && _brush != null) { g.FillRectangle(_brush, screenX, screenY, w * runtime.Scale - 1, h * runtime.Scale - 1); } if (_isShowBorderLine) { g.DrawRectangle(Pens.Black, screenX, screenY, w * runtime.Scale - 1, h * runtime.Scale - 1); } } else { if (_backColor != Color.Empty && _brush != null) { g.FillRectangle(_brush, screenX, screenY, w * runtime.Scale - 1, h * runtime.Scale - 1); } if (_isShowBorderLine) { g.DrawRectangle(Pens.Black, screenX, screenY, w * runtime.Scale, h * runtime.Scale); } } }
private unsafe Point[] ToScreenPoints(ShapePoint[] shapePoints, IDrawArgs drawArgs) { Point[] pts = new Point[shapePoints.Length]; fixed(Point *ptrPointer = pts) { Point *ptr = ptrPointer; double x = 0, y = 0; int pointCount = shapePoints.Length; for (int i = 0; i < pointCount; i++, ptr++) { x = shapePoints[i].X; y = shapePoints[i].Y; drawArgs.QuickTransformArgs.Transform(ref x, ref y); ptr->X = (int)x; ptr->Y = (int)y; } } return(pts); }
protected virtual void BeginRotate(IDrawArgs drawArgs) { if (Math.Abs(_angle) < float.Epsilon) { return; } while (_angle > 360) { _angle -= 360; } ; while (_angle < 0) { _angle += 360; } ; Graphics g = drawArgs.Graphics as Graphics; ILayoutRuntime runtime = drawArgs.Runtime; setAgleLine: if (_matrix != null) { _matrix.Reset(); float x = _location.X + _size.Width / 2; float y = _location.Y + _size.Height / 2; runtime.Layout2Screen(ref x, ref y); _matrix.RotateAt(_angle, new PointF(x, y)); } else { _matrix = new Matrix(); goto setAgleLine; } _oldMatrix = g.Transform; Matrix c = _matrix.Clone(); c.Multiply(_oldMatrix, MatrixOrder.Append); g.Transform = c; }
public override void Render(object sender, IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null) { return; } BeginRotate(drawArgs); try { float x = _location.X, y = _location.Y, w = _size.Width, h = _size.Height; drawArgs.Runtime.Layout2Screen(ref x, ref y); drawArgs.Runtime.Layout2Screen(ref w); drawArgs.Runtime.Layout2Screen(ref h); DrawLegend(g, x, y, w, h); } finally { EndRotate(drawArgs); } }
public override void Render(object sender, IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null) return; ILayoutRuntime runtime = sender as ILayoutRuntime; if (runtime == null) return; BeginRotate(drawArgs); if (_preSize != _size) { CreatBitmap(drawArgs); } if (_bmp == null) return; try { float x = _location.X, y = _location.Y; drawArgs.Runtime.Layout2Screen(ref x, ref y); float scale = runtime.Scale; int newWidth = (int)(_size.Width * scale + 0.1f); int newHeight = (int)(_size.Height * scale + 0.1f); if (newWidth < 1 || newHeight < 1 || newWidth > 10000 || newHeight > 10000) return; using (Bitmap bm = new Bitmap(newWidth, newHeight)) { using (Graphics gsp = Graphics.FromImage(bm)) { gsp.DrawImage(_bmp, new Rectangle(0, 0, bm.Width, bm.Height)); } g.DrawImage(bm, x, y); } } finally { EndRotate(drawArgs); } }
public void Render(object sender, IDrawArgs drawArgs) { //if (_geometrys.Count == 0) // return; //Graphics g = drawArgs.Graphics as Graphics; //ICanvas canvas = sender as ICanvas; //foreach (object geo in _geometrys) //{ // GraphicsPath path = ToGraphicsPath(geo, canvas); // g.DrawPath(_pen, path); // // // EditObject eobj; // if (!_editObjects.ContainsKey(geo)) // { // eobj = new EditObject(); // eobj.Geometry = geo; // _editObjects.Add(geo, eobj); // } // else // eobj = _editObjects[geo]; // if (eobj.Path != null) // eobj.Path.Dispose(); // eobj.Path = path; // // // if (_isAllowEdit) // { // Brush boxBrush = eobj.IsSelected ? Brushes.Green : Brushes.Red; // for (int i = 0; i < path.PointCount; i++) // { // g.FillRectangle(boxBrush, // path.PathPoints[i].X - EDIT_BOX_HALF_WIDTH, // path.PathPoints[i].Y - EDIT_BOX_HALF_WIDTH, // EDIT_BOX_WIDTH, EDIT_BOX_WIDTH); // } // } //} }
private Bitmap GetNorthArrowBitmap(IDrawArgs drawArgs) { Graphics g = drawArgs.Graphics as Graphics; if (g == null) { return(null); } SizeF size = g.MeasureString(_NNameString, _font); int crtWidth = Math.Max(_cstSpan, (int)size.Width); float x = crtWidth / 2; float y = size.Height; Bitmap bm = new Bitmap(Math.Max(_cstSpan, (int)size.Width), _cstHeightMax + (int)Math.Ceiling(size.Height)); using (Graphics gp = Graphics.FromImage(bm)) { GraphicsPath path = new GraphicsPath(); GraphicsPath path1 = new GraphicsPath(); path1.AddLine(x, y, x - _cstSpan / 2f, y + _cstHeightMax); path1.AddLine(x - _cstSpan / 2f, y + _cstHeightMax, x, y + _cstHeightMin); path1.AddLine(x, y + _cstHeightMin, x, y); GraphicsPath path2 = new GraphicsPath(); path2.AddLine(x, y, x + _cstSpan / 2f, y + _cstHeightMax); path2.AddLine(x + _cstSpan / 2f, y + _cstHeightMax, x, y + _cstHeightMin); path2.AddLine(x, y + _cstHeightMin, x, y); path.AddPath(path1, true); path.AddPath(path2, true); gp.Clear(_backColor); gp.SmoothingMode = SmoothingMode.HighQuality; gp.DrawPath(Pens.Black, path); gp.FillPath(Brushes.Black, path1); gp.DrawString(_NNameString, _font, Brushes.Black, 1, 0); } _preSize = _size; return(bm); }