private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button != 2) { return; } esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //Determine what kind of item is selected m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Ensure the item gets selected if (item == esriTOCControlItem.esriTOCControlItemMap) { m_tocControl.SelectItem(map, null); } else { m_tocControl.SelectItem(layer, null); } //Set the layer into the CustomProperty (this is used by the custom layer commands) m_mapControl.CustomProperty = layer; ISchematicLayer schLayer = layer as ISchematicLayer; if (schLayer != null) /// attach menu for SchematicLayer { ISchematicTarget schematicTarget = new ESRI.ArcGIS.SchematicControls.EngineSchematicEnvironmentClass() as ISchematicTarget; if (schematicTarget != null) { schematicTarget.SchematicTarget = schLayer; } //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_menuSchematicLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); } } else /// attach menu for Layer { //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); } } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button != 2) return; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //Determine what kind of item is selected m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Ensure the item gets selected if (item == esriTOCControlItem.esriTOCControlItemMap) m_tocControl.SelectItem(map, null); else m_tocControl.SelectItem(layer, null); //Set the layer into the CustomProperty (this is used by the custom layer commands) m_mapControl.CustomProperty = layer; ISchematicLayer schLayer = layer as ISchematicLayer; if (schLayer != null) /// attach menu for SchematicLayer { ISchematicTarget schematicTarget = new ESRI.ArcGIS.SchematicControls.EngineSchematicEnvironmentClass() as ISchematicTarget; if (schematicTarget != null) schematicTarget.SchematicTarget = schLayer; //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuSchematicLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); } else /// attach menu for Layer { //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); } }