protected override Collection<Style> GetStylesCore(FeatureSource featureSource)
        {
            // here we generate CustomDotDensityStyle.
            double totalValue = 0;
            featureSource.Open();
            int featureCount = featureSource.GetCount();
            for (int i = 0; i < featureCount; i++)
            {
                Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns);
                double columnValue;

                if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue))
                {
                    totalValue += columnValue;
                }
            }
            featureSource.Close();

            CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle();
            dotDensityStyle.ColumnName = SelectedColumns[0];
            dotDensityStyle.PointToValueRatio = DotDensityValue / (totalValue / featureCount);
            dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(Opacity, Color), 4);

            return new Collection<Style>() { dotDensityStyle };
        }
Example #2
0
        protected override Collection <Style> GetStylesCore(FeatureSource featureSource)
        {
            double totalValue = 0;

            featureSource.Open();
            int featureCount = featureSource.GetCount();

            for (int i = 0; i < featureCount; i++)
            {
                Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns);
                double  columnValue;
                double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue);
                totalValue += columnValue;
            }
            featureSource.Close();

            CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle();

            dotDensityStyle.ColumnName        = SelectedColumns[0];
            dotDensityStyle.PointToValueRatio = DotDensityValue / (totalValue / featureCount);
            dotDensityStyle.CustomPointStyle  = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(Opacity, Color), 4);

            return(new Collection <Style>()
            {
                dotDensityStyle
            });
        }
        private void AddDotDensityLegendItems(LegendAdornmentLayer legendAdornmentLayer)
        {
            CustomDotDensityStyle dotDensityStyle = (CustomDotDensityStyle)currentStyleBuilder.GetStyles(currentFeatureLayer.FeatureSource)[0];

            // Here we generate 4 legend items, for 5, 10, 20 and 50 points seperately.
            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.####}", TextFormatter.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);
            }
        }
Example #4
0
        protected override Style GetStyleCore(FeatureSource featureSource)
        {
            double totalValue = 0;

            featureSource.Open();
            int featureCount = featureSource.GetCount();

            for (int i = 0; i < featureCount; i++)
            {
                Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns);
                double  columnValue;
                double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue);
                totalValue += columnValue;
            }
            featureSource.Close();
            double pointToValueRatio = DotDensityValue / (totalValue / featureCount);

            CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle();

            dotDensityStyle.ColumnName        = SelectedColumns[0];
            dotDensityStyle.PointToValueRatio = pointToValueRatio;
            dotDensityStyle.CustomPointStyle  = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Opacity, Color)), 4);

            return(dotDensityStyle);
        }
        protected override void DrawCore(GeoCanvas geoCanvas, Style style)
        {
            Bitmap bitmap = new Bitmap(50, 50);

            CustomDotDensityStyle dotDensityStyle = style as CustomDotDensityStyle;
            RectangleShape        drawingExtent   = new RectangleShape(-180, 90, 180, -90);

            // Draw Icon Outline
            geoCanvas.BeginDrawing(bitmap, drawingExtent, GeographyUnit.DecimalDegree);
            geoCanvas.DrawArea(drawingExtent, new GeoPen(GeoColor.FromHtml("#cccccc"), 2), DrawingLevel.LevelOne);

            // Draw Icon points
            Random random = new Random(DateTime.Now.Millisecond);
            Collection <BaseShape> mockupPoints = new Collection <BaseShape>();

            for (int i = 0; i < DotCount; i++)
            {
                double x = random.NextDouble() * (drawingExtent.LowerRightPoint.X - drawingExtent.LowerLeftPoint.X) + drawingExtent.LowerLeftPoint.X;
                double y = random.NextDouble() * (drawingExtent.UpperLeftPoint.Y - drawingExtent.LowerLeftPoint.Y) + drawingExtent.LowerLeftPoint.Y;
                mockupPoints.Add(new PointShape(x, y));
            }
            dotDensityStyle.CustomPointStyle.Draw(mockupPoints, geoCanvas, new Collection <SimpleCandidate>(), new Collection <SimpleCandidate>());

            // Draw Icon Label
            geoCanvas.DrawText(DotCount.ToString("N0"), LabelFont, LabelBrush, null, new ScreenPointF[] { new ScreenPointF(20f, 20f) }, DrawingLevel.LabelLevel, 0, 0, 0);
            geoCanvas.EndDrawing();

            Title = string.Format(CultureInfo.InvariantCulture, "{0:0.####}", MapSuiteSampleHelper.GetFormatedStringForLegendItem(dotDensityStyle.ColumnName, (DotCount / dotDensityStyle.PointToValueRatio)));
            Image = bitmap;
        }