internal void Render(MapGraphics g) { if (Common == null || !Visible || GetScale() == null) { return; } g.StartHotRegion(this); if (!string.IsNullOrEmpty(Image)) { DrawImage(g, drawShadow: false); g.EndHotRegion(); return; } Pen pen = new Pen(BorderColor, BorderWidth); pen.DashStyle = MapGraphics.GetPenStyle(BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } MarkerStyleAttrib markerStyleAttrib = GetMarkerStyleAttrib(g); try { if (markerStyleAttrib.path != null) { bool circularFill = (MarkerStyle == MarkerStyle.Circle) ? true : false; g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, useBrushOffset: true, circularFill); } if (BorderWidth > 0 && markerStyleAttrib.path != null) { g.DrawPath(pen, markerStyleAttrib.path); } } catch (Exception) { markerStyleAttrib.Dispose(); } if (markerStyleAttrib.path != null) { Common.MapCore.HotRegionList.SetHotRegion(g, this, markerStyleAttrib.path); } g.EndHotRegion(); }
public void Render(MapGraphics g) { if (this.Common != null && this.Visible && this.GetScale() != null) { g.StartHotRegion(this); if (!string.IsNullOrEmpty(this.Image)) { this.DrawImage(g, false); g.EndHotRegion(); } else { Pen pen = new Pen(this.BorderColor, (float)this.BorderWidth); pen.DashStyle = MapGraphics.GetPenStyle(this.BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } MarkerStyleAttrib markerStyleAttrib = this.GetMarkerStyleAttrib(g); try { if (markerStyleAttrib.path != null) { bool circularFill = (byte)((this.MarkerStyle == MarkerStyle.Circle) ? 1 : 0) != 0; g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, true, circularFill); } if (this.BorderWidth > 0 && markerStyleAttrib.path != null) { g.DrawPath(pen, markerStyleAttrib.path); } } catch (Exception) { markerStyleAttrib.Dispose(); } if (markerStyleAttrib.path != null) { this.Common.MapCore.HotRegionList.SetHotRegion(g, this, markerStyleAttrib.path); } g.EndHotRegion(); } } }
internal void RenderStaticElements(MapGraphics g) { g.StartHotRegion(this); g.EndHotRegion(); RenderStaticShadows(g); Scale.RenderStaticElements(g); if (ZoomButtonsVisible) { RenderButton(g, zoomInButton); RenderButton(g, zoomOutButton); } }
public void RenderStaticElements(MapGraphics g) { g.StartHotRegion(this); g.EndHotRegion(); this.RenderStaticShadows(g); this.Scale.RenderStaticElements(g); if (this.ZoomButtonsVisible) { this.RenderButton(g, this.zoomInButton); this.RenderButton(g, this.zoomOutButton); } }
internal override void Render(MapGraphics g) { g.StartHotRegion(this); MapDashStyle mapDashStyle = BorderStyle; if (!string.IsNullOrEmpty(Image)) { ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g); imageSmoothingState.Set(); DrawImage(g, image, drawShadow: true); DrawImage(g, image, drawShadow: false); imageSmoothingState.Restore(); } else { string text = "No image."; Font font = new Font("Microsoft Sans Serif", 8.25f); SizeF sizeF = g.MeasureString(text, font); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f)); new RectangleF(absolutePoint.X, absolutePoint.Y, 0f, 0f).Inflate(sizeF.Width / 2f, sizeF.Height / 2f); using (Brush brush = new SolidBrush(Color.Gray)) { g.DrawString(text, font, brush, absoluteRectangle, stringFormat); } mapDashStyle = MapDashStyle.Solid; } if (mapDashStyle != 0 && BorderColor != Color.Transparent && BorderWidth != 0) { using (GraphicsPath path = GetPath(g)) { using (Pen pen = GetPen()) { AntiAliasing antiAliasing = g.AntiAliasing; if (Angle % 90f == 0f) { g.AntiAliasing = AntiAliasing.None; } g.DrawPath(pen, path); g.AntiAliasing = antiAliasing; } } } g.EndHotRegion(); }
private void PaintCellText(MapGraphics g, int fontSizeReducedBy, Font legendAutoFont, Size singleWCharacterSize) { bool disposeFont = false; Font cellFont = GetCellFont(legendAutoFont, fontSizeReducedBy, out disposeFont); g.StartHotRegion(this); using (SolidBrush brush = new SolidBrush(GetCellTextColor())) { StringFormat stringFormat = new StringFormat(StringFormat.GenericDefault); stringFormat.FormatFlags = StringFormatFlags.LineLimit; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.Alignment = StringAlignment.Center; if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft) { stringFormat.Alignment = StringAlignment.Near; } else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight) { stringFormat.Alignment = StringAlignment.Far; } stringFormat.LineAlignment = StringAlignment.Center; if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight) { stringFormat.LineAlignment = StringAlignment.Far; } else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight) { stringFormat.LineAlignment = StringAlignment.Near; } SizeF sizeF = g.MeasureStringAbs(GetCellText(), cellFont, new SizeF(10000f, 10000f), stringFormat); if (sizeF.Height > (float)cellPosition.Height && (stringFormat.FormatFlags & StringFormatFlags.LineLimit) != 0) { stringFormat.FormatFlags ^= StringFormatFlags.LineLimit; } else if (sizeF.Height < (float)cellPosition.Height && (stringFormat.FormatFlags & StringFormatFlags.LineLimit) == 0) { stringFormat.FormatFlags |= StringFormatFlags.LineLimit; } g.DrawStringRel(GetCellText(), cellFont, brush, g.GetRelativeRectangle(cellPosition), stringFormat); } g.EndHotRegion(); if (disposeFont) { cellFont.Dispose(); cellFont = null; } }
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(); }