欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-04-12 10:35:07
...
        /// <summary>
        /// 显示Listbox 的layer数据
        /// </summary>
        /// <param name="pLayer"></param>
        /// <param name="FeatureLayerListBoxAdv"></param>
        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();
        }

 

相关标签: Symbol ListBox