将图层添加到对应的图层树的节点当中

        /// 
        /// 往目标节点中添加图层节点
        /// 
        /// 
        /// 
        private static void AddLayerToNode(ILayer pLayer, ComboTree GroupLayerComboTree)
        {
            Node pGroupNode = new Node();
            pGroupNode.Text = pLayer.Name;
            pGroupNode.Name = pLayer.Name;
            if (pLayer is IGroupLayer)
            {
                pGroupNode.Image = Properties.Resources.图层;
                //pGroupNode.Tag = pLayer;
                //GroupLayerComboTree.Nodes.Add(pGroupNode);
                ICompositeLayer pCompositeLayer = pLayer as ICompositeLayer;
                for (int i = 0; i < pCompositeLayer.Count; i++)
                {
                    ILayer pcLayer = pCompositeLayer.Layer[i];
                    AddLayerToNode(pcLayer, pGroupNode);
                }
            }
            if (pLayer is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    //为点图层         
                    pGroupNode.Image = Properties.Resources.点图层;

                }
                if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    //为线图层
                    pGroupNode.Image = Properties.Resources.线图层;
                }


                if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                    //为面图层
                    pGroupNode.Image = Properties.Resources.面图层;
                }
            }
            if (pLayer is IRasterLayer)
            {
                pGroupNode.Image = Properties.Resources.图像图层;
            }
           
            pGroupNode.Tag = pLayer;
            GroupLayerComboTree.Nodes.Add(pGroupNode);

            GroupLayerComboTree.Refresh();
            GroupLayerComboTree.RecalcLayout();
        }

 

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