public void Render(MapGraphics g)
 {
     if (InnerLayers != null)
     {
         for (int i = 0; i < InnerLayers.Length; i++)
         {
             InnerLayers[i].Render(g);
         }
     }
     if (Paths == null)
     {
         return;
     }
     g.TranslateTransform(Origin.X, Origin.Y);
     for (int j = 0; j < Paths.Length; j++)
     {
         if (Brushes[j] != null)
         {
             g.FillPath(Brushes[j], Paths[j]);
         }
         if (Pens[j] != null)
         {
             g.DrawPath(Pens[j], Paths[j]);
         }
     }
     g.TranslateTransform(0f - Origin.X, 0f - Origin.Y);
 }
Exemple #2
0
 public void Render(MapGraphics g)
 {
     if (this.InnerLayers != null)
     {
         for (int i = 0; i < this.InnerLayers.Length; i++)
         {
             this.InnerLayers[i].Render(g);
         }
     }
     if (this.Paths != null)
     {
         g.TranslateTransform(this.Origin.X, this.Origin.Y);
         for (int j = 0; j < this.Paths.Length; j++)
         {
             if (this.Brushes[j] != null)
             {
                 g.FillPath(this.Brushes[j], this.Paths[j]);
             }
             if (this.Pens[j] != null)
             {
                 g.DrawPath(this.Pens[j], this.Paths[j]);
             }
         }
         g.TranslateTransform((float)(0.0 - this.Origin.X), (float)(0.0 - this.Origin.Y));
     }
 }
Exemple #3
0
 internal void RenderStaticShadows(MapGraphics g)
 {
     using (GraphicsPath graphicsPath = new GraphicsPath())
     {
         GraphicsPath shadowPath = Scale.GetShadowPath();
         if (shadowPath != null)
         {
             graphicsPath.AddPath(shadowPath, connect: false);
         }
         graphicsPath.FillMode = FillMode.Winding;
         using (Brush brush = g.GetShadowBrush())
         {
             g.FillPath(brush, graphicsPath);
         }
     }
 }
 public void RenderDynamicShadows(MapGraphics g)
 {
     using (GraphicsPath graphicsPath = new GraphicsPath())
     {
         GraphicsPath shadowPath = this.Pointer.GetShadowPath(g);
         if (shadowPath != null)
         {
             graphicsPath.AddPath(shadowPath, false);
         }
         graphicsPath.FillMode = FillMode.Winding;
         using (Brush brush = g.GetShadowBrush())
         {
             g.FillPath(brush, graphicsPath);
         }
     }
 }
Exemple #5
0
        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();
        }
Exemple #6
0
 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();
         }
     }
 }
        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;
            }
        }
Exemple #10
0
        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();
                }
            }
        }