1 private void HandleIdentify_MouseDown(object sender, ISceneControlEvents_OnMouseDownEvent e) 2 { 3 this.PipeSceneControl.Scene.ClearSelection();//清除之前的选择集,去除高亮显示 4 IHit3DSet pHit3DSet = null; 5 this.PipeSceneControl.SceneGraph.LocateMultiple(this.PipeSceneControl.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickAll, false, out pHit3DSet); 6 pHit3DSet.OnePerLayer(); 7 if (pHit3DSet.Hits.Count == 0) 8 { 9 MessageBox.Show("没有选中任何要素!"); 10 return; 11 } 12 IHit3D pHit3D = pHit3DSet.Hits.get_Element(0) as IHit3D; 13 IFeature pFeature = pHit3D.Object as IFeature;//pHit3D.Owner其实是一个ILayer类型,pHit3D.Object是一个IFeature类型 14 IFields pFields = pFeature.Fields; 15 StringBuilder Info = new StringBuilder(); 16 for (int i = 0; i < pFields.FieldCount;i++ ) 17 { 18 IField pField = pFields.get_Field(i); 19 if (pField.Type != esriFieldType.esriFieldTypeGeometry) 20 { 21 Info.Append(pField.Name + ":" + pFeature.get_Value(pFields.FindField(pField.Name)) + "\n"); 22 } 23 } 24 MessageBox.Show(Info.ToString()); 25 IDisplay3D pDisplay3D = this.PipeSceneControl.SceneGraph as IDisplay3D; 26 pDisplay3D.FlashGeometry(pHit3D.Owner, pHit3D.Object);//闪烁一次,pHit3D.Owner是一个ILayer类型,pHit3D.Object是一个IFeature类型 27 //pDisplay3D.AddFlashFeature(pFeature.Shape);//保持高亮 28 this.PipeSceneControl.Scene.SelectFeature(pHit3D.Owner as ILayer, pFeature);//加入选择集,并自动高亮 29 }
文章来源:http://blog.csdn.net/iispring/article/details/7284077