private string GetLabelCaption(int swatchColorIndex, bool getFromValue, SwatchLabelType currentLabelType)
        {
            SwatchColor swatchColor = this.Colors[swatchColorIndex];

            if (swatchColor.NoData)
            {
                return(this.NoDataText);
            }
            string result = "";

            if (currentLabelType == SwatchLabelType.ShowBorderValue)
            {
                if (!swatchColor.HasTextValue)
                {
                    double num = (!getFromValue) ? swatchColor.ToValue : swatchColor.FromValue;
                    result = ((base.GetMapCore().MapControl.FormatNumberHandler == null) ? num.ToString(this.NumericLabelFormat, CultureInfo.CurrentCulture) : base.GetMapCore().MapControl.FormatNumberHandler(base.GetMapCore().MapControl, num, this.NumericLabelFormat));
                }
            }
            else
            {
                if (swatchColor.HasTextValue)
                {
                    return(swatchColor.TextValue);
                }
                double num2 = (swatchColor.FromValue + swatchColor.ToValue) / 2.0;
                result = ((base.GetMapCore().MapControl.FormatNumberHandler == null) ? num2.ToString(this.NumericLabelFormat, CultureInfo.CurrentCulture) : base.GetMapCore().MapControl.FormatNumberHandler(base.GetMapCore().MapControl, num2, this.NumericLabelFormat));
            }
            return(result);
        }
        public SwatchColor Add(string name)
        {
            SwatchColor swatchColor = new SwatchColor();

            swatchColor.Name = name;
            this.Add(swatchColor);
            return(swatchColor);
        }
        public void UpdateColorSwatchAndLegend()
        {
            MapCore mapCore = base.GetMapCore();

            if (mapCore != null)
            {
                Field field = this.GetField();
                if (this.ShowInColorSwatch)
                {
                    foreach (CustomColor customColor3 in this.CustomColors)
                    {
                        if (customColor3.VisibleInt)
                        {
                            SwatchColor swatchColor = mapCore.ColorSwatchPanel.Colors.Add("");
                            swatchColor.automaticallyAdded = true;
                            swatchColor.Color          = customColor3.Color;
                            swatchColor.SecondaryColor = customColor3.SecondaryColor;
                            swatchColor.GradientType   = customColor3.GradientType;
                            swatchColor.HatchStyle     = customColor3.HatchStyle;
                            if (field != null && field.IsNumeric())
                            {
                                swatchColor.FromValue = field.ConvertToDouble(field.Parse(customColor3.FromValueInt));
                                swatchColor.ToValue   = field.ConvertToDouble(field.Parse(customColor3.ToValueInt));
                            }
                            else
                            {
                                swatchColor.TextValue = customColor3.FromValueInt;
                            }
                        }
                    }
                }
                if (this.ShowInLegend != string.Empty && this.ShowInLegend != "(none)")
                {
                    Legend legend = (Legend)mapCore.Legends.GetByName(this.ShowInLegend);
                    if (legend != null)
                    {
                        foreach (CustomColor customColor4 in this.CustomColors)
                        {
                            if (customColor4.VisibleInt)
                            {
                                LegendItem legendItem = legend.Items.Add("");
                                legendItem.automaticallyAdded = true;
                                legendItem.ItemStyle          = LegendItemStyle.Path;
                                legendItem.BorderColor        = customColor4.BorderColor;
                                legendItem.Color          = customColor4.Color;
                                legendItem.SecondaryColor = customColor4.SecondaryColor;
                                legendItem.GradientType   = customColor4.GradientType;
                                legendItem.HatchStyle     = customColor4.HatchStyle;
                                legendItem.Text           = base.GetLegendText(field, customColor4.FromValueInt, customColor4.ToValueInt);
                                legendItem.PathWidth      = this.WidthInLegend;
                                legendItem.PathLineStyle  = base.LineStyleInLegend;
                                legendItem.BorderWidth    = base.BorderWidthInLegend;
                            }
                        }
                    }
                }
            }
        }
 private void PopulateDummyData()
 {
     if (this.Colors.Count == 0)
     {
         ColorGenerator colorGenerator = new ColorGenerator();
         Color[]        array          = colorGenerator.GenerateColors(MapColorPalette.Light, 5);
         for (int i = 0; i < array.Length; i++)
         {
             SwatchColor swatchColor = new SwatchColor("", (double)((i + 1) * 100), (double)((i + 2) * 100));
             swatchColor.Color = array[i];
             this.Colors.Add(swatchColor);
         }
     }
 }
        private Brush CreateColorBoxBrush(MapGraphics g, RectangleF colorBoxBoundsAbs, int colorIndex)
        {
            if (colorIndex < 0)
            {
                return(new SolidBrush(this.RangeGapColor));
            }
            Brush         brush          = null;
            SwatchColor   swatchColor    = this.Colors[colorIndex];
            Color         color          = swatchColor.Color;
            Color         secondaryColor = swatchColor.SecondaryColor;
            GradientType  gradientType   = swatchColor.GradientType;
            MapHatchStyle hatchStyle     = swatchColor.HatchStyle;

            if (hatchStyle != 0)
            {
                return(MapGraphics.GetHatchBrush(hatchStyle, color, secondaryColor));
            }
            if (gradientType != 0)
            {
                return(g.GetGradientBrush(colorBoxBoundsAbs, color, secondaryColor, gradientType));
            }
            return(new SolidBrush(color));
        }
 public void Remove(SwatchColor value)
 {
     base.List.Remove(value);
 }
 public int Add(SwatchColor value)
 {
     return(base.List.Add(value));
 }
示例#8
0
        public void UpdateColorSwatchAndLegend()
        {
            MapCore mapCore = base.GetMapCore();

            if (mapCore != null)
            {
                Field field = this.GetField();
                if (this.ShowInColorSwatch)
                {
                    foreach (PredefinedSymbol predefinedSymbol3 in this.PredefinedSymbols)
                    {
                        if (predefinedSymbol3.Visible)
                        {
                            SwatchColor swatchColor = mapCore.ColorSwatchPanel.Colors.Add("");
                            swatchColor.automaticallyAdded = true;
                            swatchColor.Color          = predefinedSymbol3.Color;
                            swatchColor.SecondaryColor = predefinedSymbol3.SecondaryColor;
                            swatchColor.GradientType   = predefinedSymbol3.GradientType;
                            swatchColor.HatchStyle     = predefinedSymbol3.HatchStyle;
                            if (field != null && field.IsNumeric())
                            {
                                swatchColor.FromValue = field.ConvertToDouble(field.Parse(predefinedSymbol3.FromValueInt));
                                swatchColor.ToValue   = field.ConvertToDouble(field.Parse(predefinedSymbol3.ToValueInt));
                            }
                            else
                            {
                                swatchColor.TextValue = predefinedSymbol3.FromValueInt;
                            }
                        }
                    }
                }
                if (this.ShowInLegend != string.Empty && this.ShowInLegend != "(none)")
                {
                    Legend legend = (Legend)mapCore.Legends.GetByName(this.ShowInLegend);
                    if (legend != null)
                    {
                        foreach (PredefinedSymbol predefinedSymbol4 in this.PredefinedSymbols)
                        {
                            if (predefinedSymbol4.Visible)
                            {
                                LegendItem legendItem = legend.Items.Add("");
                                legendItem.automaticallyAdded = true;
                                legendItem.ShadowOffset       = predefinedSymbol4.ShadowOffset;
                                legendItem.Text = this.GetLegendText(field, predefinedSymbol4.FromValueInt, predefinedSymbol4.ToValueInt);
                                if (!string.IsNullOrEmpty(predefinedSymbol4.Image))
                                {
                                    LegendCell legendCell = new LegendCell(LegendCellType.Image, predefinedSymbol4.Image);
                                    legendCell.ImageTranspColor = predefinedSymbol4.ImageTransColor;
                                    legendCell.Margins.Top      = 15;
                                    legendCell.Margins.Bottom   = 15;
                                    LegendCell cell = new LegendCell(LegendCellType.Text, "#LEGENDTEXT", ContentAlignment.MiddleLeft);
                                    legendItem.Cells.Add(legendCell);
                                    legendItem.Cells.Add(cell);
                                }
                                else
                                {
                                    legendItem.ItemStyle            = LegendItemStyle.Symbol;
                                    legendItem.MarkerStyle          = predefinedSymbol4.MarkerStyle;
                                    legendItem.MarkerColor          = predefinedSymbol4.Color;
                                    legendItem.MarkerWidth          = (float)((predefinedSymbol4.Width < 0.0010000000474974513) ? 13.0 : predefinedSymbol4.Width);
                                    legendItem.MarkerHeight         = (float)((predefinedSymbol4.Height < 0.0010000000474974513) ? 13.0 : predefinedSymbol4.Height);
                                    legendItem.MarkerGradientType   = predefinedSymbol4.GradientType;
                                    legendItem.MarkerHatchStyle     = predefinedSymbol4.HatchStyle;
                                    legendItem.MarkerSecondaryColor = predefinedSymbol4.SecondaryColor;
                                    legendItem.MarkerBorderColor    = predefinedSymbol4.BorderColor;
                                    legendItem.MarkerBorderWidth    = predefinedSymbol4.BorderWidth;
                                    legendItem.MarkerBorderStyle    = predefinedSymbol4.BorderStyle;
                                }
                            }
                        }
                    }
                }
            }
        }