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);
}
}
}