private void DrawText(MapGraphics g, bool drawShadow) { if (string.IsNullOrEmpty(Text)) { return; } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); string text = Text; _ = Font; text = text.Replace("\\n", "\n"); StringFormat stringFormat = GetStringFormat(); TextRenderingHint textRenderingHint = g.TextRenderingHint; float num = DetermineAngle(); if (num % 90f != 0f) { g.TextRenderingHint = TextRenderingHint.AntiAlias; } Brush brush = null; brush = ((!drawShadow) ? new SolidBrush(TextColor) : g.GetShadowBrush()); try { if (num != 0f) { RectangleF layoutRectangle = DetermineTextRectangle(g, stringFormat); PointF point = new PointF(layoutRectangle.X + layoutRectangle.Width / 2f, layoutRectangle.Y + layoutRectangle.Height / 2f); Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); matrix.RotateAt(num, point, MatrixOrder.Prepend); if (drawShadow) { matrix.Translate(TextShadowOffset, TextShadowOffset, MatrixOrder.Append); } g.Transform = matrix; StringFormat stringFormat2 = new StringFormat(); stringFormat2.Alignment = StringAlignment.Center; stringFormat2.LineAlignment = StringAlignment.Center; stringFormat2.Trimming = StringTrimming.EllipsisCharacter; layoutRectangle.Inflate(1000f, 1000f); g.DrawString(text, Font, brush, layoutRectangle, stringFormat2); g.Transform = transform; } else { if (drawShadow) { absoluteRectangle.X += TextShadowOffset; absoluteRectangle.Y += TextShadowOffset; } g.DrawString(text, Font, brush, absoluteRectangle, stringFormat); } } finally { brush?.Dispose(); } g.Graphics.TextRenderingHint = textRenderingHint; }
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 RenderText(MapGraphics g) { if (!(this.TextInt == string.Empty)) { string text = (this.TextInt.IndexOf("#", StringComparison.Ordinal) == -1) ? this.TextInt : this.GetMapCore().ResolveAllKeywords(this.TextInt, this); text = text.Replace("\\n", "\n"); StringFormat stringFormat = new StringFormat(); if (this.TextAlignment == ContentAlignment.BottomRight) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.BottomCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.BottomLeft) { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.MiddleRight) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.MiddleCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.MiddleLeft) { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.TopRight) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Far; } else if (this.TextAlignment == ContentAlignment.TopCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Far; } else { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; } SizeF sizeF = g.MeasureString(text, this.Font, new SizeF(0f, 0f), StringFormat.GenericTypographic); PointF centerPointInContentPixels = this.GetCenterPointInContentPixels(g); new RectangleF(centerPointInContentPixels.X, (float)(centerPointInContentPixels.Y - 1.0), 0f, 0f).Inflate((float)(sizeF.Width / 2.0), (float)(sizeF.Height / 2.0)); if (this.TextShadowOffset != 0) { using (Brush brush = g.GetShadowBrush()) { PointF point = new PointF(centerPointInContentPixels.X + (float)this.TextShadowOffset, centerPointInContentPixels.Y + (float)this.TextShadowOffset); g.DrawString(text, this.Font, brush, point, stringFormat); } } using (Brush brush2 = new SolidBrush(this.TextColor)) { g.DrawString(text, this.Font, brush2, centerPointInContentPixels, stringFormat); } } }
public override void Render(MapGraphics g) { AntiAliasing antiAliasing = g.AntiAliasing; try { MapCore mapCore = base.GetMapCore(); if (mapCore != null) { g.AntiAliasing = AntiAliasing.None; base.Render(g); float num = 4.5f; RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); absoluteRectangle.Inflate((float)(0.0 - num), (float)(0.0 - num)); if (!(absoluteRectangle.Width < 3.0) && !(absoluteRectangle.Height < 3.0)) { float num2 = 0f; float num3 = 0f; string text = "0"; string text2 = "0"; MeasurementUnit measurementUnit = MeasurementUnit.km; MeasurementUnit measurementUnit2 = MeasurementUnit.mi; float num4 = (float)(absoluteRectangle.Width - 6.0); float num5 = (float)mapCore.PixelsToKilometers(num4); float num6 = num5 * this.KilometersToMiles; measurementUnit = this.AdjustMetricUnit(ref num5); float num7 = (float)this.FloorDistance((double)num5); float num8 = num7 / num5; measurementUnit2 = this.AdjustImperialUnit(ref num6); float num9 = (float)this.FloorDistance((double)num6); float num10 = num9 / num6; if (num7 >= 1.0 && num9 >= 1.0) { num2 = num4 * num8; num3 = num4 * num10; if (base.GetMapCore().MapControl.FormatNumberHandler != null) { text = base.GetMapCore().MapControl.FormatNumberHandler(base.GetMapCore().MapControl, num7, "G"); text2 = base.GetMapCore().MapControl.FormatNumberHandler(base.GetMapCore().MapControl, num9, "G"); } else { text = num7.ToString(CultureInfo.CurrentCulture); text2 = num9.ToString(CultureInfo.CurrentCulture); } } else { num2 = num4; num3 = num4; } using (GraphicsPath path = this.CreateScalePath(absoluteRectangle, (int)num2, (int)num3)) { using (Brush brush = new SolidBrush(this.ScaleForeColor)) { g.FillPath(brush, path); } using (Pen pen = new Pen(this.ScaleBorderColor, 1f)) { pen.Alignment = PenAlignment.Center; pen.MiterLimit = 0f; g.DrawPath(pen, path); } StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone(); stringFormat.FormatFlags = StringFormatFlags.NoWrap; using (Brush brush2 = new SolidBrush(this.LabelColor)) { RectangleF textBounds = new RectangleF((float)(absoluteRectangle.Left + 3.0), absoluteRectangle.Top, num2, (float)(absoluteRectangle.Height / 2.0 - 3.0)); string text3 = string.Format(CultureInfo.CurrentCulture, "{0} {1}", text, ((Enum)(object)measurementUnit).ToString((IFormatProvider)CultureInfo.CurrentCulture)); SizeF textClipSize = g.MeasureString(text3, this.Font, textBounds.Size, stringFormat); RectangleF layoutRectangle = this.CreateTextClip(textBounds, textClipSize); g.DrawString(text3, this.Font, brush2, layoutRectangle, stringFormat); RectangleF textBounds2 = new RectangleF((float)(absoluteRectangle.Left + 3.0), (float)(absoluteRectangle.Top + absoluteRectangle.Height / 2.0 + 3.0), num3, (float)(absoluteRectangle.Height / 2.0 - 3.0)); string text4 = string.Format(CultureInfo.CurrentCulture, "{0} {1}", text2, ((Enum)(object)measurementUnit2).ToString((IFormatProvider)CultureInfo.CurrentCulture)); SizeF textClipSize2 = g.MeasureString(text4, this.Font, textBounds2.Size, stringFormat); RectangleF layoutRectangle2 = this.CreateTextClip(textBounds2, textClipSize2); g.DrawString(text4, this.Font, brush2, layoutRectangle2, stringFormat); } } } } } finally { g.AntiAliasing = antiAliasing; } }
public override void Render(MapGraphics g) { base.Render(g); if (!this.IsEmpty) { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); bool flag = false; try { if (this.Colors.Count == 0 && this.Common != null && this.Common.MapCore.IsDesignMode()) { this.PopulateDummyData(); flag = true; } int num = (this.LabelAlignment != LabelAlignment.Alternate) ? 1 : 2; SwatchLabelType swatchLabelType = this.GetLabelType(); SizeF colorBoxSize = default(SizeF); SizeF labelBoxSize = default(SizeF); SizeF firstCaptionSize = default(SizeF); SizeF lastCaptionSize = default(SizeF); this.CalculateFontDependentData(g, absoluteRectangle.Size); absoluteRectangle.Inflate((float)(-this.PanelPadding), (float)(-this.PanelPadding)); if (!(absoluteRectangle.Width < 1.0) && !(absoluteRectangle.Height < 1.0)) { int[] colorsRef = this.GetColorsRef(swatchLabelType); float num2 = 0f; if (this.LabelInterval > 0 && this.ShowEndLabels) { firstCaptionSize = g.MeasureString(this.GetLabelCaption(0, true, swatchLabelType), this.Font, absoluteRectangle.Size, StringFormat.GenericTypographic); firstCaptionSize.Width += this.TrimmingProtector; lastCaptionSize = g.MeasureString(this.GetLabelCaption(this.Colors.Count - 1, false, swatchLabelType), this.Font, absoluteRectangle.Size, StringFormat.GenericTypographic); lastCaptionSize.Width += this.TrimmingProtector; num2 = Math.Max(firstCaptionSize.Width, lastCaptionSize.Width); } bool flag2 = !string.IsNullOrEmpty(this.Title); RectangleF layoutRectangle = absoluteRectangle; if (flag2) { float height = absoluteRectangle.Height; SizeF sizeF = g.MeasureString(this.Title, this.TitleFont, layoutRectangle.Size, StringFormat.GenericTypographic); float num4 = layoutRectangle.Height = Math.Min(height, sizeF.Height + (float)this.TitleSeparatorSize); absoluteRectangle.Y += num4; absoluteRectangle.Height -= num4; this.titlePosition = layoutRectangle; } RectangleF colorBarBounds = this.CalculateMaxColorBarBounds(g, absoluteRectangle, num2, colorsRef.Length, swatchLabelType); float num5 = 0f; float num6 = 0f; if (this.LabelInterval > 0) { num5 = this.GetLabelMaxSize(g, absoluteRectangle.Size, swatchLabelType).Height; num6 = (float)(this.TickMarkLength + this.TickMarkLabelGapSize); } float val = Math.Max(3f, (float)((absoluteRectangle.Height - num6) / 5.0)); colorBoxSize.Height = Math.Max(val, absoluteRectangle.Height - (float)num * (num6 + num5)); colorBoxSize.Width = colorBarBounds.Width / (float)colorsRef.Length; colorBarBounds.Height = colorBoxSize.Height; labelBoxSize.Height = Math.Max(0f, absoluteRectangle.Height - colorBoxSize.Height) / (float)num - num6; labelBoxSize.Width = colorBoxSize.Width * (float)this.LabelInterval * (float)num; if (this.LabelAlignment == LabelAlignment.Top || this.LabelAlignment == LabelAlignment.Alternate) { colorBarBounds.Y += labelBoxSize.Height + num6; } AntiAliasing antiAliasing = g.AntiAliasing; try { g.AntiAliasing = AntiAliasing.None; GraphicsPath graphicsPath = default(GraphicsPath); GraphicsPath graphicsPath2 = default(GraphicsPath); this.CreateColorBarPath(absoluteRectangle, colorBarBounds, colorsRef, swatchLabelType, out graphicsPath, out graphicsPath2); GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(graphicsPath2); GraphicsPath graphicsPath3 = new GraphicsPath(); Pen pen = new Pen(this.OutlineColor); try { int[] array = colorsRef; foreach (int colorIndex in array) { graphicsPath3.Reset(); bool flag3 = default(bool); graphicsPathIterator.NextSubpath(graphicsPath3, out flag3); if (flag3) { using (Brush brush = this.CreateColorBoxBrush(g, graphicsPath3.GetBounds(), colorIndex)) { g.FillPath(brush, graphicsPath3); } } } g.DrawPath(pen, graphicsPath); } finally { graphicsPath.Dispose(); graphicsPath2.Dispose(); graphicsPathIterator.Dispose(); graphicsPath3.Dispose(); pen.Dispose(); } } finally { g.AntiAliasing = antiAliasing; } if (flag2) { using (Brush brush2 = new SolidBrush(this.TitleColor)) { using (StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat.Alignment = this.TitleAlignment; stringFormat.LineAlignment = StringAlignment.Near; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.FormatFlags = StringFormatFlags.NoWrap; g.DrawString(this.Title, this.TitleFont, brush2, layoutRectangle, stringFormat); } } } if (this.Colors.Count != 0 && this.LabelInterval != 0) { using (StringFormat stringFormat2 = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat2.Alignment = StringAlignment.Center; stringFormat2.LineAlignment = StringAlignment.Near; stringFormat2.Trimming = StringTrimming.EllipsisCharacter; stringFormat2.FormatFlags = StringFormatFlags.NoWrap; using (Brush brush3 = new SolidBrush(this.LabelColor)) { bool flag4 = this.LabelAlignment != LabelAlignment.Top; if (swatchLabelType == SwatchLabelType.ShowMiddleValue) { for (int j = 0; j < colorsRef.Length; j++) { if (this.MustPrintLabel(colorsRef, j, true, swatchLabelType)) { StringAlignment alignment = default(StringAlignment); RectangleF labelBounds = this.GetLabelBounds(j, colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, true, swatchLabelType, flag4, firstCaptionSize, lastCaptionSize, out alignment); string labelCaption = this.GetLabelCaption(j, true, swatchLabelType); if (labelBounds.Width > 1.0 && labelBounds.Height > 1.0) { if (flag4) { labelBounds.Offset(0f, 1f); } stringFormat2.Alignment = alignment; g.DrawString(labelCaption, this.Font, brush3, labelBounds, stringFormat2); } flag4 = ((this.LabelAlignment == LabelAlignment.Alternate) ? (!flag4) : flag4); } } } else { for (int k = 0; k < colorsRef.Length; k++) { RectangleF labelBounds2; if (this.MustPrintLabel(colorsRef, k, true, swatchLabelType)) { StringAlignment alignment2 = default(StringAlignment); labelBounds2 = this.GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, true, swatchLabelType, flag4, firstCaptionSize, lastCaptionSize, out alignment2); string labelCaption2 = this.GetLabelCaption(colorsRef[k], true, swatchLabelType); if (labelBounds2.Width > 1.0 && labelBounds2.Height > 1.0) { if (flag4) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = alignment2; g.DrawString(labelCaption2, this.Font, brush3, labelBounds2, stringFormat2); } flag4 = ((this.LabelAlignment == LabelAlignment.Alternate) ? (!flag4) : flag4); } if (this.MustPrintLabel(colorsRef, k, false, swatchLabelType)) { StringAlignment alignment3 = default(StringAlignment); labelBounds2 = this.GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, false, swatchLabelType, flag4, firstCaptionSize, lastCaptionSize, out alignment3); string labelCaption2 = this.GetLabelCaption(colorsRef[k], false, swatchLabelType); if (labelBounds2.Width > 1.0 && labelBounds2.Height > 1.0) { if (flag4) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = alignment3; g.DrawString(labelCaption2, this.Font, brush3, labelBounds2, stringFormat2); } flag4 = ((this.LabelAlignment == LabelAlignment.Alternate) ? (!flag4) : flag4); } } } } } } } } finally { if (flag) { this.Colors.Clear(); } } } }
internal override void Render(MapGraphics g) { AntiAliasing antiAliasing = g.AntiAliasing; try { MapCore mapCore = GetMapCore(); if (mapCore == null) { return; } g.AntiAliasing = AntiAliasing.None; base.Render(g); float num = 4.5f; RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); absoluteRectangle.Inflate(0f - num, 0f - num); if (absoluteRectangle.Width < 3f || absoluteRectangle.Height < 3f) { return; } float num2 = 0f; float num3 = 0f; string arg = "0"; string arg2 = "0"; MeasurementUnit measurementUnit = MeasurementUnit.km; MeasurementUnit measurementUnit2 = MeasurementUnit.mi; float num4 = absoluteRectangle.Width - 6f; float kilometers = (float)mapCore.PixelsToKilometers(num4); float miles = kilometers * KilometersToMiles; measurementUnit = AdjustMetricUnit(ref kilometers); float num5 = FloorDistance(kilometers); float num6 = num5 / kilometers; measurementUnit2 = AdjustImperialUnit(ref miles); float num7 = FloorDistance(miles); float num8 = num7 / miles; if (num5 >= 1f && num7 >= 1f) { num2 = num4 * num6; num3 = num4 * num8; if (GetMapCore().MapControl.FormatNumberHandler != null) { arg = GetMapCore().MapControl.FormatNumberHandler(GetMapCore().MapControl, num5, "G"); arg2 = GetMapCore().MapControl.FormatNumberHandler(GetMapCore().MapControl, num7, "G"); } else { arg = num5.ToString(CultureInfo.CurrentCulture); arg2 = num7.ToString(CultureInfo.CurrentCulture); } } else { num2 = num4; num3 = num4; } using (GraphicsPath path = CreateScalePath(absoluteRectangle, (int)num2, (int)num3)) { using (Brush brush = new SolidBrush(ScaleForeColor)) { g.FillPath(brush, path); } using (Pen pen = new Pen(ScaleBorderColor, 1f)) { pen.Alignment = PenAlignment.Center; pen.MiterLimit = 0f; g.DrawPath(pen, path); } StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone(); stringFormat.FormatFlags = StringFormatFlags.NoWrap; using (Brush brush2 = new SolidBrush(LabelColor)) { RectangleF textBounds = new RectangleF(absoluteRectangle.Left + 3f, absoluteRectangle.Top, num2, absoluteRectangle.Height / 2f - 3f); string text = string.Format(CultureInfo.CurrentCulture, "{0} {1}", arg, measurementUnit.ToString(CultureInfo.CurrentCulture)); SizeF textClipSize = g.MeasureString(text, Font, textBounds.Size, stringFormat); RectangleF layoutRectangle = CreateTextClip(textBounds, textClipSize); g.DrawString(text, Font, brush2, layoutRectangle, stringFormat); RectangleF textBounds2 = new RectangleF(absoluteRectangle.Left + 3f, absoluteRectangle.Top + absoluteRectangle.Height / 2f + 3f, num3, absoluteRectangle.Height / 2f - 3f); string text2 = string.Format(CultureInfo.CurrentCulture, "{0} {1}", arg2, measurementUnit2.ToString(CultureInfo.CurrentCulture)); SizeF textClipSize2 = g.MeasureString(text2, Font, textBounds2.Size, stringFormat); RectangleF layoutRectangle2 = CreateTextClip(textBounds2, textClipSize2); g.DrawString(text2, Font, brush2, layoutRectangle2, stringFormat); } } } finally { g.AntiAliasing = antiAliasing; } }
internal override void Render(MapGraphics g) { base.Render(g); if (IsEmpty) { return; } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); bool flag = false; try { if (Colors.Count == 0 && Common != null && Common.MapCore.IsDesignMode()) { PopulateDummyData(); flag = true; } int num = (LabelAlignment != LabelAlignment.Alternate) ? 1 : 2; SwatchLabelType swatchLabelType = GetLabelType(); SizeF colorBoxSize = default(SizeF); SizeF labelBoxSize = default(SizeF); SizeF firstCaptionSize = default(SizeF); SizeF lastCaptionSize = default(SizeF); CalculateFontDependentData(g, absoluteRectangle.Size); absoluteRectangle.Inflate(-PanelPadding, -PanelPadding); if (absoluteRectangle.Width < 1f || absoluteRectangle.Height < 1f) { return; } int[] colorsRef = GetColorsRef(swatchLabelType); float num2 = 0f; if (LabelInterval > 0 && ShowEndLabels) { firstCaptionSize = g.MeasureString(GetLabelCaption(0, getFromValue: true, swatchLabelType), Font, absoluteRectangle.Size, StringFormat.GenericTypographic); firstCaptionSize.Width += TrimmingProtector; lastCaptionSize = g.MeasureString(GetLabelCaption(Colors.Count - 1, getFromValue: false, swatchLabelType), Font, absoluteRectangle.Size, StringFormat.GenericTypographic); lastCaptionSize.Width += TrimmingProtector; num2 = Math.Max(firstCaptionSize.Width, lastCaptionSize.Width); } bool flag2 = !string.IsNullOrEmpty(Title); RectangleF layoutRectangle = absoluteRectangle; if (flag2) { float num4 = layoutRectangle.Height = Math.Min(absoluteRectangle.Height, g.MeasureString(Title, TitleFont, layoutRectangle.Size, StringFormat.GenericTypographic).Height + (float)TitleSeparatorSize); absoluteRectangle.Y += num4; absoluteRectangle.Height -= num4; titlePosition = layoutRectangle; } RectangleF colorBarBounds = CalculateMaxColorBarBounds(g, absoluteRectangle, num2, colorsRef.Length, swatchLabelType); float num5 = 0f; float num6 = 0f; if (LabelInterval > 0) { num5 = GetLabelMaxSize(g, absoluteRectangle.Size, swatchLabelType).Height; num6 = TickMarkLength + TickMarkLabelGapSize; } float val = Math.Max(3f, (absoluteRectangle.Height - num6) / 5f); colorBoxSize.Height = Math.Max(val, absoluteRectangle.Height - (float)num * (num6 + num5)); colorBoxSize.Width = colorBarBounds.Width / (float)colorsRef.Length; colorBarBounds.Height = colorBoxSize.Height; labelBoxSize.Height = Math.Max(0f, absoluteRectangle.Height - colorBoxSize.Height) / (float)num - num6; labelBoxSize.Width = colorBoxSize.Width * (float)LabelInterval * (float)num; if (LabelAlignment == LabelAlignment.Top || LabelAlignment == LabelAlignment.Alternate) { colorBarBounds.Y += labelBoxSize.Height + num6; } AntiAliasing antiAliasing = g.AntiAliasing; try { g.AntiAliasing = AntiAliasing.None; CreateColorBarPath(absoluteRectangle, colorBarBounds, colorsRef, swatchLabelType, out GraphicsPath outlinePath, out GraphicsPath fillPath); GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(fillPath); GraphicsPath graphicsPath = new GraphicsPath(); Pen pen = new Pen(OutlineColor); try { int[] array = colorsRef; foreach (int colorIndex in array) { graphicsPath.Reset(); graphicsPathIterator.NextSubpath(graphicsPath, out bool isClosed); if (isClosed) { using (Brush brush = CreateColorBoxBrush(g, graphicsPath.GetBounds(), colorIndex)) { g.FillPath(brush, graphicsPath); } } } g.DrawPath(pen, outlinePath); } finally { outlinePath.Dispose(); fillPath.Dispose(); graphicsPathIterator.Dispose(); graphicsPath.Dispose(); pen.Dispose(); } } finally { g.AntiAliasing = antiAliasing; } if (flag2) { using (Brush brush2 = new SolidBrush(TitleColor)) { using (StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat.Alignment = TitleAlignment; stringFormat.LineAlignment = StringAlignment.Near; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.FormatFlags = StringFormatFlags.NoWrap; g.DrawString(Title, TitleFont, brush2, layoutRectangle, stringFormat); } } } if (Colors.Count == 0 || LabelInterval == 0) { return; } using (StringFormat stringFormat2 = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat2.Alignment = StringAlignment.Center; stringFormat2.LineAlignment = StringAlignment.Near; stringFormat2.Trimming = StringTrimming.EllipsisCharacter; stringFormat2.FormatFlags = StringFormatFlags.NoWrap; using (Brush brush3 = new SolidBrush(LabelColor)) { bool flag3 = LabelAlignment != LabelAlignment.Top; if (swatchLabelType == SwatchLabelType.ShowMiddleValue) { for (int j = 0; j < colorsRef.Length; j++) { if (!MustPrintLabel(colorsRef, j, isFromValue: true, swatchLabelType)) { continue; } StringAlignment horizontalAlignemnt; RectangleF labelBounds = GetLabelBounds(j, colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: true, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out horizontalAlignemnt); string labelCaption = GetLabelCaption(j, getFromValue: true, swatchLabelType); if (labelBounds.Width > 1f && labelBounds.Height > 1f) { if (flag3) { labelBounds.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt; g.DrawString(labelCaption, Font, brush3, labelBounds, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } return; } for (int k = 0; k < colorsRef.Length; k++) { RectangleF labelBounds2; string labelCaption2; if (MustPrintLabel(colorsRef, k, isFromValue: true, swatchLabelType)) { labelBounds2 = GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: true, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out StringAlignment horizontalAlignemnt2); labelCaption2 = GetLabelCaption(colorsRef[k], getFromValue: true, swatchLabelType); if (labelBounds2.Width > 1f && labelBounds2.Height > 1f) { if (flag3) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt2; g.DrawString(labelCaption2, Font, brush3, labelBounds2, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } if (!MustPrintLabel(colorsRef, k, isFromValue: false, swatchLabelType)) { continue; } labelBounds2 = GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: false, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out StringAlignment horizontalAlignemnt3); labelCaption2 = GetLabelCaption(colorsRef[k], getFromValue: false, swatchLabelType); if (labelBounds2.Width > 1f && labelBounds2.Height > 1f) { if (flag3) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt3; g.DrawString(labelCaption2, Font, brush3, labelBounds2, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } } } } finally { if (flag) { Colors.Clear(); } } }