www.pudn.com > MyVR.rar > QueryInfomation.cs, change:2008-06-05,size:3515b


´╗┐using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using ESRI.ArcGIS.esriSystem; 
using ESRI.ArcGIS.SystemUI; 
using ESRI.ArcGIS.Geometry; 
using ESRI.ArcGIS.Display; 
using ESRI.ArcGIS.Geodatabase; 
using ESRI.ArcGIS.Carto; 
using ESRI.ArcGIS.Controls; 
using ESRI.ArcGIS.Analyst3D; 
 
namespace MyVR 
{ 
    public partial class QueryInfomation : Form 
    { 
        public ISceneControl pSceneControl; 
        public IEnvelope pEnvelop; 
        public QueryInfomation() 
        { 
            InitializeComponent(); 
        } 
 
        public QueryInfomation(ISceneControl pSC, IEnvelope pFEnvelop) 
        { 
            InitializeComponent(); 
            pSceneControl = pSC; 
            pEnvelop = pFEnvelop; 
        } 
 
        public void SelectPropertyViaFeature() 
        { 
            trViewProperty.Nodes.Clear(); 
            for (int i = 0; i < pSceneControl.Scene.LayerCount; i++) 
            { 
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pSceneControl.Scene.get_Layer(i); 
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; 
 
                ISpatialFilter pSpatialFilter = new SpatialFilterClass(); 
                pSpatialFilter.Geometry = pEnvelop; 
                pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName; 
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; 
 
                IFields pFields = pFeatureClass.Fields; 
                IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false); 
 
                TreeNode nodeParent; 
                IFeature pFeature; 
                pFeature = pFeatureCursor.NextFeature(); 
                if (pFeature != null) 
                { 
                    nodeParent = trViewProperty.Nodes.Add(pFeatureLayer.Name.ToString()); 
                    while (pFeature != null) 
                    { 
                        TreeNode nodeSon; 
                        for (int j = 0; j < pFields.FieldCount; j++) 
                        { 
                            string fldValue; 
                            string fldName; 
                            fldName = pFields.get_Field(j).Name; 
                            if (fldName == "Shape") 
                            { 
                                fldValue = Convert.ToString(pFeature.Shape.GeometryType); 
                            } 
                            else 
                                fldValue = Convert.ToString(pFeature.get_Value(j)); 
 
 
                            //if (j == 0) 
                            //{ 
                            nodeSon = nodeParent.Nodes.Add(fldValue); 
                            //} 
                            //else 
                            //    nodeSon.Nodes.Add(fldValue); 
                        } 
                        pSceneControl.Scene.SelectFeature(pFeatureLayer, pFeature); 
                        pFeature = pFeatureCursor.NextFeature(); 
 
                    } 
                } 
 
 
            } 
            IActiveView pActiveView; 
            pActiveView = (IActiveView)pSceneControl.Scene; 
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); 
        } 
        private void QueryInfomation_Load(object sender, EventArgs e) 
        { 
            SelectPropertyViaFeature(); 
        } 
    } 
}