您的位置:首页 > 其它

根据图层获取要素的渲染颜色

2008-03-19 10:31 501 查看
根据图层获取要素的渲染颜色

public IColor GetFeatureLayerColor(IFeatureLayer pFeatureLayer,IFeature pFeature)

{

if (pFeature == null || pFeature == null) return null;

IColor _result = new RgbColorClass();

IGeoFeatureLayer pGeoFT = pFeatureLayer as IGeoFeatureLayer;

IFeatureRenderer pFeatureRender = pGeoFT.Renderer;

if (pFeatureRender != null)

{

if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)

{

ILineSymbol pLineSymbol = null;

pLineSymbol = (ILineSymbol)pFeatureRender.get_SymbolByFeature(pFeature);

_result = pLineSymbol.Color;

}

else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)

{

IFillSymbol pFillSymboll = (IFillSymbol)pFeatureRender.get_SymbolByFeature(pFeature);

_result = pFillSymboll.Color;

}

else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)

{

IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pFeatureRender.get_SymbolByFeature(pFeature);

_result = pMarkerSymbol.Color;

}

}

return _result;

}

通过IFeatureRender.get_SymbolByFeature(IFeature pFeature)方法获取要素的渲染方式,再根据不同类型图层的渲染方法转换到相应的接口获取颜色。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: