예제 #1
0
 private void Configure()
 {
     _categories = new PolygonCategoryCollection();
     OnIncludeCategories(_categories);
     PolygonCategory def = new PolygonCategory();
     _categories.Add(def);
 }
예제 #2
0
        private void ColorMap()
        {
            try
            {
                FeatureLayer fl = mainMap.Layers[0] as FeatureLayer;
                PolygonCategoryCollection pcc      = new PolygonCategoryCollection();
                PolygonScheme             myScheme = new PolygonScheme();

                myScheme.Categories = new PolygonCategoryCollection();


                string strrow       = "";
                int    iRegionColor = 0;

                foreach (BenMAPRollback brb in _monitorRollbackLine.BenMAPRollbacks)
                {
                    if (brb.SelectRegions.Count != 0)
                    {
                        iRegionColor += brb.SelectRegions.Count;
                    }
                }
                foreach (BenMAPRollback brb in _monitorRollbackLine.BenMAPRollbacks)
                {
                    if (brb.SelectRegions.Count != 0)
                    {
                        foreach (RowCol rc in brb.SelectRegions)
                        {
                            if (iRegionColor != dicMyColorIndex.Count)
                            {
                                if (strrow == "")
                                {
                                    strrow = dicMyColorIndex[rc.Col + "," + rc.Row].ToString();
                                }
                                else
                                {
                                    strrow += "," + dicMyColorIndex[rc.Col + "," + rc.Row].ToString();
                                }
                            }
                            PolygonCategory pcin = new PolygonCategory();

                            pcin.FilterExpression = string.Format("[{0}]={1} ", "MyColorIndex", dicMyColorIndex[rc.Col + "," + rc.Row].ToString());
                            pcin.Symbolizer.SetOutline(Color.Black, 1);
                            string[] strColor = brb.DrawingColor.Split(new char[] { ',' });
                            pcin.Symbolizer.SetFillColor(Color.FromArgb(Convert.ToInt32(strColor[0]), int.Parse(strColor[1]), int.Parse(strColor[2])));
                            myScheme.Categories.Add(pcin);
                        }
                    }
                }


                if (myScheme.Categories.Count > 0)
                {
                    if (iRegionColor != dicMyColorIndex.Count)
                    {
                        PolygonCategory pcin = new PolygonCategory();
                        pcin.FilterExpression = string.Format("[{0}] not in({1})", "MyColorIndex", strrow);

                        pcin.Symbolizer.SetFillColor(Color.White);
                        pcin.Symbolizer.SetOutline(Color.Black, 1);
                        myScheme.Categories.Add(pcin);
                    }
                    (fl as IFeatureLayer).Symbology = myScheme;
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }
예제 #3
0
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            const string metadataAttribute = "Meta";

            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <IPolygonCategory>();
            var categoryTwo = mocks.Stub <IPolygonCategory>();

            mocks.ReplayAll();

            var mapPolygonLayer = new MapPolygonLayer
            {
                Symbology = new PolygonScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapPolygonDataConverter();

            var random       = new Random(21);
            var polygonStyle = new PolygonStyle
            {
                FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var theme = new MapTheme <PolygonCategoryTheme>(metadataAttribute, new[]
            {
                new PolygonCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                         new PolygonStyle
                {
                    FillColor       = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });
            var mapPolygonData = new MapPolygonData("test", polygonStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            // When
            converter.ConvertLayerFeatures(mapPolygonData, mapPolygonLayer);

            // Then
            PolygonCategoryCollection categoryCollection = mapPolygonLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            PolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }
예제 #4
0
 /// <summary>
 /// Handle the event wiring and scheme update for the new categories.
 /// </summary>
 /// <param name="categories">The category collection to update</param>
 protected virtual void OnIncludeCategories(PolygonCategoryCollection categories)
 {
     if (categories == null) return;
     categories.Scheme = this;
     categories.SelectFeatures += OnSelectFeatures;
     categories.DeselectFeatures += OnDeselectFeatures;
     categories.ItemChanged += CategoriesItemChanged;
 }
예제 #5
0
 /// <summary>
 /// Handle the event un-wiring and scheme update for the old categories
 /// </summary>
 /// <param name="categories">The category collection to update.</param>
 protected virtual void OnExcludeCategories(PolygonCategoryCollection categories)
 {
     if (categories == null) return;
     categories.Scheme = null;
     categories.ItemChanged -= CategoriesItemChanged;
     categories.SelectFeatures -= OnSelectFeatures;
 }
예제 #6
0
 private void Configure()
 {
     _categories = new PolygonCategoryCollection();
     OnIncludeCategories(_categories);
 }