コード例 #1
0
        private void AddThematicLegendItems(DemographicStyleBuilder styleBuilder, LegendAdornmentLayer legendAdornmentLayer, Map map)
        {
            ShapeFileFeatureLayer statesLayer   = map.DynamicOverlay.Layers["usStatesLayer"] as ShapeFileFeatureLayer;
            ClassBreakStyle       thematicStyle = (ClassBreakStyle)styleBuilder.GetStyle(statesLayer.FeatureSource);

            for (int i = 0; i < thematicStyle.ClassBreaks.Count; i++)
            {
                LegendItem legendItem = new LegendItem();

                if (i < thematicStyle.ClassBreaks.Count)
                {
                    legendItem.ImageStyle       = thematicStyle.ClassBreaks[i].DefaultAreaStyle;
                    legendItem.ImageWidth       = 20;
                    legendItem.TextRightPadding = 5;
                    legendItem.RightPadding     = 5;

                    string text = string.Empty;
                    if (i != thematicStyle.ClassBreaks.Count - 1)
                    {
                        text = string.Format("{0:#,0.####} ~ {1:#,0.####}",
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value),
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i + 1].Value));
                    }
                    else
                    {
                        text = string.Format("> {0:#,0.####}",
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value));
                    }
                    legendItem.TextStyle = new TextStyle(text, new GeoFont("Segoe UI", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black));
                }
                legendAdornmentLayer.LegendItems.Add(legendItem);
            }
        }
コード例 #2
0
        private void AddValueCircleLegendItems(DemographicStyleBuilder styleBuilder, LegendAdornmentLayer legendAdornmentLayer, Map map)
        {
            ShapeFileFeatureLayer statesLayer      = map.DynamicOverlay.Layers["usStatesLayer"] as ShapeFileFeatureLayer;
            ValueCircleStyle      valueCircleStyle = (ValueCircleStyle)styleBuilder.GetStyle(statesLayer.FeatureSource);

            int[] circleAreas = new int[] { 160, 320, 640, 1280 };
            foreach (int circleArea in circleAreas)
            {
                LegendItem legendItem = new LegendItem();
                double     radius     = Math.Sqrt(circleArea / Math.PI);
                legendItem.ImageStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(valueCircleStyle.InnerColor), new GeoPen(new GeoSolidBrush(valueCircleStyle.OuterColor)), (int)(radius * 2));
                AreaStyle maskStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.LightGray, 1), new GeoSolidBrush(GeoColor.SimpleColors.Transparent));
                legendItem.ImageMask        = maskStyle;
                legendItem.ImageWidth       = 48;
                legendItem.TextTopPadding   = 16;
                legendItem.TextRightPadding = 5;
                legendItem.BottomPadding    = 16;
                legendItem.TopPadding       = 16;
                legendItem.RightPadding     = 5;

                double drawingRadius = circleArea / valueCircleStyle.DrawingRadiusRatio * valueCircleStyle.BasedScale / valueCircleStyle.DefaultZoomLevel.Scale;
                double ratio         = (valueCircleStyle.MaxValidValue - valueCircleStyle.MinValidValue) / (valueCircleStyle.MaxCircleAreaInDefaultZoomLevel - valueCircleStyle.MinCircleAreaInDefaultZoomLevel);
                double resultValue   = (drawingRadius - valueCircleStyle.MinCircleAreaInDefaultZoomLevel) * ratio + valueCircleStyle.MinValidValue;

                string text = DemographicStyleTextFormatter.GetFormatedStringForLegendItem(valueCircleStyle.ColumnName, resultValue);
                legendItem.TextStyle = new TextStyle(text, new GeoFont("Segoe UI", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black));

                legendAdornmentLayer.LegendItems.Add(legendItem);
            }
        }
コード例 #3
0
        private string GetIdentifiedFeatureInfo(JsonCallbackRequest callbackRequest, Map map)
        {
            // Get the requested sub-categories
            Category selectedCategory = null;
            Collection <CategoryItem> selectedCategoryItems = new Collection <CategoryItem>();

            if (callbackRequest.StyleBuildType == DemographicStyleBuilderType.PieChart)
            {
                selectedCategoryItems = GetCategoryItemByAlias(callbackRequest.SelectedCategoryItems, ref selectedCategory);
            }
            else
            {
                selectedCategoryItems = GetCategoryItemByAlias(new Collection <string>()
                {
                    callbackRequest.RequestColumnAlias
                }, ref selectedCategory);
            }

            // Get the selected columns
            Collection <string> selectedColumns = new Collection <string>();

            foreach (CategoryItem categoryItem in selectedCategoryItems)
            {
                selectedColumns.Add(categoryItem.ColumnName);
            }
            selectedColumns.Add("Name");

            // Find the identified feature with specified columns
            ShapeFileFeatureLayer statesLayer = map.DynamicOverlay.Layers["usStatesLayer"] as ShapeFileFeatureLayer;

            statesLayer.Open();
            Feature identifiedFeature = statesLayer.FeatureSource.GetFeatureById(callbackRequest.SelectedFeatureId, selectedColumns);

            ((CloudPopup)map.Popups["featureInfoPopup"]).Position = identifiedFeature.GetShape().GetCenterPoint();

            // Format the inner-html of the popup
            StringBuilder popupHtml = new StringBuilder("<table>");

            popupHtml.Append(string.Format("<tr><td class='popupTitle'>{0}</td></tr>", identifiedFeature.ColumnValues["Name"]));
            popupHtml.Append("<tr><td><div class='hrLine'></div></td></tr>");
            for (int i = 0; i < selectedColumns.Count - 1; i++)
            {
                string formatedString = DemographicStyleTextFormatter.GetFormatedString(selectedColumns[i], double.Parse(identifiedFeature.ColumnValues[selectedColumns[i]]));
                popupHtml.Append(string.Format("<tr class='popupText'><td>{0}</td></tr>", formatedString));
            }
            popupHtml.Append("</table>");

            return(popupHtml.ToString());
        }
コード例 #4
0
        private void AddDotDensityLegendItems(DemographicStyleBuilder styleBuilder, LegendAdornmentLayer legendAdornmentLayer, Map map)
        {
            ShapeFileFeatureLayer statesLayer     = map.DynamicOverlay.Layers["usStatesLayer"] as ShapeFileFeatureLayer;
            CustomDotDensityStyle dotDensityStyle = (CustomDotDensityStyle)styleBuilder.GetStyle(statesLayer.FeatureSource);

            int[] pointCounts = new int[] { 5, 10, 20, 50 };
            foreach (int pointCount in pointCounts)
            {
                LegendItem legendItem = new LegendItem();
                legendItem.ImageMask        = new AreaStyle(new GeoPen(GeoColor.StandardColors.LightGray, 1), new GeoSolidBrush(GeoColor.SimpleColors.Transparent));
                legendItem.ImageWidth       = 48;
                legendItem.TextTopPadding   = 16;
                legendItem.TextRightPadding = 5;
                legendItem.BottomPadding    = 16;
                legendItem.TopPadding       = 16;
                legendItem.RightPadding     = 5;
                CustomDotDensityStyle legendDotDensityStyle = (CustomDotDensityStyle)dotDensityStyle.CloneDeep();
                legendDotDensityStyle.DrawingPointsNumber = pointCount;
                legendItem.ImageStyle = legendDotDensityStyle;

                string text = string.Format(CultureInfo.InvariantCulture, "{0:0.####}", DemographicStyleTextFormatter.GetFormatedStringForLegendItem(dotDensityStyle.ColumnName, (pointCount / dotDensityStyle.PointToValueRatio)));
                legendItem.TextStyle = new TextStyle(text, new GeoFont("Segoe UI", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black));

                legendAdornmentLayer.LegendItems.Add(legendItem);
            }
        }