zoukankan      html  css  js  c++  java
  • ArcGis 中MapControl 框选

    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);
            }
  • 相关阅读:
    cnblog项目--20190309
    django js引入失效问题
    Python老男孩 day16 函数(六) 匿名函数
    Python老男孩 day16 函数(五) 函数的作用域
    Python老男孩 day15 函数(四) 递归
    Python老男孩 day15 函数(三) 前向引用之'函数即变量'
    Python老男孩 day15 函数(二) 局部变量与全局变量
    Python老男孩 day14 函数(一)
    Python老男孩 day14 字符串格式化
    Python老男孩 day14 集合
  • 原文地址:https://www.cnblogs.com/94cool/p/4347430.html
Copyright © 2011-2022 走看看