internal void Paint(MapGraphics chartGraph, int fontSizeReducedBy, Font legendAutoFont, Size singleWCharacterSize) { if (cellPosition.Width <= 0 || cellPosition.Height <= 0 || !GetLegend().Common.ProcessModePaint) { return; } Color cellBackColor = GetCellBackColor(); if (!cellBackColor.IsEmpty) { chartGraph.FillRectangleRel(chartGraph.GetRelativeRectangle(cellPositionWithMargins), cellBackColor, MapHatchStyle.None, string.Empty, MapImageWrapMode.Tile, Color.Empty, MapImageAlign.Center, GradientType.None, Color.Empty, Color.Empty, 0, MapDashStyle.None, Color.Empty, 0, PenAlignment.Inset); } if (GetLegend().Common.ProcessModePaint) { switch (CellType) { case LegendCellType.Text: PaintCellText(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize); break; case LegendCellType.Image: PaintCellImage(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize); break; case LegendCellType.Symbol: PaintCellSeriesSymbol(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize); break; default: throw new InvalidOperationException("Unknown legend cell type: '" + CellType.ToString(CultureInfo.CurrentCulture) + "'."); } } }
internal void RenderPanel(MapGraphics g) { if (!IsVisible()) { return; } try { RectangleF relativeRectangle = g.GetRelativeRectangle(Margins.AdjustRectangle(GetBoundsInPixels())); g.CreateDrawRegion(relativeRectangle); SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); if (absoluteSize.Width < 1f || absoluteSize.Height < 1f) { return; } if (ShouldRenderBackground() && GetMapCore().RenderingMode != RenderingMode.ZoomThumb) { RenderBackground(g); RenderBorder(g); } if (BorderWidth > 0 && ShouldRenderBackground()) { try { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); absoluteRectangle.Inflate(-BorderWidth, -BorderWidth); absoluteRectangle.Width = Math.Max(2f, absoluteRectangle.Width); absoluteRectangle.Height = Math.Max(2f, absoluteRectangle.Height); g.CreateDrawRegion(g.GetRelativeRectangle(absoluteRectangle)); Render(g); } finally { g.RestoreDrawRegion(); } } else { Render(g); } } finally { g.RestoreDrawRegion(); } }
private void RenderButton(MapGraphics g, PanelButton button) { float num = (float)(g.GetAbsoluteDimension(100f) - 1.0); SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); absoluteSize.Width -= 1f; absoluteSize.Height -= 1f; SizeF sizeF = new SizeF((float)((absoluteSize.Width - num) / 2.0), (float)((absoluteSize.Height - num) / 2.0)); float num2 = (float)(num / 3.0); PointF pointF = PointF.Empty; switch (button.Type) { case PanelButtonType.NavigationButton: pointF = new PointF((float)(num / 2.0), (float)(num2 / 2.0)); if (!this.CenterButtonVisible) { pointF.Y += 2f; } break; case PanelButtonType.NaviagateSouth: pointF = new PointF((float)(num / 2.0), (float)(num - num2 / 2.0)); if (!this.CenterButtonVisible) { pointF.Y -= 2f; } break; case PanelButtonType.NaviagateEast: pointF = new PointF((float)(num - num2 / 2.0), (float)(num / 2.0)); if (!this.CenterButtonVisible) { pointF.X -= 2f; } break; case PanelButtonType.NaviagateWest: pointF = new PointF((float)(num2 / 2.0), (float)(num / 2.0)); if (!this.CenterButtonVisible) { pointF.X += 2f; } break; case PanelButtonType.NaviagateCenter: pointF = new PointF((float)(num / 2.0), (float)(num / 2.0)); break; default: throw new ArgumentException(SR.invalid_button_type); } num2 = (float)(num2 - 4.0); RectangleF absolute = new RectangleF((float)(sizeF.Width + pointF.X - num2 / 2.0), (float)(sizeF.Height + pointF.Y - num2 / 2.0), num2, num2); button.Bounds = g.GetRelativeRectangle(absolute); button.Render(g); }
private void RenderButton(MapGraphics g, PanelButton button) { float num = g.GetAbsoluteDimension(100f) - 1f; SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); absoluteSize.Width -= 1f; absoluteSize.Height -= 1f; SizeF sizeF = new SizeF((absoluteSize.Width - num) / 2f, (absoluteSize.Height - num) / 2f); float num2 = num / 3f; PointF empty = PointF.Empty; switch (button.Type) { case PanelButtonType.NavigationButton: empty = new PointF(num / 2f, num2 / 2f); if (!CenterButtonVisible) { empty.Y += 2f; } break; case PanelButtonType.NaviagateSouth: empty = new PointF(num / 2f, num - num2 / 2f); if (!CenterButtonVisible) { empty.Y -= 2f; } break; case PanelButtonType.NaviagateEast: empty = new PointF(num - num2 / 2f, num / 2f); if (!CenterButtonVisible) { empty.X -= 2f; } break; case PanelButtonType.NaviagateWest: empty = new PointF(num2 / 2f, num / 2f); if (!CenterButtonVisible) { empty.X += 2f; } break; case PanelButtonType.NaviagateCenter: empty = new PointF(num / 2f, num / 2f); break; default: throw new ArgumentException(SR.invalid_button_type); } num2 -= 4f; RectangleF absolute = new RectangleF(sizeF.Width + empty.X - num2 / 2f, sizeF.Height + empty.Y - num2 / 2f, num2, num2); button.Bounds = g.GetRelativeRectangle(absolute); button.Render(g); }
public void RenderPanel(MapGraphics g) { if (this.IsVisible()) { try { RectangleF relativeRectangle = g.GetRelativeRectangle(this.Margins.AdjustRectangle(this.GetBoundsInPixels())); g.CreateDrawRegion(relativeRectangle); SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); if (!(absoluteSize.Width < 1.0) && !(absoluteSize.Height < 1.0)) { if (this.ShouldRenderBackground() && this.GetMapCore().RenderingMode != RenderingMode.ZoomThumb) { this.RenderBackground(g); this.RenderBorder(g); } if (this.BorderWidth > 0 && this.ShouldRenderBackground()) { try { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); absoluteRectangle.Inflate((float)(-this.BorderWidth), (float)(-this.BorderWidth)); absoluteRectangle.Width = Math.Max(2f, absoluteRectangle.Width); absoluteRectangle.Height = Math.Max(2f, absoluteRectangle.Height); g.CreateDrawRegion(g.GetRelativeRectangle(absoluteRectangle)); this.Render(g); } finally { g.RestoreDrawRegion(); } } else { this.Render(g); } } } finally { g.RestoreDrawRegion(); } } }
internal void BuildMatrices(MapGraphics g) { absMatrix.Reset(); RectangleF rectangleF = new RectangleF(0f, 0f, 1f, 1f); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(rectangleF); absMatrix.Translate(g.Transform.OffsetX, g.Transform.OffsetY); absMatrix.Scale(absoluteRectangle.Size.Width, absoluteRectangle.Size.Height); absoluteRectangle = g.GetRelativeRectangle(rectangleF); relMatrix.Reset(); relMatrix.Scale(absoluteRectangle.Size.Width, absoluteRectangle.Size.Height); relMatrix.Translate(0f - g.Transform.OffsetX, 0f - g.Transform.OffsetY); }
public void BuildMatrices(MapGraphics g) { this.absMatrix.Reset(); RectangleF rectangleF = new RectangleF(0f, 0f, 1f, 1f); RectangleF rectangleF2 = g.GetAbsoluteRectangle(rectangleF); this.absMatrix.Translate(g.Transform.OffsetX, g.Transform.OffsetY); this.absMatrix.Scale(rectangleF2.Size.Width, rectangleF2.Size.Height); rectangleF2 = g.GetRelativeRectangle(rectangleF); this.relMatrix.Reset(); this.relMatrix.Scale(rectangleF2.Size.Width, rectangleF2.Size.Height); this.relMatrix.Translate((float)(0.0 - g.Transform.OffsetX), (float)(0.0 - g.Transform.OffsetY)); }
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 RenderButton(MapGraphics g, PanelButton button) { float markerLength = Pointer.MarkerLength; markerLength += 5f; float num = 0f; float num2 = 0f; float num3; PointF relative; if (GetOrientation() == Orientation.Horizontal) { float relativeY = (100f - markerLength) / 2f; relativeY = g.GetRelativeX(g.GetAbsoluteY(relativeY)); markerLength = g.GetRelativeX(g.GetAbsoluteY(markerLength)); num3 = g.GetAbsoluteX(markerLength); relative = new PointF(markerLength / 2f + relativeY, 50f); if ((button.Type == PanelButtonType.ZoomOut && GetReversed()) || (button.Type == PanelButtonType.ZoomButton && !GetReversed())) { num = 100f - markerLength - 2f * relativeY; } } else { float relativeX = (100f - markerLength) / 2f; relativeX = g.GetRelativeY(g.GetAbsoluteX(relativeX)); markerLength = g.GetRelativeY(g.GetAbsoluteX(markerLength)); num3 = g.GetAbsoluteY(markerLength); relative = new PointF(50f, markerLength / 2f + relativeX); if ((button.Type == PanelButtonType.ZoomOut && !GetReversed()) || (button.Type == PanelButtonType.ZoomButton && GetReversed())) { num2 = 100f - markerLength - 2f * relativeX; } } relative.X += num; relative.Y += num2; relative = g.GetAbsolutePoint(relative); RectangleF absolute = new RectangleF(relative.X, relative.Y, 0f, 0f); absolute.Inflate(num3 / 2f, num3 / 2f); button.Bounds = g.GetRelativeRectangle(absolute); button.Render(g); }
private void RenderButton(MapGraphics g, PanelButton button) { float markerLength = this.Pointer.MarkerLength; markerLength = (float)(markerLength + 5.0); float num = 0f; float num2 = 0f; float relativeY; float num3; PointF relative; float relativeX; if (this.GetOrientation() == Orientation.Horizontal) { relativeY = (float)((100.0 - markerLength) / 2.0); relativeY = g.GetRelativeX(g.GetAbsoluteY(relativeY)); markerLength = g.GetRelativeX(g.GetAbsoluteY(markerLength)); num3 = g.GetAbsoluteX(markerLength); relative = new PointF((float)(markerLength / 2.0 + relativeY), 50f); if (button.Type == PanelButtonType.ZoomOut && this.GetReversed()) { goto IL_00a1; } if (button.Type == PanelButtonType.ZoomButton && !this.GetReversed()) { goto IL_00a1; } } else { relativeX = (float)((100.0 - markerLength) / 2.0); relativeX = g.GetRelativeY(g.GetAbsoluteX(relativeX)); markerLength = g.GetRelativeY(g.GetAbsoluteX(markerLength)); num3 = g.GetAbsoluteY(markerLength); relative = new PointF(50f, (float)(markerLength / 2.0 + relativeX)); if (button.Type == PanelButtonType.ZoomOut && !this.GetReversed()) { goto IL_0126; } if (button.Type == PanelButtonType.ZoomButton && this.GetReversed()) { goto IL_0126; } } goto IL_0138; IL_00a1: num = (float)(100.0 - markerLength - 2.0 * relativeY); goto IL_0138; IL_0126: num2 = (float)(100.0 - markerLength - 2.0 * relativeX); goto IL_0138; IL_0138: relative.X += num; relative.Y += num2; relative = g.GetAbsolutePoint(relative); RectangleF absolute = new RectangleF(relative.X, relative.Y, 0f, 0f); absolute.Inflate((float)(num3 / 2.0), (float)(num3 / 2.0)); button.Bounds = g.GetRelativeRectangle(absolute); button.Render(g); }
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(); }