AE基本操作

2019-04-19  本文已影响0人  吵吵人

右键移除图层

        //~内容视图~
        ILayer seletedLayer_TOC = null;
        private void 移除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            axMapControl1.Map.DeleteLayer(seletedLayer_TOC);
            axMapControl1.ActiveView.Refresh();
        }

        private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
        {
            if(e.button==2)
            {

                IBasicMap map = null;
                ILayer layer = null;
                Object other = null;
                Object index = null;
                esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                if(item==esriTOCControlItem.esriTOCControlItemLayer)
                {
                    seletedLayer_TOC = layer;
                    this.contextMenuStrip_delete.Show(axTOCControl1, e.x, e.y);
                }
            }
            
        }

将结果添加至图层

        // 是否将最后的结果加载至地图
        DialogResult dr = MessageBox.Show("是否将结果添加至地图?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        if (dr == DialogResult.Yes)
        {

            IRasterLayer pRasterLayer;
            pRasterLayer = new RasterLayer();
            pRasterLayer.CreateFromRaster(raster);           
            ILayer pLayer = pRasterLayer as ILayer;
            axMapControl1.AddLayer(pLayer, 0);
            axMapControl1.ActiveView.Refresh();
        }
上一篇 下一篇

猜你喜欢

热点阅读