/// <summary> /// Update control size /// </summary> public void UpdateControlSize() { if (_graphic.Shape == null) { return; } _updatingSize = true; switch (_graphic.Shape.ShapeType) { case ShapeTypes.Point: PointShape aPS = (PointShape)_graphic.Shape; this.Left = (int)aPS.Point.X; this.Top = (int)aPS.Point.Y; if (_graphic.Legend.GetType() == typeof(PointBreak)) { PointBreak aPB = (PointBreak)_graphic.Legend; this.Left -= (int)(aPB.Size / 2); this.Top -= (int)(aPB.Size / 2); this.Width = (int)Math.Ceiling(aPB.Size); this.Height = (int)Math.Ceiling(aPB.Size); } else if (_graphic.Legend.GetType() == typeof(LabelBreak)) { LabelBreak aLB = (LabelBreak)_graphic.Legend; SizeF aSF = _mapLayout.CreateGraphics().MeasureString(aLB.Text, aLB.Font); this.Left -= (int)(aSF.Width / 2); this.Top -= (int)(aSF.Height / 2); this.Width = (int)Math.Ceiling(aSF.Width); this.Height = (int)Math.Ceiling(aSF.Height); } break; case ShapeTypes.WindArraw: WindArraw aWA = (WindArraw)_graphic.Shape; this.Left = (int)aWA.Point.X; this.Top = (int)aWA.Point.Y; this.Width = (int)(aWA.length * ((VectorBreak)_graphic.Legend).Zoom); this.Height = 20; break; case ShapeTypes.Polyline: case ShapeTypes.Polygon: case ShapeTypes.Rectangle: case ShapeTypes.Circle: case ShapeTypes.CurveLine: case ShapeTypes.CurvePolygon: case ShapeTypes.Ellipse: Extent extent = _graphic.Shape.Extent; this.Left = (int)Math.Ceiling(extent.minX); this.Top = (int)Math.Ceiling(extent.minY); this.Width = (int)Math.Ceiling((extent.Width)); this.Height = (int)Math.Ceiling((extent.Height)); break; } _updatingSize = false; }
private void LayoutMap_MapViewUpdated(object sender, EventArgs e) { if (_graphic.Legend.GetType() == typeof(VectorBreak)) { for (int i = 0; i < _layoutMap.MapFrame.MapView.LayerSet.Layers.Count; i++) { MapLayer aLayer = _layoutMap.MapFrame.MapView.LayerSet.Layers[_layoutMap.MapFrame.MapView.LayerSet.Layers.Count - 1 - i]; if (aLayer.LayerType == LayerTypes.VectorLayer) { if (aLayer.Visible && aLayer.LayerDrawType == LayerDrawType.Vector) { this.Visible = true; float zoom = ((VectorLayer)aLayer).DrawingZoom; ((VectorBreak)_graphic.Legend).Zoom = zoom; float max = 30.0f / zoom; WindArraw aWA = (WindArraw)_graphic.Shape; int llen = 5; for (i = 10; i <= 100; i += 5) { if (max < i) { llen = i - 5; break; } } aWA.length = llen; aWA.size = 5; aWA.Value = 0; UpdateControlSize(); //if (_defaultLegend.Visible) // _defaultWindArraw.Top = _defaultLegend.Bottom + 10; //else // _defaultWindArraw.Top = _defaultLayoutMap.Bottom; break; } } } } }
/// <summary> /// Paint graphics /// </summary> /// <param name="g">graphics</param> /// <param name="pageLocation">page location</param> /// <param name="zoom">zoom</param> public void PaintGraphics(Graphics g, PointF pageLocation, float zoom) { switch (_graphic.Shape.ShapeType) { case ShapeTypes.Point: PointD dPoint = _graphic.Shape.GetPoints()[0]; PointF aPoint = PageToScreen((float)dPoint.X, (float)dPoint.Y, pageLocation, zoom); if (_graphic.Legend.GetType() == typeof(PointBreak)) { PointBreak aPB = (PointBreak)((PointBreak)_graphic.Legend).Clone(); float size = aPB.Size; aPB.Size = aPB.Size * zoom; //PointF aPoint = new PointF(this.Left + (float)this.Width / 2, this.Top + (float)this.Height / 2); g.SmoothingMode = SmoothingMode.HighQuality; Draw.DrawPoint(aPoint, aPB, g); aPB.Size = size; g.SmoothingMode = _smoothingMode; } else if (_graphic.Legend.GetType() == typeof(LabelBreak)) { LabelBreak aLB = (LabelBreak)((LabelBreak)_graphic.Legend).Clone(); Font font = (Font)aLB.Font.Clone(); aLB.Font = new Font(font.Name, font.Size * zoom, font.Style); Rectangle rect = new Rectangle(); //Draw.DrawLabelPoint(new PointF(this.Left + (float)this.Width / 2, this.Top + (float)this.Height / 2), aLB, g, ref rect); Draw.DrawLabelPoint(aPoint, aLB, g, ref rect); aLB.Font = font; //g.DrawString(aLB.Text, aLB.Font, new SolidBrush(aLB.Color), new PointF(0, 0)); } break; case ShapeTypes.WindArraw: dPoint = _graphic.Shape.GetPoints()[0]; aPoint = PageToScreen((float)dPoint.X, (float)dPoint.Y, pageLocation, zoom); WindArraw aArraw = (WindArraw)_graphic.Shape; VectorBreak aVB = (VectorBreak)_graphic.Legend; Draw.DrawArraw(aVB.Color, aPoint, aArraw, g, aVB.Zoom * zoom); Font drawFont = new Font("Arial", 8 * zoom); g.DrawString(aArraw.length.ToString(), drawFont, new SolidBrush(aVB.Color), aPoint.X, aPoint.Y); break; case ShapeTypes.Polyline: case ShapeTypes.Polygon: case ShapeTypes.Rectangle: case ShapeTypes.Circle: case ShapeTypes.CurveLine: case ShapeTypes.CurvePolygon: case ShapeTypes.Ellipse: List <PointD> pList = _graphic.Shape.GetPoints(); PointF[] points = new PointF[pList.Count]; for (int i = 0; i < pList.Count; i++) { points[i] = PageToScreen((float)pList[i].X, (float)pList[i].Y, pageLocation, zoom); } switch (_graphic.Shape.ShapeType) { case ShapeTypes.Polyline: PolyLineBreak aPLB = (PolyLineBreak)((PolyLineBreak)_graphic.Legend).Clone(); float size = aPLB.Size; aPLB.Size = size * zoom; Draw.DrawPolyline(points, (PolyLineBreak)_graphic.Legend, g); aPLB.Size = size; break; case ShapeTypes.Polygon: case ShapeTypes.Rectangle: PolygonBreak aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawPolygon(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.Circle: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawCircle(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.CurveLine: aPLB = (PolyLineBreak)((PolyLineBreak)_graphic.Legend).Clone(); size = aPLB.Size; aPLB.Size = size * zoom; Draw.DrawCurveLine(points, (PolyLineBreak)_graphic.Legend, g); aPLB.Size = size; break; case ShapeTypes.CurvePolygon: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawCurvePolygon(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.Ellipse: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawEllipse(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; } break; } }