Example #1
0
        public static IPoint XYToPoint2(ISceneGraph isceneGraph_0, int int_0, int int_1, esriScenePickMode esriScenePickMode_0)
        {
            IPoint       result       = null;
            ISceneViewer activeViewer = isceneGraph_0.ActiveViewer;
            IHit3DSet    hit3DSet;

            isceneGraph_0.LocateMultiple(activeViewer, int_0, int_1, esriScenePickMode_0, true, out hit3DSet);
            if (hit3DSet != null)
            {
                hit3DSet.OnePerLayer();
                IArray hits = hit3DSet.Hits;
                for (int i = 0; i <= hits.Count - 1; i++)
                {
                    IHit3D hit3D = hits.get_Element(i) as IHit3D;
                    result = hit3D.Point;
                }
            }
            return(result);
        }
Example #2
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;
            }
        }
Example #3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolEditFeatures.OnMouseDown implementation
            try
            {
                ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl;
                if (pSceneCtr != null)
                {
                    IPoint po;
                    object owner, obj;
                    pSceneCtr.SceneGraph.Locate(pSceneCtr.SceneViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out po, out owner, out obj);//po就是得到的点

                    //方法2
                    IHit3DSet pHit3dSet = null;
                    pSceneCtr.SceneGraph.LocateMultiple(pSceneCtr.SceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pHit3dSet);

                    //po = pHit3D.Point;//po就是得到的点

                    //如果想得到某图层元素,可以看看下面代码

                    //  int index = 2;
                    if (pHit3dSet == null)
                    {
                        return;
                    }
                    pHit3dSet.OnePerLayer();
                    IHit3D   pHit3D   = (IHit3D)pHit3dSet.Hits.get_Element(0);
                    IFeature pFeature = (IFeature)pHit3D.Object;
                    if (pFeature == null)
                    {
                        return;
                    }
                    ILayer pLayer = owner as ILayer;
                    if (pLayer == null)
                    {
                        return;
                    }
                    if (pLayer.Name != "Crater" && pLayer.Name != "NonCrater")
                    {
                        return;
                    }
                    IFeatureClass pFeatureClass = ((IFeatureLayer)pLayer).FeatureClass;
                    pSceneCtr.Scene.ClearSelection();
                    pSceneCtr.Scene.SelectFeature(pLayer, pFeature);
                    IActiveView pActiveView = pSceneCtr.Scene as IActiveView;
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    IMultiPatch pMP = pFeature.Shape as IMultiPatch;
                    FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2);
                    FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2);
                }
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    IMap   pMap = pMapCtr.Map;
                    IPoint po   = pMapCtr.ToMapPoint(X, Y);
                    ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();
                    pMap.SelectByShape(po, pSelectionEnv, true);
                    //for (int i = 0; i < pMap.LayerCount; i++ )
                    //{
                    //    ILayer pLayer = pMap.get_Layer(i);

                    //    if (pLayer.Name == "Crater")
                    //    {
                    //        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    //    }
                    //    if (pLayer.Name =="NonCrater")
                    //    {
                    //        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    //    }
                    //}
                    pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup;
                    pSelectionsetup.AllFields = true;//这里是关键
                    IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                    IFeature     pF = pFeatureCollection.Next();
                    if (pF != null && pF.Shape is IMultiPatch)
                    {
                        IMultiPatch pMP = pF.Shape as IMultiPatch;
                        FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2);
                        FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2);
                    }


                    //ISelection pSelection =pMap.FeatureSelection;
                    ////从Map.FeatureSelection获得ISelection不能读到Feature的其他属性,
                    ////这是因为从axMapControl1.Map.FeatureSelection QI到IEnumFeature 时,
                    ////ArcGIS中FeatureSelection默认的时候只存入Feature 的Shape,而不是整个Feature的字段数据。
                    ////如果要查看其他数据,必须要进行以下转换才可以:
                    //IEnumFeatureSetup pSelectionsetup = pSelection as IEnumFeatureSetup;
                    //pSelectionsetup.AllFields = true;//这里是关键
                    //IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                    //IFeature pF = pFeatureCollection.Next();
                    //if (pF != null)
                    //{
                    //    pF.Class
                    //}
                }
            }
            catch (System.Exception ex)
            {
            }
        }