码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGis 中MapControl 框选

时间:2015-03-18 17:17:06      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:

void mCtrl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            #region 框选
            
            
            if (e.button == 4)
            {
                IEnvelope pEnvelope = mCtrl.TrackRectangle();  // 通过鼠标,取得一个包络线对象
                ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();  // 设置一个新环境
                pSelectionEnv.DefaultColor = MapHelper.GetRGBColor(Color.Red);     // 再改变原来要素的眼神值
                mCtrl.Map.SelectByShape(pEnvelope, pSelectionEnv, false);
                mCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                ISelection selection = mCtrl.Map.FeatureSelection;
                IEnumFeatureSetup enumFeatureSetup = selection as IEnumFeatureSetup;    //这里很必要
                enumFeatureSetup.AllFields = true;                                      //这里很必要
                IEnumFeature enumFeature = enumFeatureSetup as IEnumFeature;
                enumFeature.Reset();
                IFeature feature = enumFeature.Next();

                IFeatureLayer pFeatureLayer = (IFeatureLayer)mCtrl.get_Layer(currentLayerIndex);
                IFeatureClass pFeatureClass = (IFeatureClass)pFeatureLayer.FeatureClass;

                int fLCDIdx = pFeatureClass.FindField(fieldName);
                lbFields.Items.Clear();
                while (feature != null)
                {
                    var _lcd = feature.get_Value(fLCDIdx);
                    long lcd = Convert.ToInt64(_lcd);
                    lbFields.Items.Add(lcd);
                    feature = enumFeature.Next();
                }
            }
            


            #endregion

            mCtrl.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing, Type.Missing);
        }

ArcGis 中MapControl 框选

标签:

原文地址:http://www.cnblogs.com/94cool/p/4347430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!