Esempio n. 1
0
 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);
 }
Esempio n. 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));
     }
 }
Esempio n. 3
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();
        }
Esempio n. 4
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();
        }
Esempio n. 5
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;
            }
        }
Esempio n. 9
0
        private void PaintCellSeriesSymbol(MapGraphics g, int fontSizeReducedBy, Font legendAutoFont, SizeF singleWCharacterSize)
        {
            Rectangle r = cellPosition;

            if (SymbolSize.Width >= 0)
            {
                int num = (int)((float)SymbolSize.Width * singleWCharacterSize.Width / 100f);
                if (num > cellPosition.Width)
                {
                    num = cellPosition.Width;
                }
                r.Width = num;
            }
            if (SymbolSize.Height >= 0)
            {
                int num2 = (int)((float)SymbolSize.Height * singleWCharacterSize.Height / 100f);
                if (num2 > cellPosition.Height)
                {
                    num2 = cellPosition.Height;
                }
                r.Height = num2;
            }
            if (r.Height <= 0 || r.Width <= 0)
            {
                return;
            }
            r.X = (int)((float)cellPosition.X + (float)cellPosition.Width / 2f - (float)r.Width / 2f);
            r.Y = (int)((float)cellPosition.Y + (float)cellPosition.Height / 2f - (float)r.Height / 2f);
            if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft)
            {
                r.X = cellPosition.X;
            }
            else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight)
            {
                r.X = cellPosition.Right - r.Width;
            }
            if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight)
            {
                r.Y = cellPosition.Bottom - r.Height;
            }
            else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight)
            {
                r.Y = cellPosition.Y;
            }
            g.StartHotRegion(this);
            if (!string.IsNullOrEmpty(legendItem.Image))
            {
                Rectangle empty = Rectangle.Empty;
                Image     image = GetLegend().Common.ImageLoader.LoadImage(legendItem.Image);
                empty.Width  = image.Size.Width;
                empty.Height = image.Size.Height;
                float num3 = 1f;
                if (empty.Height > r.Height)
                {
                    num3 = (float)empty.Height / (float)r.Height;
                }
                if (empty.Width > r.Width)
                {
                    num3 = Math.Max(num3, (float)empty.Width / (float)r.Width);
                }
                empty.Height = (int)((float)empty.Height / num3);
                empty.Width  = (int)((float)empty.Width / num3);
                empty.X      = (int)((float)r.X + (float)r.Width / 2f - (float)empty.Width / 2f);
                empty.Y      = (int)((float)r.Y + (float)r.Height / 2f - (float)empty.Height / 2f);
                ImageAttributes imageAttributes = new ImageAttributes();
                if (legendItem.ImageTranspColor != Color.Empty)
                {
                    imageAttributes.SetColorKey(legendItem.ImageTranspColor, legendItem.ImageTranspColor, ColorAdjustType.Default);
                }
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Shape)
            {
                g.FillRectangleRel(g.GetRelativeRectangle(r), legendItem.Color, legendItem.HatchStyle, legendItem.Image, legendItem.ImageWrapMode, legendItem.ImageTranspColor, legendItem.ImageAlign, legendItem.GradientType, legendItem.SecondaryColor, legendItem.borderColor, (legendItem.BorderWidth > 2) ? 2 : legendItem.BorderWidth, legendItem.BorderStyle, legendItem.ShadowColor, (legendItem.ShadowOffset > 3) ? 3 : legendItem.ShadowOffset, PenAlignment.Center);
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Path)
            {
                Point location = r.Location;
                location.Y = (int)Math.Round((float)r.Y + (float)r.Height / 2f);
                Point pt   = new Point(r.Right, location.Y);
                int   num4 = (int)Math.Round((float)legendItem.PathWidth / 2f);
                location.X += num4;
                pt.X       -= num4;
                SmoothingMode smoothingMode = g.SmoothingMode;
                if (legendItem.PathWidth < 2 && legendItem.BorderWidth < 2)
                {
                    g.SmoothingMode = SmoothingMode.None;
                }
                using (GraphicsPath graphicsPath = new GraphicsPath())
                {
                    graphicsPath.AddLine(location, pt);
                    int num5 = (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset;
                    if (num5 > 0)
                    {
                        using (Pen pen = Path.GetColorPen(g.GetShadowColor(), legendItem.PathWidth, legendItem.BorderWidth))
                        {
                            if (pen != null)
                            {
                                Matrix matrix = new Matrix();
                                matrix.Translate(num5, num5, MatrixOrder.Append);
                                graphicsPath.Transform(matrix);
                                g.DrawPath(pen, graphicsPath);
                                matrix.Reset();
                                matrix.Translate(-num5, -num5, MatrixOrder.Append);
                                graphicsPath.Transform(matrix);
                            }
                        }
                    }
                    if (legendItem.BorderWidth > 0)
                    {
                        using (Pen pen2 = Path.GetColorPen(legendItem.BorderColor, legendItem.PathWidth, legendItem.BorderWidth))
                        {
                            if (pen2 != null)
                            {
                                g.DrawPath(pen2, graphicsPath);
                            }
                        }
                    }
                    RectangleF bounds = graphicsPath.GetBounds();
                    bounds.Inflate((float)legendItem.PathWidth / 2f, (float)legendItem.PathWidth / 2f);
                    using (Pen pen3 = Path.GetFillPen(g, graphicsPath, bounds, legendItem.PathWidth, legendItem.PathLineStyle, legendItem.Color, legendItem.SecondaryColor, legendItem.GradientType, legendItem.HatchStyle))
                    {
                        if (pen3 != null)
                        {
                            g.DrawPath(pen3, graphicsPath);
                            if (pen3.Brush != null)
                            {
                                pen3.Brush.Dispose();
                            }
                        }
                    }
                }
                g.SmoothingMode = smoothingMode;
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Symbol)
            {
                MarkerStyle markerStyle = legendItem.markerStyle;
                if (markerStyle != 0 || !string.IsNullOrEmpty(legendItem.markerImage))
                {
                    int num6 = Math.Min(r.Width, r.Height);
                    int num7 = (legendItem.MarkerBorderWidth > 3) ? 3 : legendItem.MarkerBorderWidth;
                    if (num7 > 0)
                    {
                        num6 -= num7;
                        if (num6 < 1)
                        {
                            num6 = 1;
                        }
                    }
                    Point point = default(Point);
                    point.X = (int)((float)r.X + (float)r.Width / 2f);
                    point.Y = (int)((float)r.Y + (float)r.Height / 2f);
                    Rectangle empty2 = Rectangle.Empty;
                    if (!string.IsNullOrEmpty(legendItem.markerImage))
                    {
                        Image image2 = GetLegend().Common.ImageLoader.LoadImage(legendItem.markerImage);
                        empty2.Width  = image2.Size.Width;
                        empty2.Height = image2.Size.Height;
                        float num8 = 1f;
                        if (empty2.Height > r.Height)
                        {
                            num8 = (float)empty2.Height / (float)r.Height;
                        }
                        if (empty2.Width > r.Width)
                        {
                            num8 = Math.Max(num8, (float)empty2.Width / (float)r.Width);
                        }
                        empty2.Height = (int)((float)empty2.Height / num8);
                        empty2.Width  = (int)((float)empty2.Width / num8);
                    }
                    Color color = (legendItem.markerColor == Color.Empty) ? legendItem.Color : legendItem.markerColor;
                    if (Symbol.IsXamlMarker(markerStyle))
                    {
                        RectangleF rect = r;
                        if (rect.Width > rect.Height)
                        {
                            rect.X    += (rect.Width - rect.Height) / 2f;
                            rect.Width = rect.Height;
                        }
                        else if (rect.Height > rect.Width)
                        {
                            rect.Y     += (rect.Height - rect.Width) / 2f;
                            rect.Height = rect.Width;
                        }
                        using (XamlRenderer xamlRenderer = Symbol.CreateXamlRenderer(markerStyle, color, rect))
                        {
                            XamlLayer[] layers = xamlRenderer.Layers;
                            for (int i = 0; i < layers.Length; i++)
                            {
                                layers[i].Render(g);
                            }
                        }
                    }
                    else
                    {
                        PointF absolute = new PointF(point.X, point.Y);
                        if ((double)(num6 % 2) != 0.0)
                        {
                            absolute.X -= 0.5f;
                            absolute.Y -= 0.5f;
                        }
                        g.DrawMarkerRel(g.GetRelativePoint(absolute), markerStyle, num6, color, legendItem.MarkerGradientType, legendItem.MarkerHatchStyle, legendItem.MarkerSecondaryColor, legendItem.MarkerBorderStyle, (legendItem.markerBorderColor == Color.Empty) ? legendItem.borderColor : legendItem.markerBorderColor, num7, legendItem.markerImage, legendItem.markerImageTranspColor, (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset, legendItem.shadowColor, empty2);
                    }
                }
            }
            g.EndHotRegion();
        }
Esempio n. 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();
                }
            }
        }