示例#1
0
        public DotDensityAreaStyleUserControl(DotDensityStyle style, StyleBuilderArguments requiredValues)
        {
            InitializeComponent();
            this.style          = style;
            this.RequiredValues = requiredValues;

            if (RequiredValues.FeatureLayer == null || RequiredValues.FeatureLayer is InMemoryFeatureLayer)
            {
                viewDataButton.IsEnabled = false;
            }
            var ratio = Math.Round(1 / style.PointToValueRatio);

            dotDensityStyleViewModel = new DotDensityStyleViewModel(style, requiredValues);
            if (ratio != 1)
            {
                dotDensityStyleViewModel.PointValueRatioY = ratio;
            }
            DataContext = dotDensityStyleViewModel;

            string helpUri = GisEditor.LanguageManager.GetStringResource("DotDensityAreaStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }
        }
        private void DrawDotDensityFeatures_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp");

            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.Country1;

            ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\USStates.shp");

            statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.Country1);
            statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Draw features based dot density
            DotDensityStyle dotDensityStyle = new DotDensityStyle();

            dotDensityStyle.ColumnName        = "POP1990";
            dotDensityStyle.PointToValueRatio = 0.00002;
            dotDensityStyle.CustomPointStyle  = new PointStyle(PointSymbolType.Star, new GeoSolidBrush(GeoColor.StandardColors.Black), 5);
            statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(dotDensityStyle);

            LayerOverlay statesOverlay = new LayerOverlay();

            statesOverlay.Layers.Add("WorldLayer", worldLayer);
            statesOverlay.Layers.Add("StatesLayer", statesLayer);
            winformsMap1.Overlays.Add(statesOverlay);

            winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.Default;
            winformsMap1.CurrentExtent     = new RectangleShape(-126.4, 48.8, -67.0, 19.0);

            winformsMap1.Refresh();
        }
示例#3
0
        private void NotifyPointValueRatioIsBeyondTheRecommendedValue(DotDensityStyle style)
        {
            var result = System.Windows.Forms.MessageBox.Show(String.Format(GisEditor.LanguageManager.GetStringResource("CurrentDotsValueTooBigText"), Math.Round(1.0 / RecommendPointValueRatio)), GisEditor.LanguageManager.GetStringResource("MessageBoxWarningTitle"), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                PointValueRatioY = 1 / RecommendPointValueRatio;
            }
            else
            {
                style.PointToValueRatio = 1 / PointValueRatioY;
            }
        }
示例#4
0
        private void NotifyPointStyleTypeChanged(DotDensityStyle style)
        {
            var result = System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ChangingPointTypeWillDeleteText"), GisEditor.LanguageManager.GetStringResource("MessageBoxWarningTitle"), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                style.CustomPointStyle = null;
            }
            else
            {
                SelectedPointStyleType = GetPointStyleType(style.CustomPointStyle);
            }
        }
        public DotDensityAreaStyleItem(Style style)
            : base(style)
        {
            CanAddInnerStyle = true;
            dotDensityStyle  = style as DotDensityStyle;

            if (dotDensityStyle != null && dotDensityStyle.CustomPointStyle != null)
            {
                foreach (var pointStyle in dotDensityStyle.CustomPointStyle.CustomPointStyles.Reverse())
                {
                    pointStyle.Name = GisEditor.StyleManager.GetStylePluginByStyle(pointStyle).Name;
                    var styleItem = GisEditor.StyleManager.GetStyleLayerListItem(pointStyle);
                    Children.Add(styleItem);
                }
            }
        }
示例#6
0
        public DotDensityStyleViewModel(DotDensityStyle style, StyleBuilderArguments requiredValues)
            : base(style)
        {
            HelpKey = "DotDensityAreaStyleHelp";

            ActualObject          = style;
            actualDotDensityStyle = style;
            if (style.PointToValueRatio == 1.0)
            {
                RecommendPointValueRatio = 0.00001;
            }
            else
            {
                recommendPointValueRatio = style.PointToValueRatio;
            }
            SelectedPointStyleType = GetPointStyleType(style.CustomPointStyle);
            InitRequiredColumnNames(requiredValues);
            InitializeWarningTimer();
            InitializePointValueRatio();
        }
        protected override void InitializeMap()
        {
            MapView.CurrentExtent = new RectangleShape(-14299615, 20037508, -7255178, -1015546);

            ShapeFileFeatureLayer usLayer      = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usStatesCensus2010.shp"));
            LayerOverlay          layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(usLayer);
            MapView.Overlays.Add(layerOverlay);

            usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
            usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new AreaStyle(new GeoPen(new GeoSolidBrush(GeoColor.SimpleColors.Black))));
            //TODO: check this
            double          pointToValueRatio = 0.0000094778167166538189;
            PointStyle      pointStyle        = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Black, 7);
            DotDensityStyle dotDensityStyle   = new DotDensityStyle("Population", pointToValueRatio, pointStyle);

            dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromHtml("#a57431"), 5);

            usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(dotDensityStyle);
            usLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        }
示例#8
0
        /// <summary>
        /// Gets an overlay applied with DotDensity style.
        /// </summary>
        public static LayerOverlay GetOverlayWithDotDensityStyle()
        {
            // Get the file path name from its relative path.
            string shpFilePathName = GetFullPath("App_Data/usStatesCensus2010.shp");

            ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(shpFilePathName);

            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(20, GeoColor.FromHtml("#00e6fe")), GeoColor.StandardColors.Gray));
            // Create the DotDensityStyle
            DotDensityStyle dotDensityStyle = new DotDensityStyle("Population", 0.0000094778167166538189, PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Black, 7));

            dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromHtml("#a57431"), 5);
            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(dotDensityStyle);
            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Apply projection to the shape file which is used for display.
            shapeFileFeatureLayer.FeatureSource.Projection = GetProjection();

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(shapeFileFeatureLayer);
            return(layerOverlay);
        }
示例#9
0
        /// <summary>
        /// Setup the map with the ThinkGeo Cloud Maps overlay.
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();


            // Set the map's unit of measurement to meters(Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer housingUnitsLayer = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Frisco 2010 Census Housing Units.shp"));

            // Project the layer's data to match the projection of the map
            housingUnitsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            DotDensityStyle housingUnitsStyle = new DotDensityStyle("H_UNITS", .1, 1, GeoColors.Blue);

            // Add and apply the ClassBreakStyle to the housingUnitsLayer
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(housingUnitsStyle);
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Add housingUnitsLayer to a LayerOverlay
            var layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(housingUnitsLayer);

            // Add layerOverlay to the mapView
            mapView.Overlays.Add(layerOverlay);

            // Set the map extent
            housingUnitsLayer.Open();
            mapView.CurrentExtent = housingUnitsLayer.GetBoundingBox();
            housingUnitsLayer.Close();
        }
示例#10
0
        private void Form_Load(object sender, EventArgs e)
        {
            // Set the map's unit of measurement to meters(Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer housingUnitsLayer = new ShapeFileFeatureLayer(@"../../../Data/Shapefile/Frisco 2010 Census Housing Units.shp");

            // Project the layer's data to match the projection of the map
            housingUnitsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Here we use a dot density type based on the number of housing units in the area.
            // It draws 1 sized blue circles with a ratio of one dot per 10 housing units in the data
            DotDensityStyle housingUnitsStyle = new DotDensityStyle("H_UNITS", .1, 1, GeoColors.Blue);

            // Add and apply the ClassBreakStyle to the housingUnitsLayer
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(housingUnitsStyle);
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Add housingUnitsLayer to a LayerOverlay
            var layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(housingUnitsLayer);

            // Add layerOverlay to the mapView
            mapView.Overlays.Add(layerOverlay);

            // Set the map extent
            housingUnitsLayer.Open();
            mapView.CurrentExtent = housingUnitsLayer.GetBoundingBox();
            housingUnitsLayer.Close();
        }
        public static bool CheckIsValid(this Style style)
        {
            AreaStyle       areaStyle       = style as AreaStyle;
            LineStyle       lineStyle       = style as LineStyle;
            PointStyle      pointStyle      = style as PointStyle;
            TextStyle       textStyle       = style as TextStyle;
            DotDensityStyle dotDensityStyle = style as DotDensityStyle;
            ClassBreakStyle classBreakStyle = style as ClassBreakStyle;
            RegexStyle      regexStyle      = style as RegexStyle;
            FilterStyle     filterStyle     = style as FilterStyle;
            CompositeStyle  componentStyle  = style as CompositeStyle;

            bool isStyleValid = style.IsActive && !string.IsNullOrEmpty(style.Name);

            if (areaStyle != null)
            {
                isStyleValid &= (!areaStyle.FillSolidBrush.Color.IsTransparent ||
                                 !areaStyle.OutlinePen.Color.IsTransparent ||
                                 areaStyle.Advanced.FillCustomBrush != null);
            }
            else if (lineStyle != null)
            {
                isStyleValid &= (!lineStyle.CenterPen.Color.IsTransparent ||
                                 !lineStyle.OuterPen.Color.IsTransparent ||
                                 !lineStyle.InnerPen.Color.IsTransparent);
            }
            else if (pointStyle != null)
            {
                switch (pointStyle.PointType)
                {
                case PointType.Symbol:
                    isStyleValid &= (!pointStyle.SymbolPen.Color.IsTransparent ||
                                     pointStyle.Image != null ||
                                     !pointStyle.SymbolSolidBrush.Color.IsTransparent ||
                                     pointStyle.Advanced.CustomBrush != null);
                    break;

                case PointType.Bitmap:
                    isStyleValid &= pointStyle.Image != null;
                    break;

                case PointType.Character:
                    isStyleValid &= pointStyle.CharacterFont != null &&
                                    (!pointStyle.CharacterSolidBrush.Color.IsTransparent ||
                                     pointStyle.Advanced.CustomBrush != null);
                    break;

                default:
                    break;
                }
            }
            else if (textStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(textStyle.TextColumnName) &&
                                (!textStyle.HaloPen.Color.IsTransparent ||
                                 !textStyle.TextSolidBrush.Color.IsTransparent ||
                                 textStyle.Advanced.TextCustomBrush != null);
            }
            else if (dotDensityStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(dotDensityStyle.ColumnName) &&
                                (dotDensityStyle.CustomPointStyle != null &&
                                 CheckIsValid(dotDensityStyle.CustomPointStyle) &&
                                 dotDensityStyle.PointToValueRatio != 0);
            }
            else if (classBreakStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(classBreakStyle.ColumnName) &&
                                classBreakStyle.ClassBreaks.Count != 0;
            }
            else if (regexStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(regexStyle.ColumnName) &&
                                regexStyle.RegexItems.Count != 0;
            }
            else if (filterStyle != null)
            {
                isStyleValid &= filterStyle.Conditions.Count > 0;
            }
            else if (componentStyle != null)
            {
                isStyleValid = true;
            }
            return(isStyleValid);
        }