ArcGIS Engine开发-TOCControl中实现图层的拖放

news/2024/9/20 6:55:55
TOCControl非常好,不用写一行代码就可以将整个地图的图层信息况显示出来;
  TOCControl也非常坏,提供的接口非常少,我认为有用的只有三个:HitTest,SetBuddyControl,Update,而且Update方法一执行,整个TocControl就会重新装载一次,闪烁很厉害,实在是让人烦。要想在TOCControl中拖动图层,也并不容易,得动一动脑筋才行。
  下面是我写的一个类,用于实现拖动图层,有需要的朋友,可以复制过去了,看一看。
  需要说明的是,该类需要传入一个System.Windows.Forms.Control作为移动图层时显示要移到的位置,所以,在TOCControl上最好上一个Panel,然后传入到TocHelper中。另外,在计算同m_MovingLine显示的位置时,偶没找到什么好办法,只好设置了一个行高的参数。在正常字体时,据我的经验,行高是16,在Windows大字体显示时,行高是18,可以精确的显示。但这毕竟不是一个好办法。哪位高人要是看到了这个帖子,也请指点小弟一二,感激不尽!


None.gifpublic class TocHelper
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif{
InBlock.gif        
private ESRI.ArcGIS.TOCControl.AxTOCControl m_toc;
InBlock.gif        
private ILayer m_layer = null;
InBlock.gif        
private object m_other,m_index;
InBlock.gif
InBlock.gif        
private LayerPopmenu m_LyMenu ;
InBlock.gif        
private DataFramePopmenu m_FrameMenu = new DataFramePopmenu();
InBlock.gif
InBlock.gif        
public event CurrentLayerChangedHandler CurrentLayerChanged;
InBlock.gif
InBlock.gif        
private bool m_Dragging = false;
InBlock.gif        
private System.Windows.Forms.Control m_MovingLine;// = new System.Windows.Forms.Panel();
InBlock.gif

InBlock.gif        
public TocHelper(ESRI.ArcGIS.TOCControl.AxTOCControl toc)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_toc 
= toc;
InBlock.gif            m_LyMenu 
= new LayerPopmenu(this);
InBlock.gif            m_LyMenu.TOCControl 
= m_toc;
InBlock.gif            m_FrameMenu.TOCControl 
= m_toc;
InBlock.gif
InBlock.gif            m_toc.LabelEdit 
= esriTOCControlEdit.esriTOCControlManual;
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**////处理事件
InBlock.gif            m_toc.OnMouseDown += new ITOCControlEvents_OnMouseDownEventHandler(m_toc_OnMouseDown);
InBlock.gif            m_toc.OnMouseMove 
+= new ITOCControlEvents_OnMouseMoveEventHandler(m_toc_OnMouseMove);
InBlock.gif            m_toc.OnMouseUp 
+= new ITOCControlEvents_OnMouseUpEventHandler(m_toc_OnMouseUp);
InBlock.gif            m_toc.OnBeginLabelEdit 
+= new ITOCControlEvents_OnBeginLabelEditEventHandler(m_toc_OnBeginLabelEdit);
InBlock.gif            m_toc.OnEndLabelEdit 
+= new ITOCControlEvents_OnEndLabelEditEventHandler(m_toc_OnEndLabelEdit);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public void SetMoveLine(System.Windows.Forms.Control line)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_MovingLine 
= line;
InBlock.gif            m_MovingLine.Size 
= new System.Drawing.Size(100,2);
InBlock.gif            m_MovingLine.BackColor 
= System.Drawing.Color.Black;
InBlock.gif            m_MovingLine.Visible 
= false;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private DevExpress.XtraBars.BarManager m_pBarManager;
InBlock.gif        
public void SetBarManager(DevExpress.XtraBars.BarManager barMan)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_pBarManager 
= barMan;
InBlock.gif            m_LyMenu.SetBarManager(barMan);
InBlock.gif            m_FrameMenu.SetBarManager(barMan);
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 获取当前图层
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public ESRI.ArcGIS.Carto.ILayer CurrentLayer
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_layer;
ExpandedSubBlockEnd.gif            }
            
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 刷新视图
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="layer"></param>

InBlock.gif        private void RefreshView(ILayer layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (m_toc == null)
InBlock.gif                
return;
InBlock.gif            
if (m_toc.Buddy == null)
InBlock.gif                
return;
InBlock.gif
InBlock.gif            IActiveView pView 
= null;
InBlock.gif            
if (m_toc.Buddy is  ESRI.ArcGIS.MapControl.IMapControl2)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                pView 
= (m_toc.Buddy as ESRI.ArcGIS.MapControl.IMapControl2).ActiveView;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else if (m_toc.Buddy is ESRI.ArcGIS.SceneControl.ISceneControl)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                IScene scene 
= (m_toc.Buddy as ESRI.ArcGIS.SceneControl.ISceneControl).Scene;
InBlock.gif                
if (scene is IActiveView)
InBlock.gif                    pView 
= scene as IActiveView;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
if (pView != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (layer != null)
InBlock.gif                    pView.PartialRefresh(esriViewDrawPhase.esriViewGeography,layer,pView.Extent);
InBlock.gif                
else
InBlock.gif                    pView.Refresh();
InBlock.gif            
ExpandedSubBlockEnd.gif            }
                
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int m_DragStartY;
InBlock.gif        
public int MouseX,MouseY;
InBlock.gif        
private int m_TextHeight = 18;
InBlock.gif        
private void m_toc_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**////选中对象            
InBlock.gif            ITOCControl m_TOCControl = (ITOCControl) m_toc.Object;
InBlock.gif            esriTOCControlItem item 
=esriTOCControlItem.esriTOCControlItemNone;
InBlock.gif            ILayer layer 
= null;
InBlock.gif            IBasicMap map 
= null;            
InBlock.gif            m_TOCControl.HitTest(e.x,e.y,
ref item,ref map,ref layer,ref m_other,ref m_index);
InBlock.gif            MouseX 
= e.x;MouseY =e.y;
InBlock.gif            m_DragStartY 
= e.y;
InBlock.gif
InBlock.gif            
//设置当前图层
InBlock.gif
//            if (item == esriTOCControlItem.esriTOCControlItemLayer)
InBlock.gif
//            {
InBlock.gif
                if (m_layer != layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_layer 
= layer;
InBlock.gif                    
if (CurrentLayerChanged != null)
InBlock.gif                        CurrentLayerChanged();
ExpandedSubBlockEnd.gif                }

InBlock.gif
//            }
InBlock.gif
//            else
InBlock.gif
//            {
InBlock.gif
//                if (m_layer != null)
InBlock.gif
//                {
InBlock.gif
//                    m_layer = null;
InBlock.gif
//                    if (CurrentLayerChanged != null)
InBlock.gif
//                        CurrentLayerChanged();
InBlock.gif
//                }
InBlock.gif
//            }
InBlock.gif
            m_LyMenu.CurrentLayer = m_layer;
InBlock.gif            m_FrameMenu.CurrentLayer 
= m_layer;
InBlock.gif
InBlock.gif            
//如果点中的图例,则弹出符号设置窗口
InBlock.gif
            if ((e.button == 1&& (item == esriTOCControlItem.esriTOCControlItemLegendClass)) 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                ILegendGroup legendGroup;
InBlock.gif                ILegendClass legendClass;
InBlock.gif                legendGroup 
= m_other as ILegendGroup;
InBlock.gif                Debug.Assert(legendGroup 
!= null);
InBlock.gif                legendClass 
= legendGroup.get_Class(Convert.ToInt32(m_index.ToString()));
InBlock.gif                Debug.Assert(legendClass 
!= null);
InBlock.gif                ISymbol pSymbol 
= legendClass.Symbol;
InBlock.gif
InBlock.gif                //选择符号窗口代码去掉了。

InBlock.gif                
return;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            
InBlock.gif            
//如果是鼠标右键,则弹出右键菜单
InBlock.gif
            if (e.button == 2)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                System.Diagnostics.Debug.Assert(m_pBarManager 
!= null);
InBlock.gif                
if ((item == esriTOCControlItem.esriTOCControlItemLayer) && (layer != null))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_pBarManager.SetPopupContextMenu(m_toc,m_LyMenu.PopMenu);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if (item == esriTOCControlItem.esriTOCControlItemMap)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_pBarManager.SetPopupContextMenu(m_toc,m_FrameMenu.PopMenu);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_pBarManager.SetPopupContextMenu(m_toc,
null);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
InBlock.gif            
//如果鼠标左键选中了一个图层,则设为拖动状态
InBlock.gif
            if ((e.button == 1&& (layer != null))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Dragging 
= true;
InBlock.gif                m_DestLayer 
= null;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
InBlock.gif            m_TextHeight 
= m_toc.Parent.Font.Height+2
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int GetLayerIndex(IBasicMap map,ILayer layer,bool DragUp)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            ILayer tmpLayer;
InBlock.gif            
for (int i=0;i<=map.LayerCount-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                tmpLayer 
= map.get_Layer(i);
InBlock.gif                
if (tmpLayer == layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{    
InBlock.gif                    
if (DragUp == true)
InBlock.gif                        
return i-1;
InBlock.gif                    
else
InBlock.gif                        
return i;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return 0;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int GetLayerIndex(ICompositeLayer groupLayer,ILayer layer,bool DragUp)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
for (int i=0;i<=groupLayer.Count-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (groupLayer.get_Layer(i) == layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if (i == groupLayer.Count-1)
InBlock.gif                        
return i;
InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
if (DragUp == true)
InBlock.gif                            
return i;
InBlock.gif                        
else
InBlock.gif                            
return i+1;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return 0;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private ILayer m_DestLayer;
InBlock.gif        
private bool m_DestIsMap = false;
InBlock.gif        
private bool m_DragToCorrectPos = false;
InBlock.gif        
private void m_toc_OnMouseMove(object sender, ITOCControlEvents_OnMouseMoveEvent e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**////如果正在拖动图层
InBlock.gif            if (m_Dragging == true)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_DragToCorrectPos 
= false;
InBlock.gif
InBlock.gif                ITOCControl m_TOCControl 
= (ITOCControl) m_toc.Object;
InBlock.gif                esriTOCControlItem item 
=esriTOCControlItem.esriTOCControlItemNone;
InBlock.gif                ILayer layer 
= null;
InBlock.gif                IBasicMap map 
= null;
InBlock.gif                
object other = null;
InBlock.gif                
object index = null;
InBlock.gif                m_TOCControl.HitTest(e.x,e.y,
ref item,ref map,ref layer,ref other,ref index);
InBlock.gif                
InBlock.gif                m_DestIsMap 
= false;
InBlock.gif                m_DestLayer 
= layer;
InBlock.gif                
if (item == esriTOCControlItem.esriTOCControlItemMap)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_DestIsMap 
= true;
InBlock.gif
InBlock.gif                    
int yy;                    
InBlock.gif                    yy 
= Convert.ToInt32(Math.Floor(e.y/m_TextHeight) * m_TextHeight)+m_TextHeight;
InBlock.gif
InBlock.gif                    m_MovingLine.Location 
= new System.Drawing.Point(30,yy);
InBlock.gif                    m_MovingLine.Width 
= m_toc.Width - 35;
InBlock.gif                    m_MovingLine.Visible 
= true;
InBlock.gif                    m_toc.MousePointer 
= ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault;                    
InBlock.gif                    m_DragToCorrectPos 
= true;
InBlock.gif                                
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if ((item == esriTOCControlItem.esriTOCControlItemLayer) && (layer != m_layer) && (layer != null))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif
InBlock.gif                    
if (m_DestLayer is IGroupLayer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        m_MovingLine.Visible 
= false;
InBlock.gif                        m_toc.MousePointer 
= ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerLabel;
InBlock.gif                        m_DragToCorrectPos 
= true;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
int yy;                    
InBlock.gif                        
if (e.y > m_DragStartY)  //向下拖放
ExpandedSubBlockStart.gifContractedSubBlock.gif
                        dot.gif{
InBlock.gif                            yy 
= Convert.ToInt32(Math.Floor(e.y/m_TextHeight) * m_TextHeight)+m_TextHeight;
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else  //向上拖放
ExpandedSubBlockStart.gifContractedSubBlock.gif
                        dot.gif{
InBlock.gif                            yy 
= Convert.ToInt32(Math.Floor(e.y/m_TextHeight) * m_TextHeight);                        
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        m_MovingLine.Location 
= new System.Drawing.Point(30,yy);
InBlock.gif                        m_MovingLine.Width 
= m_toc.Width - 35;
InBlock.gif                        m_MovingLine.Visible 
= true;
InBlock.gif                        m_toc.MousePointer 
= ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault;                    
InBlock.gif                        m_DragToCorrectPos 
= true;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_MovingLine.Visible 
= false;
InBlock.gif                    m_toc.MousePointer 
= ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 取得图层的上一级对象,可能是igrouplayer,或ibasicmap
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="map"></param>
InBlock.gif        
/// <param name="layer"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        private object GetLayerParent(IBasicMap map,ILayer layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            ILayer tmpLayer;
InBlock.gif            
for (int i=0;i<= map.LayerCount-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                tmpLayer 
= map.get_Layer(i);
InBlock.gif                
if (tmpLayer == layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return map;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if (tmpLayer is IGroupLayer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    IGroupLayer ly 
= FindParentGroupLayer(tmpLayer as IGroupLayer,layer);
InBlock.gif                    
if (ly != null)
InBlock.gif                        
return ly;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return map;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private IGroupLayer FindParentGroupLayer(IGroupLayer groupLayer,ILayer layer)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (!(groupLayer is ICompositeLayer))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return groupLayer;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            ICompositeLayer comLayer 
= groupLayer as ICompositeLayer;
InBlock.gif            ILayer tmpLayer;
InBlock.gif            
for (int i=0;i<=comLayer.Count-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                tmpLayer 
= comLayer.get_Layer(i);
InBlock.gif                
if (tmpLayer == layer)
InBlock.gif                    
return groupLayer;
InBlock.gif                
else if (tmpLayer is IGroupLayer)
InBlock.gif                    
return FindParentGroupLayer(tmpLayer as IGroupLayer,layer);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return null;
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 在grouplayer中移动图层
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="pGroupLayer"></param>
InBlock.gif        
/// <param name="pLayer"></param>
ExpandedSubBlockEnd.gif        
/// <param name="nIndex"></param>

InBlock.gif        private void MoveLayerTo(IGroupLayer pGroupLayer, ILayer pLayer, int nIndex)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            ICompositeLayer pCompositeLayer 
= pGroupLayer as ICompositeLayer;
InBlock.gif
//            if(pCompositeLayer.Count < 2)
InBlock.gif
//                return ;
InBlock.gif

InBlock.gif            
if(pCompositeLayer.Count-1 == nIndex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                pGroupLayer.Delete(pLayer);
InBlock.gif                pGroupLayer.Add(pLayer);
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            IArray pArray 
= new ArrayClass();
InBlock.gif
InBlock.gif            
for(int i = 0; i < pCompositeLayer.Count; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                pArray.Add(pCompositeLayer.get_Layer(i));
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            pGroupLayer.Clear();
InBlock.gif            ILayer pLayer1;
InBlock.gif            
for(int i = 0; i < pArray.Count; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(pCompositeLayer.Count  == nIndex)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    pGroupLayer.Add(pLayer);
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                pLayer1  
= pArray.get_Element(i) as ILayer;
InBlock.gif                
if(pLayer1 == pLayer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
continue;
ExpandedSubBlockEnd.gif                }

InBlock.gif                pGroupLayer.Add(pLayer1);
InBlock.gif
ExpandedSubBlockEnd.gif            }
            
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void m_toc_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (m_Dragging == true)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
ContractedSubBlock.gifExpandedSubBlockStart.gif                
check dragging conditions#region check dragging conditions
InBlock.gif                m_Dragging 
= false;
InBlock.gif                m_toc.MousePointer 
= ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault;
InBlock.gif                
if (m_toc == null)
InBlock.gif                    
return ;
InBlock.gif                
if (m_toc.Buddy == null)
InBlock.gif                    
return ;
InBlock.gif                
if (m_DragToCorrectPos == false)
InBlock.gif                    
return;
InBlock.gif                m_DragToCorrectPos 
= false;
InBlock.gif                m_MovingLine.Visible 
= false;
InBlock.gif
InBlock.gif                IMap map
=null;
InBlock.gif                IScene scene
=null;
InBlock.gif                
if (m_toc.Buddy is IMapControl2)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    map 
= (m_toc.Buddy as IMapControl2).Map;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if (m_toc.Buddy is ESRI.ArcGIS.SceneControl.ISceneControl)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    scene 
= (m_toc.Buddy as ESRI.ArcGIS.SceneControl.ISceneControl).Scene;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return;
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                IBasicMap bmap;
InBlock.gif                
if (map != null)
InBlock.gif                    bmap 
= map as IBasicMap;
InBlock.gif                
else 
InBlock.gif                    bmap 
= scene as IBasicMap;
InBlock.gif                
if (bmap.LayerCount ==0)
InBlock.gif                    
return;
InBlock.gif
ExpandedSubBlockEnd.gif                
#endregion

InBlock.gif
InBlock.gif                
bool destIgnoreGroupLayer = false;
InBlock.gif                
if (m_DestIsMap == true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_DestLayer 
= bmap.get_Layer(0);
InBlock.gif                    destIgnoreGroupLayer 
= true;
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
if (m_DestLayer == null)
InBlock.gif                    
return;
InBlock.gif                
if (m_layer == m_DestLayer)
InBlock.gif                    
return;
InBlock.gif
InBlock.gif                
bool DragUp;  //是否正向上拖放
InBlock.gif
                DragUp = (e.y < m_DragStartY);
InBlock.gif                
int destIndex;
InBlock.gif
InBlock.gif                
object buddy = m_toc.Buddy;
InBlock.gif                m_toc.SetBuddyControl(
null);
InBlock.gif
InBlock.gif                
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
object srcGroupLayer = GetLayerParent(bmap,m_layer);
InBlock.gif                    
object destGroupLayer = GetLayerParent(bmap,m_DestLayer);                
InBlock.gif                
InBlock.gif                    
//先删除源图层
InBlock.gif
                    if (srcGroupLayer is GroupLayer)
InBlock.gif                        (srcGroupLayer 
as IGroupLayer).Delete(m_layer);
InBlock.gif                    
else
InBlock.gif                        bmap.DeleteLayer(m_layer);
InBlock.gif
InBlock.gif                    
//再加入,并移到合适位置
InBlock.gif
                    if ((m_DestLayer is IGroupLayer) && (destIgnoreGroupLayer == false))
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        (m_DestLayer 
as IGroupLayer).Add(m_layer);
InBlock.gif                        destIndex 
= GetLayerIndex(m_DestLayer as ICompositeLayer,m_layer,DragUp);                    
InBlock.gif                    
InBlock.gif                        MoveLayerTo(m_DestLayer 
as IGroupLayer,m_layer,destIndex);
InBlock.gif                        RefreshView(m_DestLayer);                                        
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else if (destGroupLayer is IGroupLayer)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{                    
InBlock.gif                        (destGroupLayer 
as IGroupLayer).Add(m_layer);
InBlock.gif                        destIndex 
= GetLayerIndex(destGroupLayer as ICompositeLayer,m_DestLayer,DragUp);                    
InBlock.gif                                        
InBlock.gif                        MoveLayerTo(destGroupLayer 
as IGroupLayer,m_layer,destIndex);    
InBlock.gif                        RefreshView(destGroupLayer 
as ILayer);
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        bmap.AddLayer(m_layer);
InBlock.gif                        destIndex 
= GetLayerIndex(bmap,m_DestLayer,DragUp);
InBlock.gif                                            
InBlock.gif                        
if (bmap is IMap)
InBlock.gif                            (bmap 
as IMap).MoveLayer(m_layer,destIndex);
InBlock.gif                        
else if (bmap is IScene)
InBlock.gif                            (bmap 
as IScene).MoveLayer(m_layer,destIndex);                    
ExpandedSubBlockEnd.gif                    }
    
InBlock.gif    
ExpandedSubBlockEnd.gif                }

InBlock.gif                
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_toc.SetBuddyControl(buddy);  
//重新绑定,并刷新toc
ExpandedSubBlockEnd.gif
                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void m_toc_OnBeginLabelEdit(object sender, ITOCControlEvents_OnBeginLabelEditEvent e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            e.canEdit 
= false;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void m_toc_OnEndLabelEdit(object sender, ITOCControlEvents_OnEndLabelEditEvent e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedBlockEnd.gif    }


转载于:https://www.cnblogs.com/watsonyin/archive/2006/09/14/504100.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pgtn.cn/news/18638.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

高斯金字塔

1、为什么要构建高斯金字塔 高斯金字塔模仿的是图像的不同的尺度&#xff0c;尺度应该怎样理解&#xff1f;对于一副图像&#xff0c;你近距离观察图像&#xff0c;与你在一米之外观察&#xff0c;看到的图像效果是不同的&#xff0c;前者比较清晰&#xff0c;后者比较模糊&am…

PCL:点云中的超体素数据

-----------------------体素数据---------------------体素化网格 体素&#xff08;Voxel&#xff09;是体积元素&#xff08;Volume pixel&#xff09;的简称&#xff0c;是数据位于三维空间内规则网格上的最小单位&#xff0c;体素&#xff0c;其物理意义类似于二维图像像素…

和12岁小同志搞创客开发:如何选择合适的传感器?

目录 1、信号采集 2、信号输出 3、物美价廉 4、如何选型采购 机缘巧合在网上认识一位12岁小同志&#xff0c;从零开始系统辅导其创客开发思维和技巧。 项目专栏&#xff1a;https://blog.csdn.net/m0_38106923/category_11097422.html 人类有五觉&#xff1a;视觉、听觉、…

差分金字塔

1、原理 DOG金字塔的每1组第i层是由高斯金字塔的每1组第i1层减每1组第i层得到的。以此类推&#xff0c;逐组逐层生成每一个差分图像&#xff0c;所有差分图像构成差分金字塔&#xff1b;每一组在层数上&#xff0c;DOG金字塔比高斯金字塔少一层。 DOG金字塔的构建可以用下图描…

毕业设计So Easy:珠穆朗玛FM音频电台APP

目录 1、项目背景 2、系统介绍 2.1、系统概述 2.2、关键技术 2.3、环境配置 3、系统结构设计 3.1、播放器状态结构图 3.2、登录流程结构图 4、系统模块设计 5、系统总体架构 6、接口描述 很多计算机专业大学生经常和我交流&#xff1a;毕业设计没思路、不会做、论文…

机器学习中的数学基础:(1)实际应用中矩阵特征值与特征向量的几何意义

关于特征值、特征向量的讲解有很多的教程&#xff0c;对于这些枯燥的数学基础怎么运用到自己的实际计算机视觉实验中&#xff0c;是一项很重要的任务。算法的底层其实就是数学公式的各种结合与推导&#xff0c;有时间不是我们不能很好的去理解这些算法基础&#xff0c;而是没有…

JAVA电影购票系统

一、功能描述 电影购票系统简介、项目功能演示 日志框架搭建、系统角色分析 首页设计、登录、商家界面、用户界面实现 商家-详情页设计、影片上架、退出 商家-影片下架、影片修改 用户-展示全部影片 用户-购票功能 用户-评分功能 用户-评分降序展示 用户-根据片名查询全部影片信…

和12岁小同志搞创客开发:如何驱动各类型传感器?

目录 1、数字量输出类型传感器 2、数字量输入类型传感器 3、模拟量电压类型传感器 4、模拟量电流类型传感器 5、协议类型传感器 机缘巧合在网上认识一位12岁小同志&#xff0c;从零开始系统辅导其创客开发思维和技巧。 项目专栏&#xff1a;https://blog.csdn.net/m0_3810…