private void InsertSubpath(int index, string toolTip, string href, string attr, GraphicsPath path, bool absCoordinates, MapGraphics graph) { PointF[] pathPoints = path.PathPoints; if (pathPoints.Length == 0) { return; } float[] array = new float[pathPoints.Length * 2]; if (absCoordinates) { for (int i = 0; i < pathPoints.Length; i++) { pathPoints[i] = graph.GetRelativePoint(pathPoints[i]); } } int num = 0; PointF[] array2 = pathPoints; for (int j = 0; j < array2.Length; j++) { PointF pointF = array2[j]; array[num++] = pointF.X; array[num++] = pointF.Y; } Insert(index, MapAreaShape.Polygon, toolTip, href, attr, array); }
public virtual RectangleF GetBoundRect(MapGraphics g) { RectangleF result = default(RectangleF); if (LocationUnit == CoordinateUnit.Percent) { result.Location = Location; } else { result.Location = g.GetRelativePoint(Location); } if (SizeUnit == CoordinateUnit.Percent) { result.Size = Size; } else { result.Size = g.GetRelativeSize(Size); } return(result); }
private void PaintCellSeriesSymbol(MapGraphics g, int fontSizeReducedBy, Font legendAutoFont, SizeF singleWCharacterSize) { Rectangle r = cellPosition; if (SymbolSize.Width >= 0) { int num = (int)((float)SymbolSize.Width * singleWCharacterSize.Width / 100f); if (num > cellPosition.Width) { num = cellPosition.Width; } r.Width = num; } if (SymbolSize.Height >= 0) { int num2 = (int)((float)SymbolSize.Height * singleWCharacterSize.Height / 100f); if (num2 > cellPosition.Height) { num2 = cellPosition.Height; } r.Height = num2; } if (r.Height <= 0 || r.Width <= 0) { return; } r.X = (int)((float)cellPosition.X + (float)cellPosition.Width / 2f - (float)r.Width / 2f); r.Y = (int)((float)cellPosition.Y + (float)cellPosition.Height / 2f - (float)r.Height / 2f); if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft) { r.X = cellPosition.X; } else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight) { r.X = cellPosition.Right - r.Width; } if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight) { r.Y = cellPosition.Bottom - r.Height; } else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight) { r.Y = cellPosition.Y; } g.StartHotRegion(this); if (!string.IsNullOrEmpty(legendItem.Image)) { Rectangle empty = Rectangle.Empty; Image image = GetLegend().Common.ImageLoader.LoadImage(legendItem.Image); empty.Width = image.Size.Width; empty.Height = image.Size.Height; float num3 = 1f; if (empty.Height > r.Height) { num3 = (float)empty.Height / (float)r.Height; } if (empty.Width > r.Width) { num3 = Math.Max(num3, (float)empty.Width / (float)r.Width); } empty.Height = (int)((float)empty.Height / num3); empty.Width = (int)((float)empty.Width / num3); empty.X = (int)((float)r.X + (float)r.Width / 2f - (float)empty.Width / 2f); empty.Y = (int)((float)r.Y + (float)r.Height / 2f - (float)empty.Height / 2f); ImageAttributes imageAttributes = new ImageAttributes(); if (legendItem.ImageTranspColor != Color.Empty) { imageAttributes.SetColorKey(legendItem.ImageTranspColor, legendItem.ImageTranspColor, ColorAdjustType.Default); } g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); } else if (legendItem.ItemStyle == LegendItemStyle.Shape) { g.FillRectangleRel(g.GetRelativeRectangle(r), legendItem.Color, legendItem.HatchStyle, legendItem.Image, legendItem.ImageWrapMode, legendItem.ImageTranspColor, legendItem.ImageAlign, legendItem.GradientType, legendItem.SecondaryColor, legendItem.borderColor, (legendItem.BorderWidth > 2) ? 2 : legendItem.BorderWidth, legendItem.BorderStyle, legendItem.ShadowColor, (legendItem.ShadowOffset > 3) ? 3 : legendItem.ShadowOffset, PenAlignment.Center); } else if (legendItem.ItemStyle == LegendItemStyle.Path) { Point location = r.Location; location.Y = (int)Math.Round((float)r.Y + (float)r.Height / 2f); Point pt = new Point(r.Right, location.Y); int num4 = (int)Math.Round((float)legendItem.PathWidth / 2f); location.X += num4; pt.X -= num4; SmoothingMode smoothingMode = g.SmoothingMode; if (legendItem.PathWidth < 2 && legendItem.BorderWidth < 2) { g.SmoothingMode = SmoothingMode.None; } using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddLine(location, pt); int num5 = (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset; if (num5 > 0) { using (Pen pen = Path.GetColorPen(g.GetShadowColor(), legendItem.PathWidth, legendItem.BorderWidth)) { if (pen != null) { Matrix matrix = new Matrix(); matrix.Translate(num5, num5, MatrixOrder.Append); graphicsPath.Transform(matrix); g.DrawPath(pen, graphicsPath); matrix.Reset(); matrix.Translate(-num5, -num5, MatrixOrder.Append); graphicsPath.Transform(matrix); } } } if (legendItem.BorderWidth > 0) { using (Pen pen2 = Path.GetColorPen(legendItem.BorderColor, legendItem.PathWidth, legendItem.BorderWidth)) { if (pen2 != null) { g.DrawPath(pen2, graphicsPath); } } } RectangleF bounds = graphicsPath.GetBounds(); bounds.Inflate((float)legendItem.PathWidth / 2f, (float)legendItem.PathWidth / 2f); using (Pen pen3 = Path.GetFillPen(g, graphicsPath, bounds, legendItem.PathWidth, legendItem.PathLineStyle, legendItem.Color, legendItem.SecondaryColor, legendItem.GradientType, legendItem.HatchStyle)) { if (pen3 != null) { g.DrawPath(pen3, graphicsPath); if (pen3.Brush != null) { pen3.Brush.Dispose(); } } } } g.SmoothingMode = smoothingMode; } else if (legendItem.ItemStyle == LegendItemStyle.Symbol) { MarkerStyle markerStyle = legendItem.markerStyle; if (markerStyle != 0 || !string.IsNullOrEmpty(legendItem.markerImage)) { int num6 = Math.Min(r.Width, r.Height); int num7 = (legendItem.MarkerBorderWidth > 3) ? 3 : legendItem.MarkerBorderWidth; if (num7 > 0) { num6 -= num7; if (num6 < 1) { num6 = 1; } } Point point = default(Point); point.X = (int)((float)r.X + (float)r.Width / 2f); point.Y = (int)((float)r.Y + (float)r.Height / 2f); Rectangle empty2 = Rectangle.Empty; if (!string.IsNullOrEmpty(legendItem.markerImage)) { Image image2 = GetLegend().Common.ImageLoader.LoadImage(legendItem.markerImage); empty2.Width = image2.Size.Width; empty2.Height = image2.Size.Height; float num8 = 1f; if (empty2.Height > r.Height) { num8 = (float)empty2.Height / (float)r.Height; } if (empty2.Width > r.Width) { num8 = Math.Max(num8, (float)empty2.Width / (float)r.Width); } empty2.Height = (int)((float)empty2.Height / num8); empty2.Width = (int)((float)empty2.Width / num8); } Color color = (legendItem.markerColor == Color.Empty) ? legendItem.Color : legendItem.markerColor; if (Symbol.IsXamlMarker(markerStyle)) { RectangleF rect = r; if (rect.Width > rect.Height) { rect.X += (rect.Width - rect.Height) / 2f; rect.Width = rect.Height; } else if (rect.Height > rect.Width) { rect.Y += (rect.Height - rect.Width) / 2f; rect.Height = rect.Width; } using (XamlRenderer xamlRenderer = Symbol.CreateXamlRenderer(markerStyle, color, rect)) { XamlLayer[] layers = xamlRenderer.Layers; for (int i = 0; i < layers.Length; i++) { layers[i].Render(g); } } } else { PointF absolute = new PointF(point.X, point.Y); if ((double)(num6 % 2) != 0.0) { absolute.X -= 0.5f; absolute.Y -= 0.5f; } g.DrawMarkerRel(g.GetRelativePoint(absolute), markerStyle, num6, color, legendItem.MarkerGradientType, legendItem.MarkerHatchStyle, legendItem.MarkerSecondaryColor, legendItem.MarkerBorderStyle, (legendItem.markerBorderColor == Color.Empty) ? legendItem.borderColor : legendItem.markerBorderColor, num7, legendItem.markerImage, legendItem.markerImageTranspColor, (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset, legendItem.shadowColor, empty2); } } } g.EndHotRegion(); }