阅读:3637回复:10
求助:想在ArcTOCControl 中自由拖动图层用什么接口
<P>我想在ArcTOCControl 中自由拖动图层使其可以互换位置用什么接口啊?谢谢</P>
|
|
1楼#
发布于:2007-09-26 11:30
没人回答啊???????????????
|
|
2楼#
发布于:2007-09-27 09:42
9.2中已经做好了拖动了
|
|
3楼#
发布于:2007-09-27 11:05
使用ArcTOCControl的鼠标事件MOVE,DOWN,UP.获得拖动图层和要移动的位置,然后移动图层就可以.
|
|
4楼#
发布于:2007-09-27 22:19
我是9。0的,高手有没有例子参考一下,万分感谢!!!!
|
|
5楼#
发布于:2007-09-28 10:48
<P>Mousedown事件中调用HitTest成员,</P>
<P> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMap <CODE><FONT color=#0000ff>As</FONT></CODE> IMap<BR> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pLayer <CODE><FONT color=#0000ff>As</FONT></CODE> ILayer<BR> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pOther <CODE><FONT color=#0000ff>As</FONT></CODE> IUnknown<BR> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pItem <CODE><FONT color=#0000ff>As</FONT></CODE> esriTOCControlItem<BR> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pIndex <CODE><FONT color=#0000ff>As Variant</FONT></CODE><BR><BR> <CODE><FONT color=#008000>'Determine what kind of item has been clicked on</FONT></CODE><BR> TOCControl1.HitTest x, y, pItem, pMap, pLayer, pOther, pIndex<BR></P> |
|
6楼#
发布于:2007-10-10 17:14
<P>private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseDownEvent e)<BR> {<BR> if(e.button==1)<BR> {<BR> <BR> esriTOCControlItem pItem=new esriTOCControlItem();<BR> IBasicMap pMap=new MapClass();<BR> ILayer pLayer=null;<BR> object other=new object();<BR> object index=new object();<BR> //ILegendGroup pLegendGroup;<BR> pSelSymLayer=null;//当前需要移动的图层<BR> axTOCControl1.HitTest(e.x,e.y,ref pItem,ref pMap,ref pLayer,ref other,ref index);</P>
<P> if(pLayer==null)<BR> return;<BR> //MessageBox.Show("player=null!");<BR> if(pItem==esriTOCControlItem.esriTOCControlItemLayer)<BR> {<BR> if(pLayer.GetType() is IAnnotationSublayer)<BR> return;<BR> //MessageBox.Show("annotationsublayer!");<BR> else<BR> {<BR> //MessageBox.Show("ok!");<BR> axTOCControl1.MousePointer=esriControlsMousePointer.esriPointerHand;<BR> pSelSymLayer=pLayer;<BR> }<BR> }<BR> else<BR> {MessageBox.Show("mousedown!");}</P> <P> }<BR> }</P> <P> public void axTOCControl1_OnMouseMove(object sender, ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseMoveEvent e)<BR> {<BR> <BR> IBasicMap pMap=new MapClass();<BR> ILayer pLayer=null;<BR> esriTOCControlItem pItem=new esriTOCControlItem();<BR> object pOther=new object();<BR> object pIndex=new object();<BR> //实现调整图层顺序功能<BR> if(e.button==1)<BR> {<BR> axTOCControl1.HitTest(e.x,e.y,ref pItem,ref pMap,ref pLayer,ref pOther,ref pIndex);<BR> }<BR> if(pItem!=esriTOCControlItem.esriTOCControlItemNone)<BR> {<BR> //ESRI.ArcGIS.Utility.COMSupport.OLE.GetIPictureDispFromIcon(icon);<BR> axTOCControl1.MousePointer=esriControlsMousePointer.esriPointerCustom;<BR> }<BR> }<BR> <BR> private void axTOCControl1_OnMouseUp(object sender, ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseUpEvent e)<BR> {<BR> esriTOCControlItem pItem=new esriTOCControlItem();<BR> IBasicMap pMap=new MapClass();<BR> ILayer pLayer=null;<BR> object pOther=new object();<BR> object pIndex=new object();<BR> int i;<BR> //bool bUpdataToc;<BR> axTOCControl1.MousePointer=esriControlsMousePointer.esriPointerArrow;<BR> //实现调整图层顺序功能<BR> if(e.button==1)<BR> {<BR> axTOCControl1.HitTest(e.x,e.y,ref pItem,ref pMap,ref pLayer,ref pOther,ref pIndex);<BR> }<BR> if(pItem==esriTOCControlItem.esriTOCControlItemLayer||pItem==esriTOCControlItem.esriTOCControlItemLegendClass)<BR> {<BR> if(pLayer==null||pSelSymLayer==null||pSelSymLayer==pLayer)<BR> return;<BR> if(e.button==1)<BR> {<BR> for(i=0;i<pMap.LayerCount;i++)<BR> {<BR> ILayer pLayTmp;<BR> pLayTmp=pMap.get_Layer(i);<BR> //得到当前点击的索引值<BR> if(pLayer==pLayTmp)<BR> continue;<BR> }<BR> ((IMap)pMap).MoveLayer(pSelSymLayer,i);<BR> axMapControl1.ActiveView.Refresh();<BR> }<BR> }</P> <P> }</P> <P>请问我拖动图层都没反应,程序那里有问题啊?还有ESRI.ArcGIS.Utility.COMSupport.OLE.GetIPictureDispFromIcon(icon);启动出错显示受到保护限制但是我已经把函数改成public了。请高手指点!!!!</P> |
|
7楼#
发布于:2007-10-10 18:56
<P>请帮帮忙啊!!<IMG src="http://www.gisempire.com/bbs/Skins/default/topicface/face2.gif" align=absMiddle></P>
|
|
8楼#
发布于:2007-10-11 09:16
<P>我倒是可以拖动了,基本原理一样的,移动的时候添了一个label对象,使之随着鼠标移动用来标志移动位置,但是TOC屏幕会不停的刷新,很不爽!</P>
|
|
9楼#
发布于:2007-10-11 21:45
能把你的代码贴一下吗?我对比看看哪出问题了。
能把你的代码贴一下吗?我对比看看哪出问题了。 |
|
上一页
下一页