Exemple #1
0
        /// <summary>
        /// 执行属性查询
        /// 尚未实现如何闪烁选中要素集合
        /// 以及进度条的显示
        /// </summary>
        /// <param name="searchLayers"></param>
        private void ExecuteIdentify(List <LayerFilterProperties> searchLayers, IGeometry identifyGeom)
        {
            object Missing = Type.Missing;

            //清空以前所有的查询结果先
            identifiedResultsList.Clear();
            //用于计算查询得到的要素的数量
            int identifiedObjCount = 0;
            //获取用于查询的图层的数量
            int searchLayersCount = searchLayers.Count;

            //初始化进度条
            IdentifyProgress.Visible = true;
            IdentifyProgress.Maximum = searchLayersCount;
            //初始化闪烁对象
            flashObjects.MapControl = associateMapControl.Object as IMapControl2;
            flashObjects.Init();
            //遍历所有图层
            for (int i = 0; i < searchLayersCount; i++)
            {
                LayerFilterProperties filterProps = searchLayers[i];
                ILayer layer = filterProps.TargetLayer;
                //新建查询结果列表对象
                LayerIdentifiedResult layerIdentifiedResult = new LayerIdentifiedResult();
                //先保存查询图层对象
                layerIdentifiedResult.IdentifyLayer = layer;
                layerIdentifiedResult.GeometryType  = filterProps.LayerFeatureType;
                //首先获得查询结果列表对象,以备后面往里添加结果使用
                List <IFeatureIdentifyObj> identifiedObjList = layerIdentifiedResult.IdentifiedFeatureObjList;
                //执行查询,返回查询结果
                IArray identifyResult = Identify(layer, identifyGeom);
                //处理异常情况
                if (identifyResult != null)
                {
                    //依次获取每一个查询结果对象
                    for (int k = 0; k < identifyResult.Count; k++)
                    {
                        identifiedObjCount++;
                        IFeatureIdentifyObj identifiedFeatureObj = identifyResult.get_Element(k) as IFeatureIdentifyObj;
                        //闪烁要素
                        IFeature identifiedFeature = (identifiedFeatureObj as IRowIdentifyObject).Row as IFeature;
                        //添加闪烁图形
                        flashObjects.AddGeometry(identifiedFeature.Shape);
                        //保存查询结果
                        identifiedObjList.Add(identifiedFeatureObj);
                    }
                    identifiedResultsList.Add(layerIdentifiedResult);
                }
                //显示查询进度
                IdentifyProgress.Value = i + 1;
                Application.DoEvents();
            }
            //隐藏进度条
            IdentifyProgress.Visible = false;
            //显示查询到的要素数量
            lblFeatureCount.Text = "查询到 " + identifiedObjCount + " 条记录";
        }
Exemple #2
0
        public void FlashObjects(LayerIdentifiedResult layerFlash)
        {
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
            switch (layerFlash.GeometryType)
            {
            case LayerFeatureType.Point:
                screenDisplay.SetSymbol(pointSymbol);
                break;

            case LayerFeatureType.Polyline:
                screenDisplay.SetSymbol(lineSymbol);
                break;

            case LayerFeatureType.Polygon:
                screenDisplay.SetSymbol(regionSymbol);
                break;

            default:
                return;
            }
            List <IFeatureIdentifyObj> identifyObjDefault = layerFlash.IdentifiedFeatureObjList;

            for (int i = 0; i < identifyObjDefault.Count; i++)
            {
                IFeature featureDefault = (identifyObjDefault[i] as IRowIdentifyObject).Row as IFeature;
                switch (layerFlash.GeometryType)
                {
                case LayerFeatureType.Point:
                    screenDisplay.DrawPoint(featureDefault.Shape);
                    break;

                case LayerFeatureType.Polyline:
                    screenDisplay.DrawPolyline(featureDefault.Shape);
                    break;

                case LayerFeatureType.Polygon:
                    screenDisplay.DrawPolygon(featureDefault.Shape);
                    break;
                }
            }
            Thread.Sleep(500);
            screenDisplay.FinishDrawing();
            mapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
        }
Exemple #3
0
        /// <summary>
        /// 在右侧表格中显示查询结果
        /// </summary>
        private void DisplayIdentifyResults()
        {
            //清空以前所有显示结果
            trvDataList.Nodes.Clear();
            //初始化属性显示窗口数据
            lstProperties.Items.Clear();
            lstProperties.Columns.Clear();
            //声明变量
            List <IFeatureIdentifyObj> IdentifyObjs = null;
            IFeatureIdentifyObj        IdentifyObj  = null;
            //列出查询结果
            int resultsCount = identifiedResultsList.Count;

            for (int i = 0; i < resultsCount; i++)
            {
                LayerIdentifiedResult layerIdentifiedResult = identifiedResultsList[i];
                //添加图层节点
                TreeNode layerNode = trvDataList.Nodes.Add(layerIdentifiedResult.IdentifyLayer.Name);
                //添加要素节点
                IdentifyObjs = layerIdentifiedResult.IdentifiedFeatureObjList;
                for (int k = 0; k < IdentifyObjs.Count; k++)
                {
                    IdentifyObj = IdentifyObjs[k];
                    IRowIdentifyObject rowIdentifyObj  = IdentifyObj as IRowIdentifyObject;
                    IFeature           identifyFeature = rowIdentifyObj.Row as IFeature;
                    layerNode.Nodes.Add(identifyFeature.OID.ToString());
                }
            }
            //展开所有节点
            trvDataList.ExpandAll();
            //默认显示第一图层的第一个查询要素
            if (trvDataList.Nodes.Count < 1)
            {
                ShowClickedNodeInfo(null, false);
            }
            //显示第一图层的第一个查询要素
            else
            {
                TreeNode topNode = trvDataList.Nodes[0].Nodes[0];
                //显示第一节点
                trvDataList.TopNode = topNode.Parent;
                ShowClickedNodeInfo(topNode, false);
            }
        }
Exemple #4
0
        /// <summary>
        /// 显示节点的信息
        /// </summary>
        /// <param name="node"></param>
        private void ShowClickedNodeInfo(TreeNode nodeClicked, bool doFlash)
        {
            if (nodeClicked == null)
            {
                //初始化树型显示窗口
                InitializeAttributesList();
                return;
            }
            //获取点击点对应的要素
            int nodeLevel = nodeClicked.Level;
            //获取点击的是图层还是图层下的要素
            //若featureIndex < 0则表示点击的是图层,闪烁图层下选中的所有要素
            //反之,则表示点击的是图层下的要素,获取图层索引和要素索引,
            //用于在结果列表中安索引获取要素或要素集属性
            int layerIndex = -1;    int featureIndex = -1;

            if (nodeLevel > 0)
            {
                TreeNode parentNode = nodeClicked.Parent;
                layerIndex   = parentNode.Index;
                featureIndex = nodeClicked.Index;
            }
            else
            {
                layerIndex = nodeClicked.Index;
            }
            //获取对应要素
            LayerIdentifiedResult layerResult = identifiedResultsList[layerIndex];

            //点击了图层下的要素
            if (featureIndex > -1)
            {
                IFeatureIdentifyObj identifyObjDefault = layerResult.IdentifiedFeatureObjList[featureIndex];
                IFeature            featureDefault     = (identifyObjDefault as IRowIdentifyObject).Row as IFeature;
                //显示属性
                ShowFeatureAttributes(featureDefault);
                //判断是否闪烁要素

                if (doFlash)
                {
                    HookHelperClass hookHelper = new HookHelperClass();
                    hookHelper.Hook = MainForm.Instance.AxMapCtrl.Object;

                    IHookActions hookAction = (IHookActions)hookHelper;
                    hookAction.DoAction(featureDefault.Shape, esriHookActions.esriHookActionsPan);
                    Application.DoEvents();
                    hookAction.DoAction(featureDefault.Shape, esriHookActions.esriHookActionsFlash);
                    //IIdentifyObj identifyObj = identifyObjDefault as IIdentifyObj;
                    //if (identifyObj != null)
                    //{
                    //    // identifyObj.Flash(associateMapControl.ActiveView.ScreenDisplay);
                    //    // identifyObj.Flash(MapUtils.GetActiveView().ScreenDisplay);
                    //}
                }
            }
            //点击了图层,同时闪烁图层下的所有要素图形
            else
            {
                flashObjects.FlashObjects(layerResult);
            }
        }