IPoint ppoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);   
           IIdentify pIdentify = plyr as IIdentify;
           IEnvelope pEnv = ppoint.Envelope;
           IDisplayTransformation pDT = pActView.ScreenDisplay.DisplayTransformation;
           pEnv.Expand(pDT.VisibleBounds.Width / 100, pDT.VisibleBounds.Height / 100, false);
           IArray pArray = pIdentify.Identify(pEnv   as IGeometry);
           IIdentifyObj pIdentifyObj = pArray.get_Element(0) as IIdentifyObj;              
           pIdentifyObj.Flash(pActView.ScreenDisplay);

           TreeNode pNode = new TreeNode(plyr.Name);
           pFrm.treeView1.Nodes.Clear();
           pFrm.treeView1.Nodes.Add(pNode);
           pNode.Nodes.Add(pIdentifyObj.Name);
           pFrm.treeView1.ExpandAll();
           if (plyr is IRasterLayer)
           {
               int i = 0;
               IRasterIdentifyObj2 pRObj = pIdentifyObj as IRasterIdentifyObj2;
               string pField = "";
               string pValue = "";
               do
               {
                   pFrm.MxFelx.Rows = 2+i;                     
                   pRObj.GetPropAndValues(i, out pField, out pValue);
                   pFrm.MxFelx.set_TextMatrix(i + 1, 0, pField);
                   pFrm .MxFelx .set_TextMatrix (i+1,1,pValue ) ;                  
                   i++;
               }
               while (pField != "");         
              
           }
           else if (plyr is IFeatureLayer )
           {
               IRowIdentifyObject pRowObj = pIdentifyObj as IRowIdentifyObject;
               IRow pRow = pRowObj.Row;
               IFields pFields = pRow.Fields;

               pFrm.MxFelx.Rows = pFields.FieldCount + 1;
               for (int i = 0; i < pFields.FieldCount; i++)
               {
                   IField pField = pFields.get_Field(i);
                   pFrm.MxFelx.set_TextMatrix(i + 1, 0, pField.Name);
                   switch (pField.Type)
                   {
                       case esriFieldType.esriFieldTypeOID:
                           pFrm.MxFelx.set_TextMatrix(i + 1, 1, pRow.OID.ToString());
                           break;
                       case esriFieldType.esriFieldTypeGeometry:
                           pFrm.MxFelx.set_TextMatrix(i + 1, 1, QueryShapeType(pField.GeometryDef.GeometryType));
                           break;
                       default:
                           pFrm.MxFelx.set_TextMatrix(i + 1, 1, pRow.get_Value(i).ToString());
                           break;
                   }
               }

           }

posted on 2008-06-01 11:47  叶秋  阅读(917)  评论(0编辑  收藏  举报