internal void DrawImage(MapGraphics g, bool drawShadow) { if (!Visible || (drawShadow && ShadowOffset == 0f)) { return; } Image image = Common.ImageLoader.LoadImage(Image); if (image.Width == 0 || image.Height == 0) { return; } Point point = new Point(ImageOrigin.X, ImageOrigin.Y); if (point.X == 0 && point.Y == 0) { point.X = image.Width / 2; point.Y = image.Height / 2; } float absoluteDimension = g.GetAbsoluteDimension(Width); float absoluteDimension2 = g.GetAbsoluteDimension(MarkerLength); float num = absoluteDimension / (float)image.Width; float num2 = absoluteDimension2 / (float)image.Height; float num3 = CalculateMarkerDistance(); float positionFromValue = GetScale().GetPositionFromValue(Position); PointF pointF = Point.Empty; pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num3, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num3))); Rectangle rectangle = new Rectangle((int)(pointF.X - (float)point.X * num) + 1, (int)(pointF.Y - (float)point.Y * num2) + 1, (int)((float)image.Width * num) + 1, (int)((float)image.Height * num2) + 1); ImageAttributes imageAttributes = new ImageAttributes(); if (ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default); } if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = Common.MapCore.ShadowIntensity / 100f; imageAttributes.SetColorMatrix(colorMatrix); } g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); if (!drawShadow) { using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddRectangle(rectangle); Common.MapCore.HotRegionList.SetHotRegion(g, this, graphicsPath); } } }
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(); }
internal void DrawImage(MapGraphics g, string imageName, bool drawShadow) { if (drawShadow && ShadowOffset == 0f) { return; } Image image = Common.ImageLoader.LoadImage(imageName); if (image.Width == 0 || image.Height == 0) { return; } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); Rectangle empty = Rectangle.Empty; if (ResizeMode == ResizeMode.AutoFit) { empty = new Rectangle((int)absoluteRectangle.X, (int)absoluteRectangle.Y, (int)absoluteRectangle.Width, (int)absoluteRectangle.Height); } else { empty = new Rectangle(0, 0, image.Width, image.Height); PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f)); empty.X = (int)(absolutePoint.X - (float)(empty.Size.Width / 2)); empty.Y = (int)(absolutePoint.Y - (float)(empty.Size.Height / 2)); } ImageAttributes imageAttributes = new ImageAttributes(); if (ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default); } float num = (100f - Transparency) / 100f; float num2 = Common.MapCore.ShadowIntensity / 100f; if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = num2 * num; imageAttributes.SetColorMatrix(colorMatrix); } else if (Transparency > 0f) { ColorMatrix colorMatrix2 = new ColorMatrix(); colorMatrix2.Matrix33 = num; imageAttributes.SetColorMatrix(colorMatrix2); } if (Angle != 0f) { PointF point = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f); Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); float offsetX = matrix.OffsetX; float offsetY = matrix.OffsetY; point.X += offsetX; point.Y += offsetY; matrix.RotateAt(Angle, point, MatrixOrder.Append); if (drawShadow) { matrix.Translate(ShadowOffset, ShadowOffset, MatrixOrder.Append); } g.Transform = matrix; g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); g.Transform = transform; } else { if (drawShadow) { empty.X += (int)ShadowOffset; empty.Y += (int)ShadowOffset; } g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); } if (drawShadow) { return; } using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddRectangle(empty); if (Angle != 0f) { PointF point2 = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f); using (Matrix matrix2 = new Matrix()) { matrix2.RotateAt(Angle, point2, MatrixOrder.Append); graphicsPath.Transform(matrix2); } } Common.MapCore.HotRegionList.SetHotRegion(g, this, graphicsPath); } }
private void PaintCellImage(MapGraphics chartGraph, int fontSizeReducedBy, Font legendAutoFont, Size singleWCharacterSize) { if (string.IsNullOrEmpty(Image)) { return; } Rectangle empty = Rectangle.Empty; Image image = GetLegend().Common.ImageLoader.LoadImage(Image); empty.Width = image.Size.Width; empty.Height = image.Size.Height; Rectangle rectangle = cellPosition; rectangle.Width = empty.Width; rectangle.Height = empty.Height; if (!ImageSize.IsEmpty) { if (ImageSize.Width > 0) { int num = (int)((float)(ImageSize.Width * singleWCharacterSize.Width) / 100f); if (num > cellPosition.Width) { num = cellPosition.Width; } rectangle.Width = num; } if (ImageSize.Height > 0) { int num2 = (int)((float)(ImageSize.Height * singleWCharacterSize.Height) / 100f); if (num2 > cellPosition.Height) { num2 = cellPosition.Height; } rectangle.Height = num2; } } float num3 = 1f; if (empty.Height > rectangle.Height) { num3 = (float)empty.Height / (float)rectangle.Height; } if (empty.Width > rectangle.Width) { num3 = Math.Max(num3, (float)empty.Width / (float)rectangle.Width); } empty.Height = (int)((float)empty.Height / num3); empty.Width = (int)((float)empty.Width / num3); empty.X = (int)((float)cellPosition.X + (float)cellPosition.Width / 2f - (float)empty.Width / 2f); empty.Y = (int)((float)cellPosition.Y + (float)cellPosition.Height / 2f - (float)empty.Height / 2f); if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft) { empty.X = cellPosition.X; } else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight) { empty.X = cellPosition.Right - empty.Width; } if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight) { empty.Y = cellPosition.Bottom - empty.Height; } else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight) { empty.Y = cellPosition.Y; } ImageAttributes imageAttributes = new ImageAttributes(); if (ImageTranspColor != Color.Empty) { imageAttributes.SetColorKey(ImageTranspColor, ImageTranspColor, ColorAdjustType.Default); } SmoothingMode smoothingMode = chartGraph.SmoothingMode; CompositingQuality compositingQuality = chartGraph.Graphics.CompositingQuality; InterpolationMode interpolationMode = chartGraph.Graphics.InterpolationMode; chartGraph.SmoothingMode = SmoothingMode.AntiAlias; chartGraph.Graphics.CompositingQuality = CompositingQuality.HighQuality; chartGraph.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; chartGraph.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); chartGraph.SmoothingMode = smoothingMode; chartGraph.Graphics.CompositingQuality = compositingQuality; chartGraph.Graphics.InterpolationMode = interpolationMode; }