Пример #1
0
        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;
        }
Пример #2
0
        private RectangleF DetermineTextRectangle(MapGraphics g, StringFormat stringFormat)
        {
            RectangleF result            = default(RectangleF);
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            SizeF      sizeF             = this.DetermineTextSizeAfterRotation(g);

            if (stringFormat.Alignment == StringAlignment.Near)
            {
                result.X = absoluteRectangle.X;
            }
            else if (stringFormat.Alignment == StringAlignment.Center)
            {
                result.X = (float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0 - sizeF.Width / 2.0);
            }
            else if (stringFormat.Alignment == StringAlignment.Far)
            {
                result.X = absoluteRectangle.Right - sizeF.Width;
            }
            if (stringFormat.LineAlignment == StringAlignment.Near)
            {
                result.Y = absoluteRectangle.Y;
            }
            else if (stringFormat.LineAlignment == StringAlignment.Center)
            {
                result.Y = (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0 - sizeF.Height / 2.0);
            }
            else if (stringFormat.LineAlignment == StringAlignment.Far)
            {
                result.Y = absoluteRectangle.Bottom - sizeF.Height;
            }
            result.Width  = sizeF.Width;
            result.Height = sizeF.Height;
            return(result);
        }
Пример #3
0
        internal virtual void RenderBorder(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            absoluteRectangle.X      = (float)Math.Round(absoluteRectangle.X);
            absoluteRectangle.Y      = (float)Math.Round(absoluteRectangle.Y);
            absoluteRectangle.Width  = (float)Math.Round(absoluteRectangle.Width);
            absoluteRectangle.Height = (float)Math.Round(absoluteRectangle.Height);
            try
            {
                if (BorderWidth <= 0 || BorderColor.IsEmpty || BorderStyle == MapDashStyle.None)
                {
                    return;
                }
                using (Pen pen = new Pen(BorderColor, BorderWidth))
                {
                    pen.DashStyle = MapGraphics.GetPenStyle(BorderStyle);
                    pen.Alignment = PenAlignment.Inset;
                    if (BorderWidth == 1)
                    {
                        absoluteRectangle.Width  -= 1f;
                        absoluteRectangle.Height -= 1f;
                    }
                    g.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height);
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
Пример #4
0
        public virtual void RenderBorder(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            absoluteRectangle.X      = (float)Math.Round((double)absoluteRectangle.X);
            absoluteRectangle.Y      = (float)Math.Round((double)absoluteRectangle.Y);
            absoluteRectangle.Width  = (float)Math.Round((double)absoluteRectangle.Width);
            absoluteRectangle.Height = (float)Math.Round((double)absoluteRectangle.Height);
            try
            {
                if (this.BorderWidth > 0 && !this.BorderColor.IsEmpty && this.BorderStyle != 0)
                {
                    using (Pen pen = new Pen(this.BorderColor, (float)this.BorderWidth))
                    {
                        pen.DashStyle = MapGraphics.GetPenStyle(this.BorderStyle);
                        pen.Alignment = PenAlignment.Inset;
                        if (this.BorderWidth == 1)
                        {
                            absoluteRectangle.Width  -= 1f;
                            absoluteRectangle.Height -= 1f;
                        }
                        g.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height);
                    }
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
Пример #5
0
        public bool IsVisible(MapGraphics g)
        {
            RectangleF areasRect = new RectangleF(0f, 0f, 100f, 100f);

            AdjustAreasPosition(g, ref areasRect);
            return(!g.GetAbsoluteRectangle(areasRect).Contains(g.Clip.GetBounds(g.Graphics)));
        }
Пример #6
0
        public bool IsVisible(MapGraphics g)
        {
            RectangleF relative = new RectangleF(0f, 0f, 100f, 100f);

            this.AdjustAreasPosition(g, ref relative);
            relative = g.GetAbsoluteRectangle(relative);
            return(!relative.Contains(g.Clip.GetBounds(g.Graphics)));
        }
Пример #7
0
        public bool IsRectangleVisible(MapGraphics g, RectangleF clipRect, MapPoint minExtent, MapPoint maxExtent)
        {
            MapCore    mapCore  = this.GetMapCore();
            PointF     pointF   = mapCore.GeographicToPercents(minExtent).ToPointF();
            PointF     pointF2  = mapCore.GeographicToPercents(maxExtent).ToPointF();
            RectangleF relative = new RectangleF(pointF.X, pointF2.Y, pointF2.X - pointF.X, pointF.Y - pointF2.Y);

            relative = g.GetAbsoluteRectangle(relative);
            return(clipRect.IntersectsWith(relative));
        }
Пример #8
0
        private GraphicsPath GetButtonFacePath(MapGraphics g)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            RectangleF   rectangleF   = RectangleF.Inflate(g.GetAbsoluteRectangle(Bounds), -4f, -4f);

            if (rectangleF.Width < 1f || rectangleF.Height < 1f)
            {
                return(graphicsPath);
            }
            float  num     = rectangleF.Width / 8f;
            PointF pointF  = new PointF((rectangleF.Left + rectangleF.Right) / 2f, rectangleF.Top);
            PointF pointF2 = new PointF((rectangleF.Left + rectangleF.Right) / 2f, rectangleF.Bottom);
            PointF pointF3 = new PointF(rectangleF.Left, (rectangleF.Top + rectangleF.Bottom) / 2f);
            PointF pointF4 = new PointF(rectangleF.Right, (rectangleF.Top + rectangleF.Bottom) / 2f);
            PointF pointF5 = new PointF((rectangleF.Left + rectangleF.Right) / 2f, (rectangleF.Top + rectangleF.Bottom) / 2f);

            if (Type == PanelButtonType.ZoomButton)
            {
                graphicsPath.AddLines(new PointF[12]
                {
                    new PointF(pointF3.X, pointF3.Y - num),
                    new PointF(pointF5.X - num, pointF5.Y - num),
                    new PointF(pointF.X - num, pointF.Y),
                    new PointF(pointF.X + num, pointF.Y),
                    new PointF(pointF5.X + num, pointF5.Y - num),
                    new PointF(pointF4.X, pointF4.Y - num),
                    new PointF(pointF4.X, pointF4.Y + num),
                    new PointF(pointF5.X + num, pointF5.Y + num),
                    new PointF(pointF2.X + num, pointF2.Y),
                    new PointF(pointF2.X - num, pointF2.Y),
                    new PointF(pointF5.X - num, pointF5.Y + num),
                    new PointF(pointF3.X, pointF3.Y + num)
                });
                graphicsPath.CloseAllFigures();
            }
            else if (Type == PanelButtonType.ZoomOut)
            {
                graphicsPath.AddLines(new PointF[4]
                {
                    new PointF(pointF3.X, pointF3.Y - num),
                    new PointF(pointF4.X, pointF3.Y - num),
                    new PointF(pointF4.X, pointF3.Y + num),
                    new PointF(pointF3.X, pointF3.Y + num)
                });
                graphicsPath.CloseAllFigures();
            }
            else if ((Type & PanelButtonType.NavigationButton) != 0)
            {
                CreateArrowPath(g, graphicsPath);
            }
            return(graphicsPath);
        }
Пример #9
0
        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));
        }
Пример #10
0
        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);
        }
Пример #11
0
        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();
        }
Пример #12
0
        private void CreateArrowPath(MapGraphics g, GraphicsPath path)
        {
            if (this.Type != PanelButtonType.NaviagateCenter)
            {
                if (this.Style != 0 && this.Style != PanelButtonStyle.RoundedRectangle)
                {
                    return;
                }
                RectangleF rectangleF = RectangleF.Inflate(g.GetAbsoluteRectangle(this.Bounds), -4f, -4f);
                float      left       = rectangleF.Left;
                float      right      = rectangleF.Right;
                float      x          = (float)(rectangleF.X + rectangleF.Width / 2.0);
                float      x2         = (float)(rectangleF.X + rectangleF.Width * 0.30000001192092896);
                float      x3         = (float)(rectangleF.X + rectangleF.Width * 0.699999988079071);
                float      top        = rectangleF.Top;
                float      bottom     = rectangleF.Bottom;
                float      y          = (float)(rectangleF.Y + rectangleF.Height * 0.699999988079071);
                float      y2         = (float)(rectangleF.Y + rectangleF.Height / 2.0);
                path.StartFigure();
                path.AddLines(new PointF[7]
                {
                    new PointF(x, top),
                    new PointF(right, y),
                    new PointF(x3, y),
                    new PointF(x3, bottom),
                    new PointF(x2, bottom),
                    new PointF(x2, y),
                    new PointF(left, y)
                });
                path.CloseAllFigures();
                Matrix matrix = new Matrix();
                switch (this.Type)
                {
                case PanelButtonType.NaviagateSouth:
                    matrix.RotateAt(180f, new PointF(x, y2));
                    break;

                case PanelButtonType.NaviagateEast:
                    matrix.RotateAt(90f, new PointF(x, y2));
                    break;

                case PanelButtonType.NaviagateWest:
                    matrix.RotateAt(270f, new PointF(x, y2));
                    break;
                }
                path.Transform(matrix);
            }
        }
Пример #13
0
 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();
     }
 }
Пример #14
0
 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();
         }
     }
 }
Пример #15
0
        private void CreateArrowPath(MapGraphics g, GraphicsPath path)
        {
            if (Type != PanelButtonType.NaviagateCenter && (Style == PanelButtonStyle.Rectangle || Style == PanelButtonStyle.RoundedRectangle))
            {
                RectangleF rectangleF = RectangleF.Inflate(g.GetAbsoluteRectangle(Bounds), -4f, -4f);
                float      left       = rectangleF.Left;
                float      right      = rectangleF.Right;
                float      x          = rectangleF.X + rectangleF.Width / 2f;
                float      x2         = rectangleF.X + rectangleF.Width * 0.3f;
                float      x3         = rectangleF.X + rectangleF.Width * 0.7f;
                float      top        = rectangleF.Top;
                float      bottom     = rectangleF.Bottom;
                float      y          = rectangleF.Y + rectangleF.Height * 0.7f;
                float      y2         = rectangleF.Y + rectangleF.Height / 2f;
                path.StartFigure();
                path.AddLines(new PointF[7]
                {
                    new PointF(x, top),
                    new PointF(right, y),
                    new PointF(x3, y),
                    new PointF(x3, bottom),
                    new PointF(x2, bottom),
                    new PointF(x2, y),
                    new PointF(left, y)
                });
                path.CloseAllFigures();
                Matrix matrix = new Matrix();
                switch (Type)
                {
                case PanelButtonType.NaviagateSouth:
                    matrix.RotateAt(180f, new PointF(x, y2));
                    break;

                case PanelButtonType.NaviagateEast:
                    matrix.RotateAt(90f, new PointF(x, y2));
                    break;

                case PanelButtonType.NaviagateWest:
                    matrix.RotateAt(270f, new PointF(x, y2));
                    break;
                }
                path.Transform(matrix);
            }
        }
Пример #16
0
        public Brush GetBackBrush(MapGraphics g)
        {
            RectangleF    absoluteRectangle  = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            Brush         brush              = null;
            Color         backColor          = this.BackColor;
            Color         backSecondaryColor = this.BackSecondaryColor;
            GradientType  backGradientType   = this.BackGradientType;
            MapHatchStyle backHatchStyle     = this.BackHatchStyle;

            if (backHatchStyle != 0)
            {
                brush = MapGraphics.GetHatchBrush(backHatchStyle, backColor, backSecondaryColor);
            }
            else if (backGradientType != 0)
            {
                brush = g.GetGradientBrush(absoluteRectangle, backColor, backSecondaryColor, backGradientType);
                float num = this.DetermineAngle();
                if (num != 0.0)
                {
                    PointF pointF = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0));
                    if (brush is LinearGradientBrush)
                    {
                        ((LinearGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append);
                        ((LinearGradientBrush)brush).RotateTransform(num, MatrixOrder.Append);
                        ((LinearGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append);
                    }
                    else if (brush is PathGradientBrush)
                    {
                        ((PathGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append);
                        ((PathGradientBrush)brush).RotateTransform(num, MatrixOrder.Append);
                        ((PathGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append);
                    }
                }
            }
            else
            {
                brush = new SolidBrush(backColor);
            }
            return(brush);
        }
Пример #17
0
        internal GraphicsPath GetPath(MapGraphics g)
        {
            if (!IsVisible())
            {
                return(null);
            }
            GraphicsPath graphicsPath      = new GraphicsPath();
            RectangleF   absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            graphicsPath.AddRectangle(absoluteRectangle);
            if (Angle != 0f)
            {
                PointF point = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
                using (Matrix matrix = new Matrix())
                {
                    matrix.RotateAt(Angle, point);
                    graphicsPath.Transform(matrix);
                    return(graphicsPath);
                }
            }
            return(graphicsPath);
        }
Пример #18
0
        public GraphicsPath GetPath(MapGraphics g)
        {
            if (!this.IsVisible())
            {
                return(null);
            }
            GraphicsPath graphicsPath      = new GraphicsPath();
            RectangleF   absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            graphicsPath.AddRectangle(absoluteRectangle);
            if (this.Angle != 0.0)
            {
                PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0));
                using (Matrix matrix = new Matrix())
                {
                    matrix.RotateAt(this.Angle, point);
                    graphicsPath.Transform(matrix);
                    return(graphicsPath);
                }
            }
            return(graphicsPath);
        }
Пример #19
0
        internal virtual void RenderBackground(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            absoluteRectangle.X      = (float)Math.Round(absoluteRectangle.X);
            absoluteRectangle.Y      = (float)Math.Round(absoluteRectangle.Y);
            absoluteRectangle.Width  = (float)Math.Round(absoluteRectangle.Width);
            absoluteRectangle.Height = (float)Math.Round(absoluteRectangle.Height);
            try
            {
                if (BackShadowOffset != 0)
                {
                    RectangleF rect = absoluteRectangle;
                    rect.Offset(BackShadowOffset, BackShadowOffset);
                    g.FillRectangle(g.GetShadowBrush(), rect);
                }
                if (IsMakeTransparentRequired())
                {
                    using (Brush brush = new SolidBrush(GetColorForMakeTransparent()))
                    {
                        g.FillRectangle(brush, absoluteRectangle);
                    }
                }
                using (Brush brush2 = g.CreateBrush(absoluteRectangle, BackColor, BackHatchStyle, "", MapImageWrapMode.Unscaled, Color.Empty, MapImageAlign.Center, BackGradientType, BackSecondaryColor))
                {
                    g.FillRectangle(brush2, absoluteRectangle);
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
        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;
            }
        }
Пример #21
0
        internal void DrawImage(MapGraphics g, string imageName, bool drawShadow)
        {
            if (drawShadow && ShadowOffset == 0f)
            {
                return;
            }
            Image image = Common.ImageLoader.LoadImage(imageName);

            if (image.Width == 0 || image.Height == 0)
            {
                return;
            }
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            Rectangle  empty             = Rectangle.Empty;

            if (ResizeMode == ResizeMode.AutoFit)
            {
                empty = new Rectangle((int)absoluteRectangle.X, (int)absoluteRectangle.Y, (int)absoluteRectangle.Width, (int)absoluteRectangle.Height);
            }
            else
            {
                empty = new Rectangle(0, 0, image.Width, image.Height);
                PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f));
                empty.X = (int)(absolutePoint.X - (float)(empty.Size.Width / 2));
                empty.Y = (int)(absolutePoint.Y - (float)(empty.Size.Height / 2));
            }
            ImageAttributes imageAttributes = new ImageAttributes();

            if (ImageTransColor != Color.Empty)
            {
                imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default);
            }
            float num  = (100f - Transparency) / 100f;
            float num2 = Common.MapCore.ShadowIntensity / 100f;

            if (drawShadow)
            {
                ColorMatrix colorMatrix = new ColorMatrix();
                colorMatrix.Matrix00 = 0f;
                colorMatrix.Matrix11 = 0f;
                colorMatrix.Matrix22 = 0f;
                colorMatrix.Matrix33 = num2 * num;
                imageAttributes.SetColorMatrix(colorMatrix);
            }
            else if (Transparency > 0f)
            {
                ColorMatrix colorMatrix2 = new ColorMatrix();
                colorMatrix2.Matrix33 = num;
                imageAttributes.SetColorMatrix(colorMatrix2);
            }
            if (Angle != 0f)
            {
                PointF point     = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
                Matrix transform = g.Transform;
                Matrix matrix    = g.Transform.Clone();
                float  offsetX   = matrix.OffsetX;
                float  offsetY   = matrix.OffsetY;
                point.X += offsetX;
                point.Y += offsetY;
                matrix.RotateAt(Angle, point, MatrixOrder.Append);
                if (drawShadow)
                {
                    matrix.Translate(ShadowOffset, ShadowOffset, MatrixOrder.Append);
                }
                g.Transform = matrix;
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
                g.Transform = transform;
            }
            else
            {
                if (drawShadow)
                {
                    empty.X += (int)ShadowOffset;
                    empty.Y += (int)ShadowOffset;
                }
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            }
            if (drawShadow)
            {
                return;
            }
            using (GraphicsPath graphicsPath = new GraphicsPath())
            {
                graphicsPath.AddRectangle(empty);
                if (Angle != 0f)
                {
                    PointF point2 = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
                    using (Matrix matrix2 = new Matrix())
                    {
                        matrix2.RotateAt(Angle, point2, MatrixOrder.Append);
                        graphicsPath.Transform(matrix2);
                    }
                }
                Common.MapCore.HotRegionList.SetHotRegion(g, this, graphicsPath);
            }
        }
Пример #22
0
        private GraphicsPath GetButtonPath(MapGraphics g)
        {
            GraphicsPath graphicsPath = new GraphicsPath();

            switch (this.Style)
            {
            case PanelButtonStyle.Rectangle:
                graphicsPath.AddRectangle(g.GetAbsoluteRectangle(this.Bounds));
                break;

            case PanelButtonStyle.Circle:
                graphicsPath.AddEllipse(g.GetAbsoluteRectangle(this.Bounds));
                break;

            case PanelButtonStyle.RoundedRectangle:
            {
                RectangleF absoluteRectangle = g.GetAbsoluteRectangle(this.Bounds);
                if (!(absoluteRectangle.Width < 1.0) && !(absoluteRectangle.Height < 1.0))
                {
                    float   num          = (float)(absoluteRectangle.Width / 8.0);
                    float[] cornerRadius = new float[8]
                    {
                        num,
                        num,
                        num,
                        num,
                        num,
                        num,
                        num,
                        num
                    };
                    graphicsPath.AddPath(g.CreateRoundedRectPath(absoluteRectangle, cornerRadius), false);
                    break;
                }
                return(graphicsPath);
            }

            case PanelButtonStyle.Triangle:
                switch (this.Type)
                {
                case PanelButtonType.NavigationButton:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF((float)((this.Bounds.Left + this.Bounds.Right) / 2.0), this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateSouth:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF((float)((this.Bounds.Left + this.Bounds.Right) / 2.0), this.Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Top))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateEast:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, (float)((this.Bounds.Top + this.Bounds.Bottom) / 2.0))),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateWest:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, (float)((this.Bounds.Top + this.Bounds.Bottom) / 2.0))),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;
                }
                break;
            }
            return(graphicsPath);
        }
 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();
             }
         }
     }
 }
Пример #24
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();
                }
            }
        }
        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;
            }
        }