ArcEngine二次开发之axTOCControl目录树点击

private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
{
    esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
    IBasicMap map = null;
    ILayer layer = null;
    object other = null;
    object index = null;
    axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

    if (e.button == 2)
    {
        if (item == esriTOCControlItem.esriTOCControlItemMap)
        {
            mapControl.CustomProperty = map;
            menuTOCLayer.PopupMenu(e.x + 10, e.y, axTOCControl1.hWnd);
        }
        else if (layer is IFeatureLayer)
        {
            mapControl.CustomProperty = layer;
            menuTOCLayer.PopupMenu(e.x + 10, e.y, axTOCControl1.hWnd);
        }
        else if (layer is IRasterLayer)
        {
            mapControl.CustomProperty = layer;
            menuTOCLayer.PopupMenu(e.x + 10, e.y, axTOCControl1.hWnd);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/RicardoMTan/article/details/91433765
今日推荐