阅读:1924回复:2
[求助]关于identifydialog的问题
<P>小弟在界面上使用双击实现了Identifydialog的功能,但是觉得GIS弹出的窗口非常的难看,而且我的信息只是针对其中的一个图层,我想将iidentifydialog中的信息取出,然后根据自己的需要通过一个自定义窗口显示自己想要的信息,请问大家如何取出iidentifydialog中的所有信息.小弟GIS新手,希望大家帮帮忙.</P>
|
|
1楼#
发布于:2009-08-03 20:04
<P>在论坛上找了个以前的帖子,但是附件已不能下,郁闷.</P>
|
|
2楼#
发布于:2009-08-12 11:18
<P>通常的做法是自己重新写一个工具。以下代码提供一下参考:</P>
<P>using System;<BR>using System.Drawing;<BR>using System.Runtime.InteropServices;<BR>using ESRI.ArcGIS.ADF.BaseClasses;<BR>using ESRI.ArcGIS.ADF.CATIDs;<BR>using ESRI.ArcGIS.Controls;<BR>using System.Windows.Forms;<BR>using ESRI.ArcGIS.Geometry;<BR>using ESRI.ArcGIS.Display;<BR>using ESRI.ArcGIS.Geodatabase;<BR>using ESRI.ArcGIS.Carto;<BR>using System.Collections;<BR>using System.Data;</P> <P>namespace DCIPipeInfo<BR>{<BR> /// <summary><BR> /// Summary description for FeatureSelectTool.<BR> /// </summary><BR> [Guid("d10a15d1-eb55-4979-bbea-a0781e577d8b")]<BR> [ClassInterface(ClassInterfaceType.None)]<BR> [ProgId("DCIPipeInfo.FeatureSelectTool")]<BR> public sealed class FeatureSelectTool : BaseTool<BR> {<BR> #region COM Registration Function(s)<BR> [ComRegisterFunction()]<BR> [ComVisible(false)]<BR> static void RegisterFunction(Type registerType)<BR> {<BR> // Required for ArcGIS Component Category Registrar support<BR> ArcGISCategoryRegistration(registerType);</P> <P> //<BR> // TOD Add any COM registration code here<BR> //<BR> }</P> <P> [ComUnregisterFunction()]<BR> [ComVisible(false)]<BR> static void UnregisterFunction(Type registerType)<BR> {<BR> // Required for ArcGIS Component Category Registrar support<BR> ArcGISCategoryUnregistration(registerType);</P> <P> //<BR> // TOD Add any COM unregistration code here<BR> //<BR> }</P> <P> #region ArcGIS Component Category Registrar generated code<BR> /// <summary><BR> /// Required method for ArcGIS Component Category registration -<BR> /// Do not modify the contents of this method with the code editor.<BR> /// </summary><BR> private static void ArcGISCategoryRegistration(Type registerType)<BR> {<BR> string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);<BR> MxCommands.Register(regKey);<BR> ControlsCommands.Register(regKey);<BR> }<BR> /// <summary><BR> /// Required method for ArcGIS Component Category unregistration -<BR> /// Do not modify the contents of this method with the code editor.<BR> /// </summary><BR> private static void ArcGISCategoryUnregistration(Type registerType)<BR> {<BR> string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);<BR> MxCommands.Unregister(regKey);<BR> ControlsCommands.Unregister(regKey);<BR> }</P> <P> #endregion<BR> #endregion</P> <P> private IMapControlDefault m_MapControl;</P> <P> public FeatureSelectTool()<BR> {<BR> //<BR> // TOD Define values for the public properties<BR> //<BR> base.m_category = ""; //localizable text <BR> base.m_caption = "设施选择"; //localizable text <BR> base.m_message = "设施选择"; //localizable text<BR> base.m_toolTip = "设施选择"; //localizable text<BR> base.m_name = "设施选择"; //unique id, non-localizable (e.g. "MyCategory_MyTool")<BR> try<BR> {<BR> base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");<BR> }<BR> catch<BR> {<BR> }<BR> }</P> <P> #region Overriden Class Methods</P> <P> /// <summary><BR> /// Occurs when this tool is created<BR> /// </summary><BR> /// <param name="hook">Instance of the application</param><BR> public override void OnCreate(object hook)<BR> {<BR> m_MapControl = hook as IMapControlDefault;</P> <P> // TOD Add other initialization code<BR> }</P> <P> public override int Cursor<BR> {<BR> get<BR> {<BR> return base.Cursor;<BR> }<BR> }</P> <P> /// <summary><BR> /// Occurs when this tool is clicked<BR> /// </summary><BR> public override void OnClick()<BR> {<BR> // TOD Add FeatureSelectTool.OnClick implementation<BR> //设置图层的选择参数<BR> ResetEditFeautreList(); </P> <P> //属性显示的窗口</P> <P> PipeInfoClass.GetInstance.ShowPipeInfo();<BR> }</P> <P> private IPoint m_FPoint;<BR> private INewEnvelopeFeedback m_EnvelopeFeedback; <BR> public override void OnMouseDown(int Button, int Shift, int X, int Y)<BR> {<BR> // TOD Add FeatureSelectTool.OnMouseDown implementation<BR> if (m_MapControl == null) return;<BR> m_FPoint = m_MapControl.ToMapPoint(X, Y);<BR> if (Button != 1) return;<BR> if (m_EnvelopeFeedback == null)<BR> {<BR> m_EnvelopeFeedback = new NewEnvelopeFeedbackClass();<BR> m_EnvelopeFeedback.Display = m_MapControl.ActiveView.ScreenDisplay;<BR> m_EnvelopeFeedback.Start(m_FPoint);<BR> }<BR> }</P> <P> public override void OnMouseMove(int Button, int Shift, int X, int Y)<BR> {<BR> // TOD Add FeatureSelectTool.OnMouseMove implementation<BR> if (m_MapControl == null) return;<BR> if (m_EnvelopeFeedback == null) return;<BR> IPoint pPoint = m_MapControl.ToMapPoint(X, Y);<BR> m_EnvelopeFeedback.MoveTo(pPoint);<BR> }</P> <P> public override void OnMouseUp(int Button, int Shift, int X, int Y)<BR> {<BR> // TOD Add FeatureSelectTool.OnMouseUp implementation<BR> if (m_EnvelopeFeedback == null) return;<BR> IPoint pPoint = m_MapControl.ToMapPoint(X, Y);<BR> IList pFeatureList = null;<BR> //IEnumFeature pEnumFeature = null;<BR> if (m_FPoint.X == pPoint.X ;; m_FPoint.Y == pPoint.Y)<BR> {<BR> pFeatureList = SelectFeatureInMap(m_FPoint);<BR> //pFeatureList = SelectFeatureInMap(pPoint);<BR> }<BR> else<BR> {<BR> IEnvelope pEnvelop = m_EnvelopeFeedback.Stop();<BR> pFeatureList = SelectFeatureInMap(pEnvelop);<BR> //pFeatureList = SelectFeatureInMap(pEnvelop);<BR> }<BR> m_FPoint = null;<BR> m_EnvelopeFeedback = null;</P> <P> // 显示属性窗口,把选择的结果传递给属性窗口<BR> PipeInfoClass.GetInstance.SetFeatureCollection(pFeatureList); <BR> PipeInfoClass.GetInstance.ShowPipeInfo();<BR> }<BR> public override void OnKeyDown(int keyCode, int Shift)<BR> {<BR> base.OnKeyDown(keyCode, Shift);<BR> }</P> <P> private IList SelectFeatureInMap(IGeometry pGeometry)<BR> {<BR> if (m_EditFeatureLayerList == null || m_EditFeatureLayerList.Count == 0) return null;<BR> IList pFeatureList = new ArrayList();<BR> IFeatureLayer pFeatureLayer = null;</P> <P> ISpatialFilter pSpatialFilter = new SpatialFilterClass();<BR> if (pGeometry.GeometryType == esriGeometryType.esriGeometryPoint)<BR> {<BR> ITopologicalOperator pTopo = pGeometry as ITopologicalOperator;<BR> pGeometry = pTopo.Buffer(m_MapControl.Extent.Width / 200);<BR> }<BR> pSpatialFilter.Geometry = pGeometry;<BR> pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;</P> <P> IFeatureCursor pFeatureCursor = null;<BR> IFeature pFeature = null;</P> <P> m_MapControl.Map.ClearSelection();<BR> for (int i = 0; i < m_EditFeatureLayerList.Count; i++)<BR> {<BR> pFeatureLayer = m_EditFeatureLayerList as IFeatureLayer;<BR> if (pFeatureLayer.MinimumScale != 0 || pFeatureLayer.MaximumScale != 0)<BR> {<BR> if (m_MapControl.MapScale > pFeatureLayer.MinimumScale || m_MapControl.MapScale < pFeatureLayer.MaximumScale) continue;<BR> }</P> <P> pFeatureCursor = pFeatureLayer.Search(pSpatialFilter, false);<BR> pFeature = pFeatureCursor.NextFeature();<BR> while (pFeature != null)<BR> {<BR> m_MapControl.Map.SelectFeature(pFeatureLayer as ILayer, pFeature);<BR> pFeatureList.Add(pFeature);</P> <P> pFeature = pFeatureCursor.NextFeature();<BR> }<BR> Marshal.FinalReleaseComObject(pFeatureCursor);<BR> }<BR> m_MapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, m_MapControl.Extent);<BR> return pFeatureList;<BR> }<BR> <BR> private IList m_EditFeatureLayerList = null;</P> <P> private void ResetEditFeautreList()<BR> {<BR> string pLayerName = string.Empty;<BR> IFeatureLayer pFeatureLayer = null;<BR> m_EditFeatureLayerList = new ArrayList();<BR> string pToolName = "FeatureInfo";<BR> <BR> string pSQL = "SELECT LAYERNAME FROM TOOL_LAYER WHERE TOOLNAME = '" + pToolName + "'";<BR> DataTable pDataTable = DCIEngine.Utility.DbUtil.GetInstance.GetDBTable(pSQL);</P> <P> if (pDataTable == null || pDataTable.Rows.Count == 0) return;</P> <P> for (int i = 0; i < pDataTable.Rows.Count; i++)<BR> {<BR> pLayerName = pDataTable.Rows["LAYERNAME"].ToString().Trim();<BR> if (pLayerName == string.Empty) continue;</P> <P> pFeatureLayer = DCIEngine.FrameWork.Global.GetFeatureLayerByName(pLayerName);<BR> if (pFeatureLayer == null) continue;</P> <P> m_EditFeatureLayerList.Add(pFeatureLayer);<BR> }<BR> } </P> <P> #endregion<BR> }<BR>}<BR></P> |
|