private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (axMapControl1.LayerCount > 0) { esriTOCControlItem pItem = new esriTOCControlItem(); pGlobalFeatureLayer = new FeatureLayerClass(); IBasicMap pBasicMap = new MapClass(); object pOther = new object(); object pIndex = new object(); axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref player, ref pOther, ref pIndex); } if (e.button == 2) { contextMenuStrip1.Show(axTOCControl1, e.x, e.y); } if (axMapControl1.LayerCount > 0) { esriTOCControlItem pItem = new esriTOCControlItem(); pGlobalFeatureLayer = new FeatureLayerClass(); IBasicMap pBasicMap = new MapClass(); object pOther = new object(); object pIndex = new object(); axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref player, ref pOther, ref pIndex); } if (e.button == 2) { contextMenuStrip1.Show(axTOCControl1, e.x, e.y); } }
private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) { object unk = null; object data = null; // 双击TOCControl控件时触发的事件 esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; IBasicMap basicMap = null; ILayer layer = null; this.axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data); if (e.button == 1) { if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass) { //取得图例 ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data); //创建符号选择器SymbolSelector实例 SymbolSelectorFrm SymbolSelectorFrm = new SymbolSelectorFrm(pLegendClass, layer); if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK) { //局部更新主Map控件 m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); //设置新的符号 pLegendClass.Symbol = SymbolSelectorFrm.pSymbol; //更新主Map控件和图层控件 m_mapControl.ActiveView.Refresh(); this.axTOCControl1.Refresh(); } } } }
private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e) { if (e.button == 1 && pMovelayer != null) { 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); IMap pMap = axMapControl1.ActiveView.FocusMap; ILayer pTempLayer; int toindex = 0; if (item == esriTOCControlItem.esriTOCControlItemLayer && layer != null) { if (pMovelayer != layer) { for (int i = 0; i < pMap.LayerCount; i++) { pTempLayer = pMap.get_Layer(i); if (pTempLayer == layer) { toindex = i;; } } pMap.MoveLayer(pMovelayer, toindex); } } axMapControl1.ActiveView.Refresh(); axMapControl1.Update(); pMovelayer = null; } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { axTOCControl1.ContextMenuStrip = contextMenuStrip1; //judge the type of item selected in the TOC IBasicMap map = new MapClass(); ILayer layer = null; System.Object other = null; System.Object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer) { //transfer the screen point location to form location to popup the contextmenu System.Drawing.Point p = new System.Drawing.Point(); p.X = e.x; p.Y = e.y; p = this.axTOCControl1.PointToScreen(p); this.contextMenuStrip1.Show(p); layerName = layer.Name; } if (e.button == 1 && item == esriTOCControlItem.esriTOCControlItemLayer) { strFileName = layer.Name; } }
private void tocControl_OnMouseDown(int button, int shift, int x, int y) { esriTOCControlItem esriTOCControlItem = esriTOCControlItem.esriTOCControlItemNone; object obj = null; object obj2 = null; IBasicMap basicMap = null; ILayer layer = null; this._tocControl.HitTest(x, y, ref esriTOCControlItem, ref basicMap, ref layer, ref obj, ref obj2); if (button == 2) { switch (esriTOCControlItem) { case esriTOCControlItem.esriTOCControlItemMap: this._tocControl.SelectItem(basicMap, null); this._mapControl.CustomProperty = basicMap; this._popMenuFrame.ShowPopup(System.Windows.Forms.Control.MousePosition); break; case esriTOCControlItem.esriTOCControlItemLayer: this._tocControl.SelectItem(layer, null); this._mapControl.CustomProperty = layer; this.SetBarItemEnabled(); this._popMenuLayer.ShowPopup(System.Windows.Forms.Control.MousePosition); break; } } }
/// <summary> /// tocControl鼠标按下事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_tocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object index = null; object other = null; m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (e.button == 2) // 鼠标右键 { switch (item) { case esriTOCControlItem.esriTOCControlItemMap: // 点击的是地图 tocControl_contextMenuStrip.Show(m_tocControl, new System.Drawing.Point(e.x, e.y)); break; case esriTOCControlItem.esriTOCControlItemLayer: // 点击的是图层 tocControlLayer_ContextMenu.Show(m_tocControl, new System.Drawing.Point(e.x, e.y)); break; case esriTOCControlItem.esriTOCControlItemHeading: break; default: tocControl_contextMenuStrip.Show(m_tocControl, new System.Drawing.Point(e.x, e.y)); break; } } }
private void GetWorkPath() //get the path of the first layer in the TOC table { IMap pMap = axTOCControl1.ActiveView.FocusMap; try { ILayer pLayer = pMap.Layer[0]; // get first layer of the Map IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFC = pFLayer.FeatureClass; /// get dataset of the standalone feature class IDataset pDataset = pFC as IDataset; IWorkspace pWS = pDataset.Workspace; this.strFilePath = pWS.PathName; // get selected layers object legendGroup = new object(); object index = new object(); IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); esriTOCControlItem item = new esriTOCControlItem(); axTOCControl1.GetSelectedItem(ref item, ref map, ref layer, ref legendGroup, ref index); if (item == esriTOCControlItem.esriTOCControlItemLayer) { MessageBox.Show("Selected layer name: " + layer.Name); } } catch { MessageBox.Show("Add at least one layer to the map"); } }
/// <summary> /// 打开属性表右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void openAttTable_ToolStripMenuItem_Click(object sender, EventArgs e) { IBasicMap map = null; ILayer layer = null; object unk = null; object data = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; m_tocControl.GetSelectedItem(ref item, ref map, ref layer, ref unk, ref data); IFeatureLayer selectedLayer = layer as IFeatureLayer; if (item == esriTOCControlItem.esriTOCControlItemLayer && selectedLayer != null) { if (selectedLayer is IFeatureLayer) { // 打开属性表窗口,如果当前没有属性表,就创建一个,如果当前有,就在原有窗口中添加一张表格 if (m_attForm == null || m_attForm.IsDisposed == true) { m_attForm = new AttributeTableForm(selectedLayer, this.getMapControl()); } else { m_attForm.appendTable(selectedLayer); } m_attForm.Show(); m_attForm.Focus(); } } }
/// <summary> /// 移除图层右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeLayer_ToolStripMenuItem_Click(object sender, EventArgs e) { IBasicMap map = null; ILayer selectedLayer = null; object unk = null; object data = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; m_tocControl.GetSelectedItem(ref item, ref map, ref selectedLayer, ref unk, ref data); if (item == esriTOCControlItem.esriTOCControlItemLayer) { IDataLayer2 datalayer = selectedLayer as IDataLayer2; if (datalayer.DataSourceName.NameString != "") { datalayer.Disconnect(); } m_mapControl.Map.DeleteLayer(selectedLayer); if (m_attForm != null && selectedLayer is IFeatureLayer) { m_attForm.att_removetable(selectedLayer as IFeatureLayer); } } this.Focus(); m_mapControl.Focus(); }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 1) //左键 { esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; IBasicMap pMap = null; object unk = null; object data = null; ILayer pLayer = null; axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data); pCurrentLayer = pLayer as IFeatureLayer; return; } else if (e.button == 2) { esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; IBasicMap pMap = null; object unk = null; object data = null; ILayer pLayer = null; axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data); pCurrentLayer = pLayer as IFeatureLayer; if (pItem == esriTOCControlItem.esriTOCControlItemLayer && pCurrentLayer != null) { contextMenuStrip1.Show(Control.MousePosition); } } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (e.button == 2) { if (item == esriTOCControlItem.esriTOCControlItemMap) { m_controlsSynchronizer.MapControl.CustomProperty = map; m_TocMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } else if (layer is IFeatureLayer) { m_controlsSynchronizer.MapControl.CustomProperty = layer; m_TocLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } } if (e.button == 1) { if (layer == null) { return; } IFeatureLayer featurelayer = layer as IFeatureLayer; if (featurelayer == null) { return; } IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featurelayer; ILegendClass legendClass = new LegendClassClass(); ISymbol symbol = null; if (other is ILegendGroup && (int)index != -1) { legendClass = ((ILegendGroup)other).get_Class((int)index); symbol = legendClass.Symbol; } if (symbol == null) { return; } symbol = GetSymbolByControl(symbol); if (symbol == null) { return; } legendClass.Symbol = symbol; this.Activate(); //((IActiveView)m_MapDocument.get_Map(0)).ContentsChanged(); axMapControl1.ActiveView.ContentsChanged(); axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); axMapControl1.Refresh(); axTOCControl1.Update(); } }
// axTOCControl1 中判断鼠标点中的项目并弹出右键菜单 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) { 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 ); // 如果点中了一个 Map 项目 if (item == esriTOCControlItem.esriTOCControlItemMap) { mapTOCMenuStrip.Show(axTOCControl1, e.x, e.y); _hitMap = map as IMap; } else if (item == esriTOCControlItem.esriTOCControlItemLayer) { layerTOCMenuStrip.Show(axTOCControl1, e.x, e.y); _hitLayer = layer; } } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //右键toc图层出现菜单和图层关联 axTOCControl1.ContextMenuStrip = null; IBasicMap map = new MapClass(); System.Object other = null; System.Object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemLayer && e.button == 2) { System.Drawing.Point pt = new System.Drawing.Point(); pt.X = e.x; pt.Y = e.y; pt = this.axTOCControl1.PointToScreen(pt); this.contextMenuStrip1.Show(pt); } else if (item == esriTOCControlItem.esriTOCControlItemLayer && e.button == 1) { if (layer is IAnnotationSublayer) //注记层在表层,不参与移动 { return; } else { pMoveLayer = layer; } } }
private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button != 2) { return; } //if ( m_pToolbarMenu. IBasicMap map = null; ILayer layer = null; ILayer m_layer = null; object other = null; object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if ((item == esriTOCControlItem.esriTOCControlItemLayer)) { if (layer is IFeatureLayer) { MapControl.CustomProperty = layer; m_pToolbarMenu.PopupMenu(e.x, e.y, (int)TOCControl.Handle); } } }
private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e) { if (e.button == 1)//判断是否为左键点击 { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; mTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); IMap pMap = this.axMapControl1.ActiveView.FocusMap; if (item == esriTOCControlItem.esriTOCControlItemLayer || layer != null) { if (pMoveLayer != null) { ILayer pTempLayer; for (int i = 0; i < pMap.LayerCount; i++) { pTempLayer = pMap.get_Layer(i); if (pTempLayer == layer) { toIndex = i; } } pMap.MoveLayer(pMoveLayer, toIndex); axMapControl1.ActiveView.Refresh(); mTOCControl.Update();//更新tocControl空间 } } } }
//TOCControl控件的鼠标双击事件 public void m_tocControl_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) { if (e.button == 1) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //判断所选菜单的类型 m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemLayer) { /* AttributeForm af = new AttributeForm((IMapControl3)m_mapControl); * af.m_layer = layer; * af.ShowDialog();*/ // iAttribute_Click(null, null); } this.m_mapControl.ActiveView.Refresh(); this.m_tocControl.Refresh(); } }
private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e) { if (e.button == 1) { 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); IMap pMap = axMapControl_1.ActiveView.FocusMap; if (item == esriTOCControlItem.esriTOCControlItemLayer || layer != null) { //预移动图层和鼠标当前位置图层不一致时 if (pMoveLayer != layer) { ILayer pTempLayer; for (int i = 0; i < pMap.LayerCount; i++) { pTempLayer = pMap.get_Layer(i); //获取鼠标当前位置图层的索引值 if (pTempLayer == layer) { toIndex = i; } } pMap.MoveLayer(pMoveLayer, toIndex); axMapControl_1.ActiveView.Refresh(); axTOCControl1.Update(); } } } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //make sure that the user right clicked if (2 != e.button) { return; } //use HitTest in order to test whether the user has selected a featureLayer esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //do the HitTest axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Determine what kind of item has been clicked on if (null == layer || !(layer is IFeatureLayer)) { return; } //set the featurelayer as the custom property of the MapControl axMapControl1.CustomProperty = layer; //popup a context menu with a 'Properties' command m_contextMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { /* ArcGIS Snippet Title: * Find the selected layer in the table of contents * * Add the following reference to the project: * ESRI.ArcGIS.Controls * * Add the following ArcGIS Engine control to the project: * TOCControl * * Intended ArcGIS Products for this snippet: * ArcGIS Engine * * Notes: * This snippet is intended to be inserted into the OnMouseDown event of the TOC Control * The code assumes that a module-level variable (m_layer) has been declared as ILayer */ IBasicMap map = null; ILayer layer = null; object other = null; object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if ((item == esriTOCControlItem.esriTOCControlItemLayer)) { m_layer = layer; } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button != 2) { return; } rightMenu(); esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemMap) { this.axTOCControl1.SelectItem(map, null); } else if (item == esriTOCControlItem.esriTOCControlItemLayer) { this.axTOCControl1.SelectItem(layer, null); } axMapControl1.CustomProperty = layer; if (item == esriTOCControlItem.esriTOCControlItemMap) { System.Windows.MessageBox.Show("点击了Layers"); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { pToolMenuLayer.PopupMenu(e.x, e.y, this.axTOCControl1.hWnd); } }
private void 图层下移ToolStripMenuItem_Click(object sender, EventArgs e) { esriTOCControlItem pTocItem = new esriTOCControlItem(); ILayer pLayer = new FeatureLayerClass(); IBasicMap pBasicMap = new MapClass(); object obj1 = new object(); object obj2 = new object(); axTOCControl1.GetSelectedItem(ref pTocItem, ref pBasicMap, ref pLayer, ref obj1, ref obj2); if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer) { int iIndex; for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++) { if (axMapControl1.get_Layer(iIndex) == pLayer) { if (iIndex == axMapControl1.LayerCount - 1) { break; } axMapControl1.MoveLayerTo(iIndex, iIndex + 1); break; } } } }
private void TOCLayer_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) { if (e.button != 1) { return; } esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; IBasicMap pBasicMap = null; ILayer pLayer = null; object unk = null; object data = null; TOCLayer.HitTest(e.x, e.y, ref itemType, ref pBasicMap, ref pLayer, ref unk, ref data); if (e.button == 1) { if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data); FrmSymbolSelect SymbolSelectorFrm = new FrmSymbolSelect(pLegendClass, pLayer); if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK) { m_MapMain.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); pLegendClass.Symbol = SymbolSelectorFrm.pSymbol; m_MapMain.ActiveView.Refresh(); TOCLayer.Refresh(); } } } }
private void AxTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap pMap = null; ILayer pLayer = null; object legendgp = null; object index = null; esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index); //点击测试,点击图例打开符号选择器 if (e.button == 1) { ILegendGroup pLegendGroup = new LegendGroup(); ILegendClass pLegendClass = new LegendClass(); pLegendGroup = (ILegendGroup)legendgp; if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass) { pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString())); if (pLegendClass == null) { return; } FormSymbolSelector dlg = new FormSymbolSelector(pLegendClass, pLayer); if (dlg != null) { dlg.ShowDialog(); m_pTocControl.Update(); m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } } } }
private void axTOCControlLayerTree_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)//TOCC左键设置图例,右键弹出菜单 { esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; IBasicMap pMap = null; object unk = null, data = null; axTOCControlLayerTree.HitTest(e.x, e.y, ref pItem, ref pMap, ref _toccSelectedLayer, ref unk, ref data); if (e.button == 1) { if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass) { //取得图例 ILegendClass legendClass = ((ILegendGroup)unk).get_Class((int)data); var symbolSelectorForm = new SymbolSelectorDevForm(legendClass, _toccSelectedLayer); if (symbolSelectorForm.ShowDialog() == DialogResult.OK) { GoToMapView(); legendClass.Symbol = symbolSelectorForm.PSymbol; //设置新的符号 axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); //更新主Map控件和图层控件 } _effectLayer.SwipeLayer = _toccSelectedLayer; } } else if (e.button == 2) { if (pItem == esriTOCControlItem.esriTOCControlItemLayer) { cMenuStripTocc.Show(axTOCControlLayerTree, new System.Drawing.Point(e.x, e.y)); ShowFieldLabelMenuItems(_toccSelectedLayer); } } }
private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e)//双击legend修改symbol { ILayer pLayer = null; IBasicMap pBasicMap = null; object plegendGroup = null; object pIndex = null; esriTOCControlItem pTocItem = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref plegendGroup, ref pIndex); if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendClass legendClass = (plegendGroup as ILegendGroup).get_Class((int)pIndex); if (!((pLayer is IRasterLayer && (pLayer as IRasterLayer).Renderer is IRasterStretchColorRampRenderer) || (pLayer is IFeatureLayer && (pLayer as IGeoFeatureLayer).Renderer is IProportionalSymbolRenderer))) { ISymbolSelector selector = new SymbolSelectorClass(); selector.AddSymbol(legendClass.Symbol); if (selector.SelectSymbol(0) == true) { legendClass.Symbol = selector.GetSymbolAt(0); } axMapControl1.Refresh(); axTOCControl1.Update(); } } }
private void TocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; object other = null; object index = null; IBasicMap map = null; ILayer layer = null; CurTOCControl = (sender as AxTOCControl).Object as ITOCControl2; //返回点后的指定的对象 CurTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //如果点中的图例,则弹出符号设置窗口 if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLegendClass)) { //暂不支持 } else if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLayer)) { object obj = m_MapLayersController.GetLayerParent(layer); if (obj is ICompositeLayer) { ILayer pParentLayer = (ILayer)obj; bool b = layer.Visible; if (b == false) { pParentLayer.Visible = true; } } } else if (e.button == 2) //鼠标右键 { switch (item) { case esriTOCControlItem.esriTOCControlItemNone: break; case esriTOCControlItem.esriTOCControlItemMap: CurTOCControl.SelectItem(map, null); this.popMenuTOCMap.ShowPopup(MousePosition); break; case esriTOCControlItem.esriTOCControlItemLegendClass: break; case esriTOCControlItem.esriTOCControlItemLayer: m_CurrentSelectLayer = layer; CurTOCControl.SelectItem(layer, null); popMenuTOCLayer.ShowPopup(MousePosition); // new System.Drawing.Point(e.x, e.y)); break; case esriTOCControlItem.esriTOCControlItemHeading: break; } CurActivityMapControl.CustomProperty = layer; } CurTOCControl = null; }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)//事件图层列表框(TOCControl)的右键弹出框 { if (e.button == 2) { ILayer pLayer = null; IBasicMap pBasicMap = null; object plegendGroup = null; object pIndex = null; esriTOCControlItem pTocItem = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref plegendGroup, ref pIndex); selectLayerIndex = Convert.ToInt16(pIndex); Console.WriteLine(selectLayerIndex); if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer) { if (pLayer != null) { selectLayer = pLayer; } popupMenu1.ShowPopup(axTOCControl1.PointToScreen(new System.Drawing.Point(e.x, e.y))); } else if (pTocItem == esriTOCControlItem.esriTOCControlItemMap) { popupMenu2.ShowPopup(axTOCControl1.PointToScreen(new System.Drawing.Point(e.x, e.y))); } } }
private void axTOOControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { ///右键打开菜单项 try { if (e.button == 1) { return; } esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; IBasicMap pMap = null; ILayer Lyr = null; object unk = null; object data = null; this.axTOOControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref Lyr, ref unk, ref data); if (pItem == esriTOCControlItem.esriTOCControlItemLayer && (Lyr as IFeatureLayer) != null) { this.LyrContxtMenuStrip.Show(MousePosition); } if (pItem == esriTOCControlItem.esriTOCControlItemMap) { this.MapMenuStrip.Show(MousePosition); } featureLyr = Lyr as IFeatureLayer; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void axTOCControl1_OnMouseUp(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseUpEvent e) { if (e.button == 2) { IBasicMap map = null; ILayer layer = null; object other = null; object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemLayer) { if (layer is IAnnotationSublayer) { _curLayer = null; } else { _curLayer = layer; } } else { _curLayer = null; } PopupContextMenu(e.x, e.y); } }
public void SelectMoveLayer(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 1) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; m_TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemLayer) { if (layer is IAnnotationSublayer) { return; } else { m_MoveLayer = layer; } } } }
public static ILayer GetLayerFromTOCControl(AxTOCControl _axTOCControl) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object legendGroup = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); _axTOCControl.GetSelectedItem(ref item, ref map, ref layer, ref legendGroup, ref index); return layer; }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap map = null;//实现TOC的右键快捷菜单 object other = null; object index = null; esriTOCControlItem item = new esriTOCControlItem(); this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref m_layer, ref other, ref index); if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer) { this.OpenAttribute.Enabled = false; this.ClearAttribute.Enabled = false; this.SelectBand.Enabled = false; if (m_layer is IFeatureLayer) { this.OpenAttribute.Enabled = true; this.ClearAttribute.Enabled = true; } else { this.SelectBand.Enabled = true; } System.Drawing.Point point = new System.Drawing.Point(e.x, e.y); this.conMenuTOC.Show(axTOCControl1, point); } }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { //Exit if not right mouse button if (e.button != 2) return; IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new Object(); object index = new Object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) return; IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) return; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer) geoFeatureLayer.Renderer; //Create the form with the SymbologyControl frmSymbol symbolForm = new frmSymbol(); //Get the IStyleGalleryItem IStyleGalleryItem styleGalleryItem = null; //Select SymbologyStyleClass based upon feature type switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols, simpleRenderer.Symbol); break; } //Release the form symbolForm.Dispose(); this.Activate(); if (styleGalleryItem == null) return; //Create a new renderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol) styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; //Fire contents changed event that the TOCControl listens to axPageLayoutControl1.ActiveView.ContentsChanged(); //Refresh the display axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); try { axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); } catch (Exception eX) { MessageBox.Show(eX.Message); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { if (layer != null) { this.setCurrentLayer(layer); } } } }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (axMapControl1.LayerCount > 0) { esriTOCControlItem pItem = new esriTOCControlItem(); pGlobalFeatureLayer = new FeatureLayerClass(); IBasicMap pBasicMap = new MapClass(); object pOther = new object(); object pIndex = new object(); axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pGlobalFeatureLayer, ref pOther, ref pIndex); } if (e.button == 2) { context.Show(axTOCControl1, e.x, e.y); } }
private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) { IBasicMap map = null;//设置要素符号 object other = null; object index = null; esriTOCControlItem item = new esriTOCControlItem(); this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref m_layer, ref other, ref index); if (item == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendGroup legendGroup = other as ILegendGroup; ILegendClass legendClass = legendGroup.get_Class(Convert.ToInt32(index)); ISymbol symbol = legendClass.Symbol; ISymbolSelector pSS = new SymbolSelectorClass(); pSS.AddSymbol(symbol); Boolean bOK = pSS.SelectSymbol(0); if (bOK == true) { legendClass.Symbol = pSS.GetSymbolAt(0); } axTOCControl1.Update(); this.mapCtlMain.Refresh(); } }