当前位置: 首页 > 编程日记 > 正文

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

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

相关文章:

多线程2(常用的方法:join、interrupt、currentThread、isAlive、setDaemon...)

常用的方法&#xff1a; 1、join()方法&#xff1a;join()方法&#xff1a;执行该方法的线程进入阻塞状态&#xff0c;直到调用该方法的线程结束后再由阻塞状态转为就绪状态。 示例&#xff1a; package venus;import java.util.Date;public class Test {public static void m…

Oracle总结第二篇【视图、索引、事务、用户权限、批量操作】

前言 在Oracle总结的第一篇中&#xff0c;我们已经总结了一些常用的SQL相关的知识点了…那么本篇主要总结关于Oralce视图、序列、事务的一些内容… 在数据库中&#xff0c;我们可以把各种的SQL语句分为四大类… &#xff08;1&#xff09;DML&#xff08;数据操纵语言&#xff…

物联网应用介绍

•物联网的研究背景&#xff08;概念 | 本质 | 特征 | 发展现状&#xff09;物联网是新一代信息技术的高度集成和综合运用&#xff0c;已成为全球新一轮科技革命与产业变革的核心驱动和经济社会绿色、智能、可持续发展的关键基础与重要引擎。国家十三五规划纲要明确提出“积极推…

Oracle使用手册(三)---存储过程与触发器

--存储过程/**//*--1.过程的语法结构--参见:http://newland.cnblogs.com/archive/2006/04/05/367531.html--2.执行存储过程begin 存储过程名;end;--创建好的存储过程可以被任何程序调用*/--3.带参数的存储过程/**//* 参数类型 在PL/SQL过程中&#xff0c;可以有3种类型的…

数据结构之【线性表】(顺序表、链表的基本操作实现)

概念线性表&#xff1a;是N个数据元素的有限序列。 顺序表&#xff1a;用一组地址连续的存储单元依次存储【线性表 】的数据元素。&#xff08;区别于有序表&#xff1a;表中的数据元素存在非递增或非递减有序&#xff09; 链表&#xff1a;用一组任意的存储单元来存储【线性表…

基于android的天气预报的设计与实现

目录 应用开发技术及开发平台介绍应用需求分析应用功能设计及其描述应用UI展示①开发技术&#xff1a; 本系统是采用面向对象的软件开发方法&#xff0c;基于Android studio开发平台&#xff0c;以Android作为本系统的开发语言实现音乐播放器预定的需求功能。 ②平台介绍 硬件平…

敏捷开发有感!

http://sd.csdn.net/n/20060913/94713.html1.我们最优先要做的是通过尽早的&#xff0c;持续的交付有价值的软件来使客户满意。有一篇文章分析了对于公司构建高质量产品方面有帮助的软件开发实践&#xff0c;其中一个实践表明尽早的交付具有部分功能的系统和系统质量之间具有很…

ng 表单提交验证

http://www.runoob.com/try/try.php?filenametry_ng_validate 转载于:https://www.cnblogs.com/alvin553819/p/7127226.html

Infragistics NetAdvantage 2006 Volume 2 CLR 2.0曲折安装

上个月看到Infragistics NetAdvantage 2006 Volume 2 CLR 2.0(新特性)新鲜出炉&#xff0c;就一直想安装试用。昨天qq上得知已经有人在使用了&#xff0c;赶紧google一个down下来。经过漫长下载等待&#xff0c;满怀希望安装&#xff0c;哪想到快完成的时候居然报错&#xff0c…

数据结构之【栈】的基本操作C语言实现

引题&#xff1a; 很多人都把【栈】描述成【弹匣】&#xff0c;但我总感觉有点不恰当&#xff0c;因为弹匣从上端【装弹】之后&#xff0c;子弹总是在匣的上层&#xff1b;而元素【进栈】之后&#xff0c;总在栈的下面。 我觉得还是描述成【从下往上向书箱里一层…

编码小记(未整理-持续更新)

----------------基本概念-------------------------------一.位&#xff1a; 计算机存储信息的最小单位&#xff0c;称之为位&#xff08;bit&#xff09;&#xff0c;音译比特&#xff0c;二进制的一个“0”或一个“1”叫一位。 二.字节 字节&#xff08;Byte&#xff09;是一…

使用locate 的正则查询 查找所有main.c

locate支持正则查询的功能&#xff0c; 只需输入locate -r 正则表达式 即可。 现在我想查找所有main.c怎么做&#xff1f; 打开终端&#xff0c;输入shell&#xff1a; locate -r main.c$ PS&#xff1a;$表示结束字符串结束。转载于:https://www.cnblogs.com/the-one/p…

My Favorites

AJAX "Atlas" Control Toolkit HomePage "Atlas" Client Class Library "Atlas" Server Class Library ASP.NET AJAX Roadmap http://www.ajaxian.com 被成为AJAX第一站 . http://www.ajaxmatters.com/ 不仅有讨论XMLHttpRequest 的文…

数据库事务初探

使用事务级别要慎重: 因为事务级别越高&#xff0c;数量越多、限制性更强的锁就会被运用到数据库记录或者表中。同时&#xff0c;更多的锁被运用到数据库和它们的覆盖面越宽&#xff0c;任意两个事务冲突的可能性就越大。 如果有一个冲突&#xff08;例如两个事务试图获取同一个…

数据结构之【队列】的基本操作C语言实现

直接上图&#xff1a; 循环队列的声明&#xff1a; 0、循环队列的声明 循环队列的基本操作&#xff1a; 1、InitQueue(&Q)&#xff08;构造一个空队列&#xff09; 2、DestroyQueue(&Q)&#xff08;销毁队列Q&#xff09; 3、ClearQueue(&Q)&#xff08;清空队列Q&…

在python3环境安装builtwith模块

1、安装命令&#xff1a; pip install builtwith 如果在命令行提示如下错误&#xff1a; Fatal error in launcher: Unable to create process using " 使用如下命令&#xff1a; python3 -m pip install builtwith 2、导入模块会出现错误提示&#xff1a; 原因&#xff1…

kettle组件-输出

1&#xff1a;删除连接数据库&#xff1a;新建连接数据库&#xff0c;或者应用转换中已经定义好的数据库。目标模式&#xff1a;指什么现在还不明确&#xff0c;集群模式&#xff1f;子服务器模式&#xff1f;--要写入数据的表的Schema名称。允许表名中包含“.”是很重要的。目…

NGOSS的一点简单概念

NGOSS&#xff08;Next Generation Operational Support Systems&#xff09;是由TMF&#xff08;Tele Management Forum&#xff09;提出的&#xff0c;他用于电信领域&#xff0c;是构建下一代OSS/BSS系统的框架。TMF提供了技术中立构架&#xff08;TNA&#xff09;作为NGOSS…

Windows Mobile 5.0 设备的目录变化

自定义铃声的默认两个存放位置&#xff1a;1. Application Data\Sounds &#xff08;不是Storage下的Application Data了&#xff09;。2. 外存储设备的根目录。

第二周期的第一次站立会议

今天&#xff1a;对这一阶段的任务进行了分配&#xff0c;我就自己的任务内容搜集了一些资料&#xff0c;尝试了编程。明天&#xff1a;继续进行编程。遇到的问题&#xff1a;编程方面有些许的困难。转载于:https://www.cnblogs.com/guantianhuan/p/10051436.html

常见的函数式编程模型

1.闭包&#xff08;Closure&#xff09; 闭包的概念 可以保留局部变量不被释放的代码块&#xff0c;被称为一个闭包。 闭包的特点&#xff1a;函数嵌套函数、内部函数可以引用外部函数的参数和变量、参数和变量不会被垃圾回收机制收回 // 创建一个闭包 function makeCounter() …

Ubuntu下安装和配置Redis

找到 /ect/redis/redis.conf 文件修改如下:注释掉 127.0.0.1 ,如果不需要远程连接redis则不需要这个操作。使用客户端向 Redis 服务器发送一个 PING ,如果服务器运作正常的话,会返回一个 PONG。默认情况下,Redis服务器不允许远程访问,只允许本机访问,所以我们需要设置打开远程访问的功能。执行sudo apt-get install redis-server 安装命令。查看 redis 是否启动,重新打开一个窗口。停止/启动/重启redis。

自学笔记——1.Pyhton保留关键字

Python保留关键字python保留的关键字如下python保留的关键字如下 and del from None True as elif global nonlocal try assert else if not while break except import or with class False in pass yield continue finally is raise def for lambda…

人的一生有三件事不能等

人的一生有三件事不能等人的一生有三件事不能等 第一是“贫穷” 贫穷不能等&#xff0c;因为一但时间久了&#xff0c;你将习惯贫穷&#xff0c;到时不但无法突破自我&#xff0c;甚至会抹杀了自己的梦想&#xff0c;而庸庸碌碌的过一辈子。。。。。。 第二是“梦想” 梦想不能…

安装部署中的数据库打包和快捷方式启动浏览器

前一段时间&#xff0c;因为工作的需要&#xff0c;学习了一些.net的部署。在打包的过程中遇到了几个问题&#xff1a;<?XML:NAMESPACE PREFIX O />1、 数据库脚本打包&#xff0c;如何修改Web.config文件中的数据联接2、 数据库脚本中的方法和视图打包时要注意的问题…

Windows下安装和配置Redis

下载版本Redis-x64-5.0.14.1.zip。(可能需要开代理)

python练习册 每天一个小程序 第0004题

1 #-*-coding:utf-8-*- 2 __author__ Deen 3 4 题目描述&#xff1a;任一个英文的纯文本文件&#xff0c;统计其中的单词出现的个数。5 参考学习链接&#xff1a;6 re http://www.cnblogs.com/tina-python/p/5508402.html#undefined7 collections http://blog.csdn.…

xxxxxxx

xxxxxxxxxxxxxxxx转载于:https://www.cnblogs.com/pythonClub/p/10054454.html

自学笔记——2.字符串的切片、遍历、查找字符

一、字符串的切片 字符串的部分片段或者子集称为切片操作&#xff0c;所有字符串的切片操作是通过方括号&#xff08;[ ]&#xff09;实现的&#xff0c;语法&#xff1a;[n : m : s] 会返回一个子字符串&#xff0c;从索引值n到n-1之间&#xff0c;以s为步进&#xff0c;即&a…

【EXLIBRIS】随笔记 011

随 笔 记 <十一> 持这种观点的人一个是Dr. Johnson&#xff0c;另一个是西方文化影响更加根深蒂固的Reverend&#xff0c;似乎英文字母&#xff08;Indian-European family&#xff09;那种“抽象的、率意独断”的符号&#xff08;Wai-lim Yip语&#xff09;才是最基本的…