10楼#
发布于:2006-01-02 17:45
VB.NET版
<P> '~~ 使TOC事件可以拖曳圖層 ~~<BR> '抓取要拖曳圖層<BR> Private Sub AxTOCControl1_OnMouseDown(ByVal sender As Object, ByVal e As ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseDownEvent) Handles AxTOCControl1.OnMouseDown<BR> If (e.button = 1) Then<BR> Dim pMap As IMap = New MapClass<BR> Dim pLayer As ILayer = New FeatureLayerClass<BR> ' Dim pLegendGroup As ILegendGroup<BR> Dim pLegendGroup As Object<BR> Dim pItem As esriTOCControlItem = New esriTOCControlItem<BR> Dim pIndex As Object<BR> pSelSymLayer = Nothing</P>
<P> '點選圖層或圖例<BR> AxTOCControl1.HitTest(e.x, e.y, pItem, pMap, pLayer, pLegendGroup, pIndex)<BR> If pLayer Is Nothing Then Exit Sub<BR> If pItem = esriTOCControlItem.esriTOCControlItemLayer Then<BR> '點中的是註記中的sublayer就退出<BR> If TypeOf pLayer Is IAnnotationSublayer Then Exit Sub<BR> pSelSymLayer = pLayer<BR> 'MsgBox(pSelSymLayer.Name)<BR> ElseIf pItem = esriTOCControlItem.esriTOCControlItemLegendClass Then<BR> '點中的是圖例<BR> If TypeOf pLayer Is IFeatureLayer Then<BR> End If<BR> End If<BR> End If<BR> End Sub<BR> '抓取放置位置<BR> Private Sub AxTOCControl1_OnMouseMove(ByVal sender As Object, ByVal e As ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseMoveEvent) Handles AxTOCControl1.OnMouseMove<BR> Dim pMap As IMap = New MapClass<BR> Dim pLayer As ILayer = New FeatureLayerClass<BR> Dim pLegendGroup As Object = Nothing<BR> Dim pItem As esriTOCControlItem = New esriTOCControlItem<BR> Dim pIndex As Object</P> <P> '實現調整圖層順序功能<BR> If (e.button = 1) Then<BR> AxTOCControl1.HitTest(e.x, e.y, pItem, pMap, pLayer, pLegendGroup, pIndex)<BR> End If<BR> If pItem <> esriTOCControlItem.esriTOCControlItemNone Then<BR> Me.AxTOCControl1.MousePointer = esriControlsMousePointer.esriPointerPanning<BR> End If</P> <P> End Sub<BR> '執行放置圖層<BR> Private Sub AxTOCControl1_OnMouseUp(ByVal sender As Object, ByVal e As ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseUpEvent) Handles AxTOCControl1.OnMouseUp<BR> Dim pMap As IMap = New MapClass<BR> Dim pLayer As ILayer = New FeatureLayerClass<BR> Dim pLegendGroup As Object = Nothing<BR> Dim pItem As esriTOCControlItem = New esriTOCControlItem<BR> Dim pIndex As Object<BR> Dim i As Integer, j As Integer<BR> Dim bUpdataToc As Boolean<BR> Me.AxTOCControl1.MousePointer = esriControlsMousePointer.esriPointerArrow</P> <P> '實現調整圖層順序功能<BR> If (e.button = 1) Then<BR> AxTOCControl1.HitTest(e.x, e.y, pItem, pMap, pLayer, pLegendGroup, pIndex)<BR> End If</P> <P> If pItem = esriTOCControlItem.esriTOCControlItemLayer Or esriTOCControlItem.esriTOCControlItemLegendClass Then<BR> If (pLayer Is Nothing) Or (pSelSymLayer Is Nothing) Or (pSelSymLayer Is pLayer) Then Exit Sub<BR> If (e.button = 1) Then</P> <P> For i = 0 To AxMap_MapView.LayerCount - 1<BR> Dim pLayTmp As ILayer<BR> pLayTmp = AxMap_MapView.get_Layer(i)<BR> '得到點選當前的索引值<BR> If pLayer Is pLayTmp Then Exit For<BR> Next i<BR> '防止多次刷新<BR> 'TreeRedraw(Me.TOCLayer.hwnd, False)<BR> On Error Resume Next<BR> AxMap_MapView.Map.MoveLayer(pSelSymLayer, i)<BR> On Error GoTo 0<BR> 'TreeRedraw(Me.TOCLayer.hwnd, True)<BR> End If<BR> End If<BR> End Sub</P> <P> <img src="images/post/smile/dvbbs/em01.gif" /></P> <P><FONT color=#f70909>這是VB.NET版....不過請教各位高手.....是否可以在拖動圖層時...可以顯示...在那一個圖層上停住嗎?? 因為這樣可以比較知道在那一個圖層!!</FONT> </P> |
|
11楼#
发布于:2006-02-20 16:29
<P>上面的所有代码都不能解决图层组的问题,是吗?</P>
|
|
12楼#
发布于:2006-02-24 15:50
<img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
|
|
|
13楼#
发布于:2006-02-28 12:27
<DIV class=quote><B>以下是引用<I>mms999</I>在2006-2-20 16:29:26的发言:</B><BR>
<P>上面的所有代码都不能解决图层组的问题,是吗?</P></DIV> <P>这个需要加入图层类型的判断</P> |
|
|
14楼#
发布于:2006-03-19 23:07
<P>kankan</P>
|
|
15楼#
发布于:2006-03-22 22:04
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" />
|
|
16楼#
发布于:2006-03-24 15:58
非常感谢,估计SceneControl的控制代码也是类似的吧。
|
|
17楼#
发布于:2006-06-09 17:21
<P>有.NET2003(C#)版的没??我把你们的改成C#了,在控制TOC刷新时,TreeRedraw(Me.TOCLayer.hwnd, True)里的SendMessage(...)是受保护的,请问,还有其他方法没??</P>
|
|
18楼#
发布于:2006-09-26 21:20
<P>哭,我怎么做不起来啊,我用C#</P>
|
|
19楼#
发布于:2006-09-28 16:03
好 辛苦了~~~~~~~
|
|
上一页
下一页