コード例 #1
0
        private void ShowAttribute(IGeometry geometry)
        {
            if (FeatureLayer != null)
            {
                IArray array = AttributeExtensions.Identity(FeatureLayer.FeatureClass, geometry, WhereClause);
                if (array != null)
                {
                    IFeatureIdentifyObj featureIdentifyObj = array.get_Element(0) as IFeatureIdentifyObj;
                    IIdentifyObj        identifyObj        = featureIdentifyObj as IIdentifyObj;
                    IRowIdentifyObject  rowIdentifyObj     = featureIdentifyObj as IRowIdentifyObject;
                    IFeature            feature            = rowIdentifyObj.Row as IFeature;
                    if (feature != null)
                    {
                        _father.dataGridView1.DataSource = GetAttribute(feature);
                        //_father.ExportExcelbutton.Enabled = true;
                        var tbbh  = _featureValues.FirstOrDefault(e => e.Name == "TBBH");
                        var xzcdm = _featureValues.FirstOrDefault(e => e.Name == "XZCDM");
                        _father.Search(xzcdm.Value, tbbh.Value);

                        Application.DoEvents();

                        Twinkle(feature);
                    }
                    else
                    {
                        //_father.ExportExcelbutton.Enabled = false;
                    }
                }
            }
        }
コード例 #2
0
 private void FlashCommand(object sender, RoutedEventArgs e)
 {
     LogLog.Instance.Logger[LogLogEnum.Debug]("TableSearch:FlashCommand");
     try {
         IActiveView  av    = ArcMap.Document.ActiveView as IActiveView;
         FeatureModel aFeat = dataGrid1.SelectedItem as FeatureModel;
         av.ScreenDisplay.UpdateWindow();
         IFeatureIdentifyObj featIdentify = new FeatureIdentifyObject();
         featIdentify.Feature = aFeat.Feature;
         IIdentifyObj identify = featIdentify as IIdentifyObj;
         identify.Flash(av.ScreenDisplay);
     } catch (Exception ex) {
         LogLog.Instance.Logger[LogLogEnum.Error](ex.Message);
     }
 }
コード例 #3
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            int            X      = arg.X;
            int            Y      = arg.Y;
            IMxApplication pMxApp = null;
            IMxDocument    pMxDoc = null;

            pMxApp = (IMxApplication)ArcMap.Application;
            pMxDoc = (IMxDocument)ArcMap.Application.Document;

            // calculate tolerance rectangle to identify features inside it
            int Tolerance = 0;

            Tolerance = pMxDoc.SearchTolerancePixels;

            IDisplayTransformation pDispTrans = null;

            pDispTrans = pMxApp.Display.DisplayTransformation;
            tagRECT pToleranceRect = new tagRECT();

            pToleranceRect.left   = X - Tolerance;
            pToleranceRect.right  = X + Tolerance;
            pToleranceRect.top    = Y - Tolerance;
            pToleranceRect.bottom = Y + Tolerance;

            IEnvelope pSearchEnvelope = null;

            pSearchEnvelope = new EnvelopeClass();
            pDispTrans.TransformRect(pSearchEnvelope, ref pToleranceRect, (int)(esriDisplayTransformationEnum.esriTransformPosition | esriDisplayTransformationEnum.esriTransformToMap));

            // identify feature points of measurement
            IBasicDocument pBasicDoc = null;

            pBasicDoc = (IBasicDocument)ArcMap.Application.Document;
            pSearchEnvelope.SpatialReference = pMxDoc.ActiveView.FocusMap.SpatialReference;

            IIdentify pIdentify = null;

            pIdentify = (IIdentify)pMxDoc.FocusMap.get_Layer(0);
            if (pIdentify == null)
            {
                MessageBox.Show("No layer");
                return;
            }

            IArray pIDArray = null;

            pIDArray = pIdentify.Identify(pSearchEnvelope);

            // get object from feature point
            IIdentifyObj pIDObj = null;

            if (pIDArray != null)
            {
                pIDObj = (IIdentifyObj)pIDArray.get_Element(0);
            }

            if (pIDObj == null)
            {
                MessageBox.Show("No feature was identified");
                return;
            }

            // get the name of the layer containing feature points
            ILayer pLayer = null;

            pLayer = pMxDoc.FocusMap.get_Layer(0);

            string layerName = null;

            layerName = pLayer.Name;

            // get primary display field for measurement values and set names of a date/time field and gage ID field
            IFeatureLayer pFeatLayer = null;

            pFeatLayer = (IFeatureLayer)pLayer;
            string dataFldName   = null;
            string timefldName   = null;
            string gageIDFldName = null;

            dataFldName   = "TSValue";
            timefldName   = "TSDateTime"; // substitute data/time field name for different dataset
            gageIDFldName = "Name";       // substitute gage ID field name for different dataset

            // get display table from layer
            ITable        pTable        = null;
            IDisplayTable pDisplayTable = null;

            pDisplayTable = (IDisplayTable)pLayer;
            if (pDisplayTable != null)
            {
                pTable = pDisplayTable.DisplayTable;
                if (pTable == null)
                {
                    goto THEEND;
                }
            }

            // get fields from display table
            IFields pFields = null;

            pFields = pTable.Fields;
            long fldCount = 0;

            fldCount = pFields.FieldCount;

            // create WHERE clause from identified objects of measurement points
            int gageIDFldIdx = 0;

            gageIDFldIdx = pFields.FindField(gageIDFldName);

            IRowIdentifyObject pRowIDObj = null;

            pRowIDObj = (IRowIdentifyObject)pIDObj;

            string gageID = null;

            gageID = (string)pRowIDObj.Row.get_Value(gageIDFldIdx);

            IFeatureLayerDefinition pFeatureLayerDef = null;

            pFeatureLayerDef = (IFeatureLayerDefinition)pLayer;
            string definitionExpression = null;

            definitionExpression = pFeatureLayerDef.DefinitionExpression;

            string whereClause = null;

            if (definitionExpression == "")
            {
                whereClause = "[" + gageIDFldName + "] = '" + gageID + "'";
            }
            else
            {
                whereClause = "[" + gageIDFldName + "] = '" + gageID + "' AND " + definitionExpression;
            }

            //find color for the identified object from feature layer's renderer
            IGeoFeatureLayer pGeoFeatureLayer = null;

            pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

            ILookupSymbol pLookupSymbol = null;

            pLookupSymbol = (ILookupSymbol)pGeoFeatureLayer.Renderer;

            IFeature pFeature = null;

            pFeature = (IFeature)pRowIDObj.Row;

            IMarkerSymbol pSymbol = null;

            pSymbol = (IMarkerSymbol)pLookupSymbol.LookupSymbol(false, pFeature);

            // Find an opened GraphWindow
            IDataGraphBase    pDataGraphBase = null;
            IDataGraphT       pDataGraphT    = null;
            IDataGraphWindow2 pDGWin         = null;

            IDataGraphCollection pDataGraphs = null;

            pDataGraphs = (IDataGraphCollection)pMxDoc;
            int grfCount = 0;

            grfCount = pDataGraphs.DataGraphCount;
            for (int i = 0; i < grfCount; i++)
            {
                pDataGraphBase = pDataGraphs.get_DataGraph(i);
                pDGWin         = FindGraphWindow(ref pDataGraphBase);
                if (pDGWin != null)
                {
                    break;
                }
            }

            // if there is not an opened graph window - create a new graph for
            if (pDGWin == null)
            {
                // create graph
                pDataGraphT    = new DataGraphTClass();
                pDataGraphBase = (IDataGraphBase)pDataGraphT;

                // load template from <ARCGISHOME>\GraphTemplates\
                string strPath = null;
                strPath = Environment.GetEnvironmentVariable("ARCGISHOME");
                try
                {
                    pDataGraphT.LoadTemplate(strPath + @"GraphTemplates\timeseries.tee");
                }
                catch
                { }

                // graph, axis and legend titles. Substitute them for different input layer
                pDataGraphT.GeneralProperties.Title           = "Daily Streamflow for Guadalupe Basin in 1999";
                pDataGraphT.LegendProperties.Title            = "Monitoring Point";
                pDataGraphT.get_AxisProperties(0).Title       = "Streamflow (cfs)";
                pDataGraphT.get_AxisProperties(0).Logarithmic = true;
                pDataGraphT.get_AxisProperties(2).Title       = "Date";
                pDataGraphBase.Name = layerName;
            }
            else // get graph from the opened window
            {
                pDataGraphT = (IDataGraphT)pDataGraphBase;
            }

            // create vertical line series for all measurements for the identified gage
            ISeriesProperties pSP = null;

            pSP             = pDataGraphT.AddSeries("line:vertical");
            pSP.ColorType   = esriGraphColorType.esriGraphColorCustomAll;
            pSP.CustomColor = pSymbol.Color.RGB;
            pSP.WhereClause = whereClause;
            pSP.InLegend    = true;
            pSP.Name        = gageID;

            pSP.SourceData = pLayer;
            pSP.SetField(0, timefldName);
            pSP.SetField(1, dataFldName);
            IDataSortSeriesProperties pSortFlds = null;

            pSortFlds = (IDataSortSeriesProperties)pSP;
            int idx = 0;

            pSortFlds.AddSortingField(timefldName, true, ref idx);


            pDataGraphBase.UseSelectedSet = true;

            ITrackCancel pCancelTracker = null;

            pCancelTracker = new CancelTracker();
            pDataGraphT.Update(pCancelTracker);

            // create data graph window if there is not any opened one
            if (pDGWin == null)
            {
                pDGWin = new DataGraphWindowClass();
                pDGWin.DataGraphBase = pDataGraphBase;
                pDGWin.Application   = ArcMap.Application;
                pDGWin.Show(true);

                pDataGraphs.AddDataGraph(pDataGraphBase);
            }

THEEND:
            return;

            //base.OnMouseDown(arg);
        }
コード例 #4
0
 private void objTree_AfterSelect(object sender, TreeViewEventArgs e)
 {
     try
     {
         if ((this.objTree.SelectedNode != null) && (this.objTree.SelectedNode.Tag != null))
         {
             IActiveView view;
             object      tag = null;
             tag = this.objTree.SelectedNode.Tag;
             if (tag is IIdentifyObj)
             {
                 IIdentifyObj obj3 = tag as IIdentifyObj;
                 this.Infolist.Visible = true;
                 if (obj3 is IFeatureIdentifyObj)
                 {
                     this.ifeature_0 = (obj3 as IRowIdentifyObject).Row as IFeature;
                     view            = (IActiveView)this.ibasicMap_0;
                     this.method_6(obj3.Layer as IFeatureLayer, this.ifeature_0);
                     obj3.Flash(view.ScreenDisplay);
                 }
                 else
                 {
                     int          num;
                     string[]     strArray;
                     string       str;
                     string       str2;
                     ListViewItem item;
                     if (obj3 is IRasterIdentifyObj2)
                     {
                         this.panel5.AutoSize = true;
                         this.Infolist.Items.Clear();
                         num      = 0;
                         strArray = new string[2];
                         while (true)
                         {
                             try
                             {
                                 (obj3 as IRasterIdentifyObj2).GetPropAndValues(num, out str, out str2);
                                 if (str == null)
                                 {
                                     break;
                                 }
                                 strArray[0] = str;
                                 strArray[1] = str2;
                                 item        = new ListViewItem(strArray);
                                 this.Infolist.Items.Add(item);
                                 num++;
                             }
                             catch
                             {
                                 break;
                             }
                         }
                         view = (IActiveView)this.ibasicMap_0;
                         obj3.Flash(view.ScreenDisplay);
                     }
                     else
                     {
                         Exception exception;
                         if (obj3 is ITinIdentifyObj2)
                         {
                             this.panel5.AutoSize = true;
                             this.Infolist.Items.Clear();
                             num      = 0;
                             strArray = new string[2];
                             while (true)
                             {
                                 try
                                 {
                                     (obj3 as ITinIdentifyObj2).SetupEntity();
                                     (obj3 as ITinIdentifyObj2).GetPropAndValues(num, out str, out str2);
                                     if (str == null)
                                     {
                                         break;
                                     }
                                     strArray[0] = str;
                                     strArray[1] = str2;
                                     item        = new ListViewItem(strArray);
                                     this.Infolist.Items.Add(item);
                                     num++;
                                 }
                                 catch (Exception exception1)
                                 {
                                     exception = exception1;
                                     string message = exception.Message;
                                     break;
                                 }
                             }
                             view = (IActiveView)this.ibasicMap_0;
                             obj3.Flash(view.ScreenDisplay);
                         }
                         else if (obj3 is ICadIdentifyObj2)
                         {
                             this.panel5.AutoSize = true;
                             this.Infolist.Items.Clear();
                             num      = 0;
                             strArray = new string[2];
                             while (true)
                             {
                                 try
                                 {
                                     (obj3 as ICadIdentifyObj2).SetupEntity();
                                     (obj3 as ICadIdentifyObj2).GetPropAndValues(num, out str, out str2);
                                     if (str == null)
                                     {
                                         break;
                                     }
                                     strArray[0] = str;
                                     strArray[1] = str2;
                                     item        = new ListViewItem(strArray);
                                     this.Infolist.Items.Add(item);
                                     num++;
                                 }
                                 catch (Exception exception2)
                                 {
                                     exception = exception2;
                                     string text2 = exception.Message;
                                     break;
                                 }
                             }
                             view = (IActiveView)this.ibasicMap_0;
                             obj3.Flash(view.ScreenDisplay);
                         }
                         else if (obj3 is IIdentifyObject)
                         {
                             object obj4;
                             object obj5;
                             this.panel5.AutoSize = true;
                             (obj3 as IIdentifyObject).PropertySet.GetAllProperties(out obj4, out obj5);
                             this.Infolist.Items.Clear();
                             strArray = new string[2];
                             System.Array array  = obj4 as Array;
                             System.Array array2 = obj5 as Array;
                             for (int i = 0; i < array.Length; i++)
                             {
                                 strArray[0] = array.GetValue(i).ToString();
                                 strArray[1] = array2.GetValue(i).ToString();
                                 item        = new ListViewItem(strArray);
                                 this.Infolist.Items.Add(item);
                             }
                             view = (IActiveView)this.ibasicMap_0;
                             obj3.Flash(view.ScreenDisplay);
                         }
                     }
                 }
             }
             else if (tag is IFeature)
             {
                 this.Infolist.Visible = true;
                 this.ifeature_0       = tag as IFeature;
                 view = (IActiveView)this.ibasicMap_0;
                 this.method_5(this.ifeature_0);
                 Flash.FlashFeature(view.ScreenDisplay, this.ifeature_0);
             }
             else
             {
                 this.Infolist.Visible = false;
             }
         }
     }
     catch
     {
     }
 }
コード例 #5
0
        private void method_0()
        {
            this.objTree.Nodes.Clear();
            this.Infolist.Items.Clear();
            object       layer = null;
            TreeNode     node  = null;
            TreeNode     node2 = null;
            IIdentifyObj obj3  = null;
            object       obj4  = null;

            if (this.iarray_0 != null)
            {
                for (int i = 0; i < this.iarray_0.Count; i++)
                {
                    TreeNode node3;
                    obj4 = this.iarray_0.get_Element(i);
                    if (obj4 is IIdentifyObj)
                    {
                        obj3 = obj4 as IIdentifyObj;
                        if ((this.identifyTypeEnum_0 != IdentifyTypeEnum.enumITCurrentLayer) ||
                            (obj3.Layer == this.ilayer_0))
                        {
                            if (obj3 is IFeatureIdentifyObj)
                            {
                                IRow row = (obj3 as IRowIdentifyObject).Row;
                                if (layer != obj3.Layer)
                                {
                                    layer = obj3.Layer;
                                    node  = new TreeNode(obj3.Layer.Name);
                                    this.objTree.Nodes.Add(node);
                                    node.Tag = obj3.Layer;
                                    node.ExpandAll();
                                }
                                if (row.HasOID)
                                {
                                    node3 = new TreeNode(row.OID.ToString());
                                }
                                else
                                {
                                    node3 = new TreeNode(row.get_Value(0).ToString());
                                }
                                node3.Tag = obj3;
                                if (node2 == null)
                                {
                                    node2 = node3;
                                }
                                this.method_3(row as IFeature, node3);
                                if (obj3.Layer is IRelationshipClassCollection)
                                {
                                    this.method_1((obj3.Layer as IRelationshipClassCollection).RelationshipClasses,
                                                  row as IObject, node3, false);
                                }
                                node.Nodes.Add(node3);
                            }
                            else if ((obj3 is IRasterIdentifyObj) || (obj3 is ITinIdentifyObj))
                            {
                                layer = null;
                                node  = new TreeNode(obj3.Layer.Name);
                                this.objTree.Nodes.Add(node);
                                node.Tag = obj3.Layer;
                                node.ExpandAll();
                                node3 = new TreeNode(obj3.Name)
                                {
                                    Tag = obj3
                                };
                                if (node2 == null)
                                {
                                    node2 = node3;
                                }
                                node.Nodes.Add(node3);
                            }
                            else
                            {
                                layer = null;
                                node  = new TreeNode(obj3.Layer.Name);
                                this.objTree.Nodes.Add(node);
                                node.Tag = obj3.Layer;
                                node.ExpandAll();
                                node3 = new TreeNode(obj3.Name)
                                {
                                    Tag = obj3
                                };
                                if (node2 == null)
                                {
                                    node2 = node3;
                                }
                                node.Nodes.Add(node3);
                            }
                        }
                    }
                    else
                    {
                        IFeature feature;
                        if (obj4 is IFeatureFindData2)
                        {
                            feature = (obj4 as IFeatureFindData2).Feature;
                            node    = new TreeNode(feature.Class.AliasName);
                            this.objTree.Nodes.Add(node);
                            node.Tag = feature.Class;
                            node.ExpandAll();
                            node3 = new TreeNode(feature.OID.ToString())
                            {
                                Tag = feature
                            };
                            if (node2 == null)
                            {
                                node2 = node3;
                            }
                            node.Nodes.Add(node3);
                            this.method_6((obj4 as IFeatureFindData2).Layer as IFeatureLayer, feature);
                        }
                        else if (obj4 is IHit3D)
                        {
                            IHit3D hitd = obj4 as IHit3D;
                            if (hitd.Object is IFeature)
                            {
                                feature = hitd.Object as IFeature;
                                node    = new TreeNode(feature.Class.AliasName);
                                this.objTree.Nodes.Add(node);
                                node.Tag = feature.Class;
                                node.ExpandAll();
                                node3 = new TreeNode(feature.OID.ToString())
                                {
                                    Tag = feature
                                };
                                if (node2 == null)
                                {
                                    node2 = node3;
                                }
                                node.Nodes.Add(node3);
                                this.method_5(feature);
                            }
                            else if (hitd.Owner is ITinIdentifyObj)
                            {
                                layer = null;
                            }
                        }
                    }
                }
                this.objTree.SelectedNode = node2;
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArcmapPickCandidate"/> class.
 /// </summary>
 /// <param name="identifyOby">Identified object.</param>
 /// <param name="distance">Distance from the identified object to the mouse click.</param>
 public ArcmapPickCandidate(IIdentifyObj identifyOby, double distance)
 {
     IdentifyObj          = identifyOby;
     DistanceToClickPoint = distance;
     GeometryType         = ArcmapUtils.DetectGeometryBaseType(Feature.Shape);
 }
コード例 #7
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     if (Button == 1)
     {
         List <ILayer> layers = EngineAPI.GetLayers(this.m_hookHelper.FocusMap, "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}", null);
         if (layers.Count == 0)
         {
             IdentifyManager.instance.FrmIdentify.Close();
             IdentifyManager.instance.FrmIdentify      = null;
             EnviVars.instance.MapControl.CurrentTool  = null;
             EnviVars.instance.MapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
         }
         else
         {
             foreach (ILayer current in layers)
             {
                 IIdentify identify = current as IIdentify;
                 IPoint    point    = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                 IArray    array    = identify.Identify(point);
                 if (array != null && array.Count != 0)
                 {
                     IdentifyManager.instance.FrmIdentify.treeList1.ClearNodes();
                     IIdentifyObj identifyObj = array.get_Element(0) as IIdentifyObj;
                     identifyObj.Flash(this.m_hookHelper.ActiveView.ScreenDisplay);
                     TreeListNode treeListNode = IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                     {
                         identifyObj.Layer.Name
                     }, 0, identifyObj);
                     DataColumn column    = new DataColumn("字段", typeof(string));
                     DataColumn column2   = new DataColumn("值", typeof(string));
                     DataTable  dataTable = new DataTable();
                     dataTable.Columns.Add(column);
                     dataTable.Columns.Add(column2);
                     if (current is IFeatureLayer)
                     {
                         IFeature     feature       = (identifyObj as IRowIdentifyObject).Row as IFeature;
                         TreeListNode treeListNode2 = IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                         {
                             feature.OID.ToString()
                         }, treeListNode);
                         int num = feature.Fields.FindField((current as IFeatureLayer).FeatureClass.ShapeFieldName);
                         for (int i = 0; i < feature.Fields.FieldCount; i++)
                         {
                             if (num != i)
                             {
                                 DataRow dataRow = dataTable.NewRow();
                                 dataRow["字段"] = feature.Fields.get_Field(i).AliasName;
                                 dataRow["值"]  = feature.get_Value(i).ToString();
                                 dataTable.Rows.Add(dataRow);
                             }
                         }
                         treeListNode2.Tag = dataTable;
                     }
                     else if (current is IRasterLayer)
                     {
                         IRasterLayer rasterLayer = current as IRasterLayer;
                         IRaster2     raster      = rasterLayer.Raster as IRaster2;
                         int          num2        = raster.ToPixelRow(point.Y);
                         int          num3        = raster.ToPixelColumn(point.X);
                         double       num4        = CommonAPI.ConvertToDouble(raster.GetPixelValue(0, num3, num2));
                         this.AddRow(dataTable, "像素值", num4);
                         this.AddRow(dataTable, "行号", num2);
                         this.AddRow(dataTable, "列号", num3);
                         IRasterIdentifyObj rasterIdentifyObj = array.get_Element(0) as IRasterIdentifyObj;
                         if (rasterLayer.BandCount != 1)
                         {
                             Regex           regex           = new Regex("\\d{2,3}");
                             MatchCollection matchCollection = regex.Matches(rasterIdentifyObj.MapTip);
                             if (matchCollection.Count == 3)
                             {
                                 this.AddRow(dataTable, "R", matchCollection[0].Value);
                                 this.AddRow(dataTable, "G", matchCollection[1].Value);
                                 this.AddRow(dataTable, "B", matchCollection[2].Value);
                             }
                         }
                         IdentifyManager.instance.FrmIdentify.treeList1.AppendNode(new object[]
                         {
                             rasterIdentifyObj.Name
                         }, treeListNode, dataTable);
                     }
                     IdentifyManager.instance.FrmIdentify.UpdateStatusText(string.Format("X:{0:0.000 },Y:{1:0.000}", point.X, point.Y));
                     IdentifyManager.instance.FrmIdentify.treeList1.ExpandAll();
                     if (treeListNode.Nodes.Count > 0)
                     {
                         IdentifyManager.instance.FrmIdentify.treeList1.FocusedNode = treeListNode.Nodes[0];
                     }
                     IdentifyManager.instance.FrmIdentify.Show();
                     break;
                 }
                 IdentifyManager.instance.FrmIdentify.Close();
                 IdentifyManager.instance.FrmIdentify = null;
             }
         }
     }
 }