根据IFeatureLayer在Map中的渲染颜色设置对应的DonetBar中Listbox中Layer项的符号

        /// 
        /// 显示Listbox 的layer数据
        /// 
        /// 
        /// 
        public static void SymbolLayerInGroupLayerListBox(ILayer pLayer, ListBoxAdv FeatureLayerListBoxAdv)
        {
            if (pLayer is IGroupLayer)
            {
                ListBoxItem layerNameItem = new ListBoxItem();
                layerNameItem.Image = Properties.Resources.图层;
                layerNameItem.Text = pLayer.Name;
                layerNameItem.Name = pLayer.Name;
                FeatureLayerListBoxAdv.Items.Add(layerNameItem);
                ICompositeLayer pCompositeLayer = pLayer as ICompositeLayer;
                for (int j = 0; j < pCompositeLayer.Count; j++)
                {
                    ILayer pcLayer = pCompositeLayer.Layer[j];
                    SymbolLayerInGroupLayerListBox(pcLayer, FeatureLayerListBoxAdv);
                }

            }
            if (pLayer is IFeatureLayer)
            {
                ListBoxItem layerItem = new ListBoxItem();
                layerItem.Text = pLayer.Name;
                layerItem.Name = pLayer.Name;
                layerItem.Tag = pLayer;

                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
                IFeatureRenderer pFeatRender = pGeoFeatureLayer.Renderer;
                ISimpleFillSymbol pSymbol = null;
                if (pFeatRender is ISimpleRenderer)
                {
                    ISimpleRenderer pSimple = pFeatRender as ISimpleRenderer;
                    pSymbol = pSimple.Symbol as ISimpleFillSymbol;
                    RgbColor rgbColor = new RgbColor();
                    rgbColor.RGB = pSymbol.Color.RGB;
                    Color pSymbolColor = Color.FromArgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
                    layerItem.SymbolColor = pSymbolColor;
                    layerItem.SymbolSet = eSymbolSet.Awesome;
                    layerItem.Symbol = "\uf04d";
                }
                FeatureLayerListBoxAdv.Items.Add(layerItem);
            }
            FeatureLayerListBoxAdv.RecalcLayout();
        }

 

你可能感兴趣的:(ArcEngine开发)