private void Configure(IFeatureSet inFeatureSet) { if (inFeatureSet.FeatureType != FeatureType.Polygon) { throw new PolygonFeatureTypeException(); } PolygonScheme ps = new PolygonScheme(); ps.SetParentItem(this); Symbology = ps; }
/// <summary> /// This should launch an open file dialog instead of the usual thing. /// </summary> /// <param name="context">ITypeDescriptorContext</param> /// <param name="provider">IServiceProvider</param> /// <param name="value">The object being displayed</param> /// <returns>A new version of the object if the dialog was ok.</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _original = value as IPolygonScheme; _editCopy = _original.Copy(); IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); NamedList<IPolygonCategory> cats = new NamedList<IPolygonCategory>(_editCopy.Categories, "Category"); CollectionPropertyGrid frm = new CollectionPropertyGrid(cats); frm.ChangesApplied += FrmChangesApplied; frm.AddItemClicked += FrmAddItemClicked; dialogProvider.ShowDialog(frm); return _original; // don't bother swapping out the edit copy, just store copies of the categories when changes are applied. }
/// <summary> /// This should launch an open file dialog instead of the usual thing. /// </summary> /// <param name="context">ITypeDescriptorContext</param> /// <param name="provider">IServiceProvider</param> /// <param name="value">The object being displayed</param> /// <returns>A new version of the object if the dialog was ok.</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _original = value as IPolygonScheme; _editCopy = _original.Copy(); IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); NamedList <IPolygonCategory> cats = new NamedList <IPolygonCategory>(_editCopy.Categories, "Category"); CollectionPropertyGrid frm = new CollectionPropertyGrid(cats); frm.ChangesApplied += FrmChangesApplied; frm.AddItemClicked += FrmAddItemClicked; dialogProvider.ShowDialog(frm); return(_original); // don't bother swapping out the edit copy, just store copies of the categories when changes are applied. }
public void ConvertLayerProperties_MapPolygonDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory() { // Setup const string metadataAttribute = "Meta"; var random = new Random(21); var theme = new MapTheme <PolygonCategoryTheme>("Other Meta", 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 polygonStyle = 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) } }; var mapPolygonLayer = new MapPolygonLayer(); var converter = new MapPolygonDataConverter(); // Call converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer); // Assert IPolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle); IPolygonScheme appliedScheme = mapPolygonLayer.Symbology; Assert.AreEqual(1, appliedScheme.Categories.Count); IPolygonCategory baseCategory = appliedScheme.Categories[0]; AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer); Assert.IsNull(baseCategory.FilterExpression); }
/// <summary> /// Initializes a new PolygonCategoryCollection instance with the supplied scheme. /// </summary> /// <param name="scheme">The scheme to use ofr this collection.</param> public PolygonCategoryCollection(IPolygonScheme scheme) { _scheme = scheme; }
public void ConvertLayerProperties_MapPolygonDataWithThemeAndMetaDataNameInFeatures_ConvertDataToMapPolygonLayer() { // Setup const string metadataAttribute = "Meta"; var random = new Random(21); var unequalCriterion = new ValueCriterion(ValueCriterionOperator.UnequalValue, "unequal value"); var equalCriterion = new ValueCriterion(ValueCriterionOperator.EqualValue, "equal value"); var theme = new MapTheme <PolygonCategoryTheme>(metadataAttribute, new[] { new PolygonCategoryTheme(equalCriterion, new PolygonStyle { FillColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeThickness = random.Next(1, 48) }), new PolygonCategoryTheme(unequalCriterion, new PolygonStyle { FillColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeColor = Color.FromKnownColor(random.NextEnum <KnownColor>()), StrokeThickness = random.Next(1, 48) }) }); var polygonStyle = 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) } }; var mapPolygonLayer = new MapPolygonLayer(); var converter = new MapPolygonDataConverter(); // Call converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer); // Assert PolygonSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(polygonStyle); IPolygonScheme appliedScheme = mapPolygonLayer.Symbology; Assert.AreEqual(3, appliedScheme.Categories.Count); IPolygonCategory baseCategory = appliedScheme.Categories[0]; AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer); Assert.IsNull(baseCategory.FilterExpression); IPolygonCategory equalSchemeCategory = appliedScheme.Categories[1]; string expectedFilter = $"[1] = '{equalCriterion.Value}'"; Assert.AreEqual(expectedFilter, equalSchemeCategory.FilterExpression); PolygonStyle expectedCategoryStyle = theme.CategoryThemes.ElementAt(0).Style; expectedSymbolizer = CreateExpectedSymbolizer(expectedCategoryStyle); AssertAreEqual(expectedSymbolizer, equalSchemeCategory.Symbolizer); IPolygonCategory unEqualSchemeCategory = appliedScheme.Categories[2]; expectedFilter = $"NOT [1] = '{unequalCriterion.Value}'"; Assert.AreEqual(expectedFilter, unEqualSchemeCategory.FilterExpression); expectedCategoryStyle = theme.CategoryThemes.ElementAt(1).Style; expectedSymbolizer = CreateExpectedSymbolizer(expectedCategoryStyle); AssertAreEqual(expectedSymbolizer, unEqualSchemeCategory.Symbolizer); }