Exemple #1
0
        private string GetLabelCaption(int swatchColorIndex, bool getFromValue, SwatchLabelType currentLabelType)
        {
            SwatchColor swatchColor = Colors[swatchColorIndex];

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

            if (currentLabelType == SwatchLabelType.ShowBorderValue)
            {
                if (!swatchColor.HasTextValue)
                {
                    double num = (!getFromValue) ? swatchColor.ToValue : swatchColor.FromValue;
                    result = ((GetMapCore().MapControl.FormatNumberHandler == null) ? num.ToString(NumericLabelFormat, CultureInfo.CurrentCulture) : GetMapCore().MapControl.FormatNumberHandler(GetMapCore().MapControl, num, NumericLabelFormat));
                }
            }
            else
            {
                if (swatchColor.HasTextValue)
                {
                    return(swatchColor.TextValue);
                }
                double num2 = (swatchColor.FromValue + swatchColor.ToValue) / 2.0;
                result = ((GetMapCore().MapControl.FormatNumberHandler == null) ? num2.ToString(NumericLabelFormat, CultureInfo.CurrentCulture) : GetMapCore().MapControl.FormatNumberHandler(GetMapCore().MapControl, num2, NumericLabelFormat));
            }
            return(result);
        }
        internal void UpdateColorSwatchAndLegend()
        {
            MapCore mapCore = GetMapCore();

            if (mapCore == null)
            {
                return;
            }
            Field field = GetField();

            if (ShowInColorSwatch)
            {
                foreach (CustomColor customColor3 in 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 (!(ShowInLegend != string.Empty) || !(ShowInLegend != "(none)"))
            {
                return;
            }
            Legend legend = (Legend)mapCore.Legends.GetByName(ShowInLegend);

            if (legend == null)
            {
                return;
            }
            foreach (CustomColor customColor4 in CustomColors)
            {
                if (customColor4.VisibleInt)
                {
                    LegendItem legendItem = legend.Items.Add("");
                    legendItem.automaticallyAdded = true;
                    legendItem.ItemStyle          = LegendItemStyle.Shape;
                    legendItem.Color          = customColor4.Color;
                    legendItem.SecondaryColor = customColor4.SecondaryColor;
                    legendItem.GradientType   = customColor4.GradientType;
                    legendItem.HatchStyle     = customColor4.HatchStyle;
                    legendItem.Text           = GetLegendText(field, customColor4.FromValueInt, customColor4.ToValueInt);
                }
            }
        }
Exemple #3
0
        public SwatchColor Add(string name)
        {
            SwatchColor swatchColor = new SwatchColor();

            swatchColor.Name = name;
            Add(swatchColor);
            return(swatchColor);
        }
Exemple #4
0
 private void PopulateDummyData()
 {
     if (Colors.Count == 0)
     {
         Color[] array = new ColorGenerator().GenerateColors(MapColorPalette.Light, 5);
         for (int i = 0; i < array.Length; i++)
         {
             SwatchColor swatchColor = new SwatchColor("", (i + 1) * 100, (i + 2) * 100);
             swatchColor.Color = array[i];
             Colors.Add(swatchColor);
         }
     }
 }
Exemple #5
0
        private Brush CreateColorBoxBrush(MapGraphics g, RectangleF colorBoxBoundsAbs, int colorIndex)
        {
            if (colorIndex < 0)
            {
                return(new SolidBrush(RangeGapColor));
            }
            Brush         brush          = null;
            SwatchColor   swatchColor    = 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));
        }
        internal void UpdateColorSwatchAndLegend()
        {
            MapCore mapCore = GetMapCore();

            if (mapCore == null)
            {
                return;
            }
            Field field = GetField();

            if (ShowInColorSwatch)
            {
                foreach (PredefinedSymbol predefinedSymbol3 in 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 (!(ShowInLegend != string.Empty) || !(ShowInLegend != "(none)"))
            {
                return;
            }
            Legend legend = (Legend)mapCore.Legends.GetByName(ShowInLegend);

            if (legend == null)
            {
                return;
            }
            foreach (PredefinedSymbol predefinedSymbol4 in PredefinedSymbols)
            {
                if (predefinedSymbol4.Visible)
                {
                    LegendItem legendItem = legend.Items.Add("");
                    legendItem.automaticallyAdded = true;
                    legendItem.ShadowOffset       = predefinedSymbol4.ShadowOffset;
                    legendItem.Text = 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          = ((predefinedSymbol4.Width < 0.001f) ? 13f : predefinedSymbol4.Width);
                        legendItem.MarkerHeight         = ((predefinedSymbol4.Height < 0.001f) ? 13f : 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;
                    }
                }
            }
        }
Exemple #7
0
 public void Remove(SwatchColor value)
 {
     base.List.Remove(value);
 }
Exemple #8
0
 public int Add(SwatchColor value)
 {
     return(base.List.Add(value));
 }