public void MessageReceived(Core.Result.Events.ResultLayerSelected theEvent) { if (theEvent.ResultSet == null) { this.resultsGroup.Layers.Remove(this.resultsLayer); this.resultsLayer = null; return; } if (this.curResultsSet != theEvent.ResultSet) { SetupResultsMapGroup(theEvent.ResultSet); } if (this.resultsLayer == null) { return; } var layers = theEvent.SelectedLayers; IFeatureScheme scheme = this.resultsLayer.Symbology.Clone() as IFeatureScheme; this.resultsLayer.Symbology.SuspendEvents(); scheme.ClearCategories(); for (int i = 0; i < layers.Count; i++) { var cat = new LineCategory(this.colorList[i % this.colorList.Count], 1); string filter = "[LayerName] = '" + layers[i] + "'"; cat.FilterExpression = filter; cat.LegendText = layers[i]; scheme.AddCategory(cat); } BeginInvoke(new MethodInvoker(delegate { this.resultsLayer.Symbology.CopyProperties(scheme); this.resultsLayer.Symbology.ResumeEvents(); })); }
private IFeatureScheme CreateCategoryScheme(TFeatureBasedMapData mapData) { IFeatureScheme scheme = CreateScheme(); scheme.ClearCategories(); scheme.AddCategory(CreateDefaultCategory(mapData)); MapTheme <TCategoryTheme> mapTheme = mapData.Theme; Dictionary <string, int> attributeMapping = GetAttributeMapping(mapData); if (attributeMapping.ContainsKey(mapTheme.AttributeName)) { int attributeIndex = attributeMapping[mapTheme.AttributeName]; foreach (TCategoryTheme categoryTheme in mapTheme.CategoryThemes) { IFeatureCategory category = CreateFeatureCategory(categoryTheme); category.FilterExpression = CreateFilterExpression(attributeIndex, categoryTheme.Criterion); scheme.AddCategory(category); } } return(scheme); }