private void Configure() { _categories = new PointCategoryCollection(); OnIncludeCategories(_categories); }
/// <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(PointCategoryCollection categories) { if (categories == null) return; categories.Scheme = null; categories.ItemChanged -= CategoriesItemChanged; categories.SelectFeatures -= OnSelectFeatures; categories.DeselectFeatures -= OnDeselectFeatures; }
/// <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(PointCategoryCollection categories) { if (categories == null) return; categories.Scheme = this; categories.ItemChanged += CategoriesItemChanged; categories.SelectFeatures += OnSelectFeatures; }
public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory() { // Given const string metadataAttribute = "Meta"; var mocks = new MockRepository(); var categoryOne = mocks.Stub <IPointCategory>(); var categoryTwo = mocks.Stub <IPointCategory>(); mocks.ReplayAll(); var mapPointLayer = new MapPointLayer { Symbology = new PointScheme { Categories = { categoryOne, categoryTwo } } }; var converter = new MapPointDataConverter(); var random = new Random(21); var pointStyle = new PointStyle { Color = Color.FromKnownColor(random.NextEnum <KnownColor>()), Size = random.Next(1, 48), Symbol = random.NextEnum <PointSymbol>(), StrokeColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeThickness = random.Next(1, 48) }; var theme = new MapTheme <PointCategoryTheme>(metadataAttribute, new[] { new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), new PointStyle { Color = Color.FromKnownColor(random.NextEnum <KnownColor>()), Size = random.Next(1, 48), Symbol = random.NextEnum <PointSymbol>(), StrokeColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeThickness = random.Next(1, 48) }) }); var mapPointData = new MapPointData("test", pointStyle, theme) { Features = new[] { CreateMapFeatureWithMetaData(metadataAttribute) } }; // When converter.ConvertLayerFeatures(mapPointData, mapPointLayer); // Then PointCategoryCollection categoryCollection = mapPointLayer.Symbology.Categories; Assert.AreEqual(1, categoryCollection.Count); IPointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle); AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer); mocks.VerifyAll(); }