C#学习笔记二:ArcGIS Engine关闭所有图层

方法一

        private void 所有图层不可见ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ICompositeLayer pCompositeLayer;
            for (int i = 0; i < axMapControl.LayerCount; i++)  //遍历所有图层
            {
                if (axMapControl.get_Layer(i) is ICompositeLayer)
                {
                    pCompositeLayer = axMapControl.get_Layer(i) as ICompositeLayer;
                    UnVisibleTogetlayer(pCompositeLayer);
                }
            }
            axTOCControl1.Update();
            axMapControl.Refresh();
        }
        //递归遍历所有要素集
        private void UnVisibleTogetlayer(ICompositeLayer pCompositeLayer)
        {
            ICompositeLayer icolayer;
            ICompositeLayer pcomLayer = pCompositeLayer;
            ILayer layer = null;
            for (int i = 0; i < pcomLayer.Count; i++)
            {
                if (pcomLayer.get_Layer(i) is ICompositeLayer)
                {
                    icolayer = pcomLayer.get_Layer(i) as ICompositeLayer;
                    UnVisibleTogetlayer(icolayer);
                }

                layer = pcomLayer.get_Layer(i);
                layer.Visible = false;
            }

        }

方法二

        private void 所有图层不可见ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ICompositeLayer pCompositeLayer;
            ILayer mCompositeLayer;
            for (int i = 0; i < axMapControl.LayerCount; i++)  //遍历所有图层
            {
                if (axMapControl.get_Layer(i) is ICompositeLayer)
                {
                    pCompositeLayer = axMapControl.get_Layer(i) as ICompositeLayer;
                    for (int j = 0; j < pCompositeLayer.Count; j++)
                    {
                        mCompositeLayer = pCompositeLayer.get_Layer(j);
                        mCompositeLayer.Visible = false;
                    }
                }
            }
            axTOCControl1.Update();
            axMapControl.Refresh();
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值