예제 #1
0
        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;
                            }
                        }
                    }
                }
            }
        }
예제 #2
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;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
 public void GetOptimalIntervals(Field field, ArrayList sortedList, object fromValue, object toValue, int intervalCount, ref object[] fromValues, ref object[] toValues)
 {
     if (sortedList.Count == 0 || AspNetCore.Reporting.Map.WebForms.Field.ToStringInvariant(fromValue) == AspNetCore.Reporting.Map.WebForms.Field.ToStringInvariant(toValue))
     {
         this.GetEqualIntervals(field, fromValue, toValue, intervalCount, ref fromValues, ref toValues);
     }
     else
     {
         intervalCount = Math.Min(intervalCount, sortedList.Count);
         if (intervalCount < 4)
         {
             if (intervalCount < 1)
             {
                 intervalCount = 1;
             }
             this.GetEqualIntervals(field, fromValue, toValue, intervalCount, ref fromValues, ref toValues);
         }
         else
         {
             if (intervalCount > sortedList.Count - 3)
             {
                 intervalCount = sortedList.Count - 3;
             }
             if (intervalCount < 4)
             {
                 if (intervalCount < 1)
                 {
                     intervalCount = 1;
                 }
                 this.GetEqualIntervals(field, fromValue, toValue, intervalCount, ref fromValues, ref toValues);
             }
             else
             {
                 ArrayList arrayList = new ArrayList();
                 for (int i = 0; i < sortedList.Count; i++)
                 {
                     arrayList.Add(field.ConvertToDouble(sortedList[i]));
                 }
                 int[] jenksBreaks = this.GetJenksBreaks(arrayList, intervalCount);
                 fromValues    = new object[jenksBreaks.Length];
                 toValues      = new object[jenksBreaks.Length];
                 fromValues[0] = this.GetRoundedAverage(field, sortedList[0], sortedList[0], true);
                 object roundedAverage = this.GetRoundedAverage(field, sortedList[jenksBreaks[0] - 1], sortedList[jenksBreaks[0]], true);
                 toValues[0] = roundedAverage;
                 for (int j = 1; j < fromValues.Length - 1; j++)
                 {
                     fromValues[j]  = roundedAverage;
                     roundedAverage = this.GetRoundedAverage(field, sortedList[jenksBreaks[j] - 1], sortedList[jenksBreaks[j]], true);
                     toValues[j]    = roundedAverage;
                 }
                 fromValues[fromValues.Length - 1] = roundedAverage;
                 toValues[fromValues.Length - 1]   = this.GetRoundedAverage(field, sortedList[sortedList.Count - 1], sortedList[sortedList.Count - 1], false);
                 if (this.FromValue != string.Empty)
                 {
                     fromValues[0] = field.Parse(this.FromValue);
                 }
                 if (this.ToValue != string.Empty)
                 {
                     toValues[toValues.Length - 1] = field.Parse(this.ToValue);
                 }
             }
         }
     }
 }