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; //判断所选菜单的类型 m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //确定选定的菜单类型,Map或是图层菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { m_tocControl.SelectItem(map, null); m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd); } else { m_tocControl.SelectItem(layer, null); //添加 打开属性表 m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); //移除OpenAttributeTable菜单项,以防止重复添加 m_menuLayer.Remove(2); } }
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; //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemLayer) { //动态添加OpenAttributeTable菜单项 m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new UpdateAreaPrimeter(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); //移除OpenAttributeTable菜单项,以防止重复添加 m_menuLayer.Remove(1); m_menuLayer.Remove(1); } }
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; //判断所选菜单的类型 m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //确定选定的菜单类型,Map或是图层菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { m_tocControl.SelectItem(map, null); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_tocControl.SelectItem(layer, null); } //设置CustomPropety为layer(用于自定义的Layer命令) m_mapControl.CustomProperty = layer; //弹出右键菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd); } else if (item == esriTOCControlItem.esriTOCControlItemLayer) { //动态添加OpenAttributeTable菜单项 m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); //移除OpenAttributeTable菜单项,以防止重复添加 m_menuLayer.Remove(2); } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //如果不是右键按下直接返回 if (e.button != 2) { return; } if (e.button == 2) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; RightMenu rtMenu = new RightMenu(axTOCControl1); IToolbarMenu m_meunLayer = rtMenu.getToolbarMenu(); m_meunLayer.SetHook(m_mapControl); //判断所选菜单的类型 rtMenu.m_TocC.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //确定选定的菜单类型,Map 或是图层菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { rtMenu.m_TocC.SelectItem(map, null); } else { rtMenu.m_TocC.SelectItem(layer, null); } //设置CustomProperty 为layer (用于自定义的Layer 命令) m_mapControl.CustomProperty = layer; if (item == esriTOCControlItem.esriTOCControlItemLayer) { //动态添加ShowAttributeTable菜单项 m_meunLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_meunLayer.PopupMenu(e.x, e.y, rtMenu.m_TocC.hWnd); //移除OpenAttributeTable菜单项,以防止重复添加 m_meunLayer.Remove(2); } } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { esriTOCControlItem item = new esriTOCControlItem(); IBasicMap pMap = null; ILayer pLayer = new FeatureLayer(); object pOther = new object(); object pIndex = new object(); //获取鼠标点击信息 axTOCControl1.HitTest(e.x, e.y, ref item, ref pMap, ref pLayer, ref pOther, ref pIndex); if (e.button == 2) { if (item == esriTOCControlItem.esriTOCControlItemMap) { pTocControl.SelectItem(pMap, null); } else { pTocControl.SelectItem(pLayer, null); } //设置CustomProperty为layer (用于自定义的Layer命令) pMapControl.CustomProperty = pLayer; //弹出右键菜单 if (item == esriTOCControlItem.esriTOCControlItemLayer) { //动态添加OpenAttributeTable菜单项 pToolMenuLayer.AddItem(new OpenAttribute(pLayer, pMapControl, axMapControl1), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd); //移除OpenAttributeTable菜单项,以防止重复添加 pToolMenuLayer.Remove(2); } if (item == esriTOCControlItem.esriTOCControlItemMap) { pToolMenuMap.PopupMenu(e.x, e.y, pTocControl.hWnd); } else { pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd); } } esriTOCControlItem item1 = esriTOCControlItem.esriTOCControlItemNone; if (e.button == 1) { IBasicMap map = null; ILayer layer = null; object other = null; object index = null; m_TOCControl.HitTest(e.x, e.y, ref item1, ref map, ref layer, ref other, ref index); if (item1 == esriTOCControlItem.esriTOCControlItemLayer) { if (layer is IAnnotationSublayer) { return; } else { pMoveLayer = layer; } } } }
private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e) { int m_reszEng;//返回鼠标位置 IPoint m_point = m_pageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); m_origenalElement = m_element; if (e.button == 1) { getElement(e.pageX, e.pageY); if (e.pageX < -0.03 || e.pageY < -0.03 || e.pageX > 29.71 || e.pageY > 29.71) { m_element = null; } if (m_element != null) { m_selectionTracker = m_element.SelectionTracker; if (m_element is IFrameElement || m_element is ITextElement) { m_reszEng = Convert.ToInt32(m_selectionTracker.HitTest(m_point)); // 测试点击的位置,并获得位置值 if (m_reszEng == 0 || m_reszEng == 1 || m_element is ITextElement) //当鼠标在选中元素的中间部位时 { m_selectionTracker = null; m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSize; //设置鼠标样式为移动元素样式 } else if (m_reszEng == 2 || m_reszEng == 3 || m_reszEng == 4 || m_reszEng == 5 || m_reszEng == 6 || m_reszEng == 7 || m_reszEng == 8 || m_reszEng == 9) { m_reszEng = m_reszEng - 2; if (m_reszEng == 4 || m_reszEng == 3) { m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeWE;//设置鼠标样式 用来改变元素大小 } if (m_reszEng == 2 || m_reszEng == 5) { m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNESW; } if (m_reszEng == 1 || m_reszEng == 6) { m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNS; } if (m_reszEng == 0 || m_reszEng == 7) { m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNWSE; } m_resizeEnvelopeFeedback = new ResizeEnvelopeFeedbackClass(); m_resizeEnvelopeFeedback.Display = m_pageLayoutControl.ActiveView.ScreenDisplay; //设置Display m_resizeEnvelopeFeedback.ResizeEdge = (esriEnvelopeEdge)m_reszEng; //设置改变大小时,需要移动的边 m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsNone; m_resizeEnvelopeFeedback.Start(m_element.Geometry.Envelope, m_point); //设置移动的启动位置 // m_resizeEnvelopeFeedback.MoveTo(m_point); } } } if (m_element == null && m_origenalElement != null)//当没有选中元素时,将原来选择的元素跟踪包络线隐藏 { m_selectionTracker = m_origenalElement.SelectionTracker; m_selectionTracker.Deactivate();//隐藏包络线 } } #region //右击 if (e.button == 2) //右击鼠标 { if (m_resizeEnvelopeFeedback != null) { m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsSquare; } #region // 右键菜单 m_menuPageLayout.AddItem(new DeleteElement(m_pageLayoutControl, m_element), -1, 7, false, esriCommandStyles.esriCommandStyleIconOnly); //删除选中元素 m_menuPageLayout.AddItem(new ChangeFrameBackGround(m_element, m_pageLayoutControl), 8, 8, false, esriCommandStyles.esriCommandStyleIconOnly); //设置背景 m_menuPageLayout.AddItem(new ChangeFrameShadow(m_element, m_pageLayoutControl), 9, 9, false, esriCommandStyles.esriCommandStyleIconOnly); //设置阴影 m_menuPageLayout.AddItem(new ChangeFrameBorder(m_element, m_pageLayoutControl), 10, 10, false, esriCommandStyles.esriCommandStyleIconOnly); //设置边框 m_menuPageLayout.AddItem(new CmdExoprtMapAsPicture(), 11, 11, false, esriCommandStyles.esriCommandStyleIconOnly); m_menuPageLayout.PopupMenu(e.x, e.y, m_pageLayoutControl.hWnd); m_menuPageLayout.Remove(11); m_menuPageLayout.Remove(10); m_menuPageLayout.Remove(9); m_menuPageLayout.Remove(8); m_menuPageLayout.Remove(7); #endregion } #endregion }