Пример #1
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);
 }
Пример #2
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 = pAxMapControl.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 + " 条记录";
 }