使用AE开发,有时会由程序生成新的图层,并添加到MapControl中显示,而此时如果没有完备的符号选择器的话,新添加的此图层的显示,比如最基础的线条的颜色粗细就会被随机指定。有时这个问题无所谓,但有时我们就会希望能由程序指定其显示的具体方式。于是就有了下面的函数代码,当然,这个函数只是为polyline图层指定相应的显示方式,point以及polygon的显示方式还没有涉及到,貌似也差不多。
实现代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
private void funChangeStyle(IFeatureLayer pFL) { IFeatureLayer featureLayer = pFL; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; ISimpleRenderer simpleRenderer; ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.5; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; simpleLineSymbol.Color = rgbColor; simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = (ISymbol)simpleLineSymbol; geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; mainMap.ActiveView.ContentsChanged(); mainMap.Refresh(esriViewDrawPhase.esriViewGeography, null , null ); } |