您的位置:首页 > 其它

AO中如何利用style 文件渲染要素

2007-03-09 11:17 344 查看
1.新建style文件
在Arcmap中Tools--Styles--StyleManager
添加新的style文件,在文件中添加将要用于渲染的symbol,symbol的命名实别中文。

2 从SDE或者shp中添加地图,根据图层对应的symbol名称从style文件中提取symbol进行渲染操作

 


public void RenderLayer(ILayer layer)




...{


IGeoFeatureLayer geoLayer;


            //显示自动注记


            geoLayer = layer as IGeoFeatureLayer;


ISimpleRenderer simpleRenderer = new  SimpleRendererClass();


                string geotype="";


                if(geoLayer.FeatureClass.ShapeType==esriGeometryType.esriGeometryPolygon)




                ...{geotype="3";}




                else if(geoLayer.FeatureClass.ShapeType==esriGeometryType.esriGeometryPolyline)...{geotype="2";}




                else if(geoLayer.FeatureClass.ShapeType==esriGeometryType.esriGeometryPoint)...{geotype="1";}


                ISymbol sym=getSymbolByName(geotype,info.FHMC);


                //Set the symbol property of the renderer


                if(sym!=null)




                ...{


                    simpleRenderer.Symbol = (ISymbol) sym;


                    //Set the renderer property of the geo feature layer


                    geoLayer.Renderer = (IFeatureRenderer) simpleRenderer;}


}


private ISymbol getSymbolByName(string symbolstyle,string name)




        ...{


            ISymbol result=null;


            string stylepath=System.Configuration.ConfigurationSe
d287
ttings.AppSettings["SymbolPath"];


            IStyleGallery pStyleGallery =new StyleGalleryClass();


            IntPtr pointer = System.Runtime.InteropServices.Marshal.GetComInterfaceForObject(pStyleGallery, typeof(IStyleGallery));


            IStyleGalleryStorage pStyleStorage=pStyleGallery as IStyleGalleryStorage;


            


            //IStyleGalleryClass pStyleClass;


            IEnumStyleGalleryItem pEnumStyleGall;


            IStyleGalleryItem pStyleItem; 


            //IMarkerSymbol pMarkerSym;


            // pStyleGallery.ImportStyle(stylepath);


            string pp=pStyleStorage.DefaultStylePath;


            pStyleStorage.AddFile(stylepath);    


            if(symbolstyle=="1")




            ...{                                                                                                                                       


                pEnumStyleGall = pStyleGallery.get_Items("Marker Symbols", stylepath, "");}




            else if(symbolstyle=="2")...{pEnumStyleGall = pStyleGallery.get_Items("Line Symbols", stylepath, "");}




            else if(symbolstyle=="3")...{pEnumStyleGall = pStyleGallery.get_Items("Fill Symbols", stylepath, "");}




            else...{return null;}


            pEnumStyleGall.Reset();


            pStyleItem = pEnumStyleGall.Next();




            while ( pStyleItem != null)  //Loop through and access each marker




            ...{




                if(pStyleItem.Name==name)...{result=pStyleItem.Item as ISymbol;break;}


                


                pStyleItem = pEnumStyleGall.Next();


                


            }


            return result;


        }

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string null layer