public DataTable attributeTable; //AttributeTableFrm类成员变量 private void MyMapContext_Load(object sender, EventArgs e) { //首先初始化右键菜单 m_tocControl = this.axTOCControl1.Object as ITOCControl2;//获取TOCC引用 m_menuMap = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); m_mapControl = (IMapControl3)_mainFrm.axMapControl1.Object; //取得MapControl的引用 //添加自定义菜单项到TOCCOntrol的Map菜单中 //打开文档菜单 m_menuMap.AddItem(new ControlsOpenDocCommandClass(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); //添加数据菜单 m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText); //打开全部图层菜单 m_menuMap.AddItem(new LayerVisibility(1), 1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); //关闭全部图层菜单 m_menuMap.AddItem(new LayerVisibility(2), 1, 3, false, esriCommandStyles.esriCommandStyleIconAndText); //以二级菜单的形式添加内置的“选择”菜单 m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 4, true); //以二级菜单的形式添加内置的“地图浏览”菜单 m_menuMap.AddSubMenu("esriControls.ControlsMapViewMenu", 5, true); //添加自定义菜单项到TOCCOntrol的图层菜单中 m_menuLayer = new ToolbarMenuClass(); //添加“移除图层”菜单项 m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //添加“放大到整个图层”菜单项 m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new Controls3DAnalystContourToolClass(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); //设置菜单的Hook m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
//初始化函数 public void Load() { #region 使用IToolbarMenu菜单 m_tocControl.OnMouseDown += new ITOCControlEvents_Ax_OnMouseDownEventHandler(m_tocControl_OnMouseDown); m_tocControl.OnDoubleClick += new ITOCControlEvents_Ax_OnDoubleClickEventHandler(m_tocControl_OnDoubleClick); m_menuLayer.SetHook((IMapControl3)m_mapControl.Object); m_menuMap.SetHook((IMapControl3)m_mapControl.Object); //添加数据菜单 m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); //打开全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); //关闭全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //以二级菜单的形式添加内置的“选择”菜单 m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 3, true); //以二级菜单的形式添加内置的“地图浏览”菜单 m_menuMap.AddSubMenu("esriControls.ControlsMapViewMenu", 4, true); #endregion #region 加载ContextMenu菜单项 //复制命令 string str = System.IO.Directory.GetParent(System.IO.Directory.GetParent(Application.StartupPath).FullName).FullName; iCopy.Click += new EventHandler(iCopy_Click); //移除图层 iRemoveLayer.Image = Image.FromFile(str + "\\Resources\\RemoveLayer.bmp"); //iRemoveLayer.Image=Image.FromFile(str+"\\RemoveLayer.bmp"); iRemoveLayer.Click += new EventHandler(iRemoveLayer_Click); //打开属性表 iOpenTable.Image = Image.FromFile(str + "\\Resources\\OpenAttributeTable.bmp"); //iOpenTable.Image=Image.FromFile(str+"\\OpenAttributeTable.bmp"); iOpenTable.Click += new EventHandler(iOpenTable_Click); //缩放至图层 iZoomToLayer.Image = Image.FromFile(str + "\\Resources\\ZoomToLayer.bmp"); //iZoomToLayer.Image=Image.FromFile(str+"\\ZoomToLayer.bmp"); iZoomToLayer.Click += new EventHandler(iZoomToLayer_Click); //缩放至可见 iVisible.Click += new EventHandler(iVisible_Click); //标注要素 iLabel.Click += new EventHandler(iLabel_Click); //数据 iData.Click += new EventHandler(iData_Click); //属性 iAttribute.Click += new EventHandler(iAttribute_Click); m_contextMemuLayer.Items.Add(iCopy); //0 m_contextMemuLayer.Items.Add(iRemoveLayer); //1 m_contextMemuLayer.Items.Add(iOpenTable); //2 m_contextMemuLayer.Items.Add(iZoomToLayer); //3 m_contextMemuLayer.Items.Add(iVisible); //4 m_contextMemuLayer.Items.Add(iLabel); //5 //m_contextMemuLayer.Items[5].Enabled = false; m_contextMemuLayer.Items.Add(iData); //6 m_contextMemuLayer.Items[6].Enabled = false; m_contextMemuLayer.Items.Add(iAttribute); //7 #endregion }
private void AeMap_Load(object sender, EventArgs e) { sMapUnits = "Unknown"; m_mapControl = (IMapControl3)this.axMapControl1.Object; m_pageLayoutControl = (IPageLayoutControl2)this.axPageLayoutControl1.Object; //初始化controls synchronization class m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //把MapControl和PageLayoutControl绑定起来(两个都指向同一个Map),然后设置MapControl为活动的Control m_controlsSynchronizer.BindControls(true); //为了在切换MapControl和PageLayoutControl视图同步,要添加Framework Control m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(this.axTOCControl1.Object); //添加打开命令按钮到工具条 OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); //初始化菜单创建 m_menuMap = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); //添加自定义菜单项到TOCCOntrol的Map菜单中 //打开文档菜单 m_menuMap.AddItem(new OpenNewMapDocument(m_controlsSynchronizer), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); //添加数据菜单 m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText); //打开全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //关闭全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); //以二级菜单的形式添加内置的“选择”菜单 m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 4, true); //以二级菜单的形式添加内置的“地图浏览”菜单 m_menuMap.AddSubMenu("esriControls.ControlsMapViewMenu", 5, true); //添加自定义菜单项到TOCControl的图层菜单中 m_menuLayer = new ToolbarMenuClass(); //添加“移除图层”菜单项 m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //添加“放大到整个图层”菜单项 m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); //设置菜单的Hook m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); m_tocControl = (ITOCControl2)this.axTOCControl1.Object; }
private void ContextMenu_Load(object sender, EventArgs e) { m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl1.SetBuddyControl(m_mapControl); //Add pre-defined control commands to the ToolbarControl axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Add custom commands to the map menu m_menuMap = new ToolbarMenuClass(); m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); //Add pre-defined menu to the map menu as a sub menu m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); //Add custom commands to the map menu m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly); //Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
private void MainForm_Load(object sender, EventArgs e) { // m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //设置控件的关联 axToolbarControl1.SetBuddyControl(axMapControl1); axTOCControl1.SetBuddyControl(axMapControl1); axTOCControl1.EnableLayerDragDrop = true; //设置钩子 map_hookHelper.Hook = this.axMapControl1.Object; //图层快捷菜单 m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //m_menuLayer.AddItem(new ExportToFGDB(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_submenuRender = new ToolbarMenuClass(); m_submenuRender.Caption = "渲染"; m_submenuRender.AddItem(new ClassBreakRender(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //Set the hook of each menu m_menuLayer.AddSubMenu(m_submenuRender, 1, true); m_menuLayer.AddItem(new LayerProperty(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.SetHook(m_mapControl); //加载分类码 loadcode(); axToolbarControl1.Enabled = true; //控制TOC控件中图层名称的修改 this.axTOCControl1.LabelEdit = esriTOCControlEdit.esriTOCControlManual; // }
private void ContextMenu_Load(object sender, EventArgs e) { m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl1.SetBuddyControl(m_mapControl); //Add pre-defined control commands to the ToolbarControl axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Add custom commands to the map menu m_menuMap = new ToolbarMenuClass(); m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); //Add pre-defined menu to the map menu as a sub menu m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); //Add custom commands to the map menu m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly); //Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
private void cmdAddSubMenu_Click(object sender, System.EventArgs e) { //Create a MenuDef object IMenuDef menuDef = new ToolbarSubMenu(); //Get the menu, which is the 6th item on the toolbar (indexing from 0) IToolbarItem toolbarItem = axToolbarControl1.GetItem(5); IToolbarMenu toolbarMenu = toolbarItem.Menu; //Add the sub-menu as the third item on the Navigation menu, making it start a new group toolbarMenu.AddSubMenu(menuDef, 2, true); cmdAddSubMenu.Enabled = false; }
private void MainForm_Load(object sender, EventArgs e) { //get the MapControl and tocControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control for tocControl m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl2.SetBuddyControl(m_mapControl); //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; axToolbarControl2.Select(); //Create a SchematicEditor's MenuDef object IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor(); //Add SchematicEditor on the ToolBarMenu m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); //Set the ToolbarMenu's hook m_CreateMenu.SetHook(axToolbarControl2.Object); //Set the ToolbarMenu's caption m_CreateMenu.Caption = "SchematicEditor"; /// Add ToolbarMenu on the ToolBarControl axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar); ///Create a other ToolbarMenu for layer m_menuSchematicLayer = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); ///Add 3 items on the SchematicLayer properties menu m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); IMenuDef subMenuDef = new CreateSubMenuSchematic(); m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true); ////Add the sub-menu as the third item on the Layer properties menu, making it start a new group m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); ////Set the hook of each menu m_menuSchematicLayer.SetHook(m_mapControl); m_menuLayer.SetHook(m_mapControl); }
private void MainForm_Load(object sender, EventArgs e) { //get a reference to the MapControl and the PageLayoutControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; m_pageLayoutControl = (IPageLayoutControl2)axPageLayoutControl1.Object; //initialize the controls synchronization class m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //bind the controls together (both point at the same map) and set the MapControl as the active control m_controlsSynchronizer.BindControls(true); //add the framework controls (TOC and Toolbars) in order to synchronize then when the //active control changes (call SetBuddyControl) m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(axTOCControl1.Object); //add the Open Map Document command onto the toolbar OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); //Add custom commands to the map menu m_menuMap = new ToolbarMenuClass(); m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new BufferAnalysis(), 3, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //Add pre-defined menu to the map menu as a sub menu m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); //Add custom commands to the map menu m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerRendering(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerProperties(), -1, 8, false, esriCommandStyles.esriCommandStyleTextOnly); axToolbarControl1.AddItem(new IdentifyTool(), -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
private void CreateGroupLayerPopupMenu() { toolbarMenu = new ToolbarMenuClass(); toolbarMenu.SetHook(_mapControl); toolbarMenu.AddItem(new CommandRemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); // toolbarMenu.AddItem(new CmdClearEmptyLayerFromGroupLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); IToolbarMenu subToolbarMenu = new ToolbarMenuClass { Caption = "移动图层" };; subToolbarMenu.AddItem(new CommandMoveLayerUp(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerDown(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerTop(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerBottom(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); toolbarMenu.AddSubMenu(subToolbarMenu, 2, false); }
private void CreatePopupMenu() { toolbarMenu = new ToolbarMenuClass(); toolbarMenu.AddItem(new CommandZoomToLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); toolbarMenu.AddItem(new CommandZoomToVisible(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); IToolbarMenu subToolbarMenu = new ToolbarMenuClass { Caption = "移动图层" };; subToolbarMenu.AddItem(new CommandMoveLayerUp(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerDown(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerTop(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); subToolbarMenu.AddItem(new CommandMoveLayerBottom(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); toolbarMenu.AddSubMenu(subToolbarMenu, 2, false); toolbarMenu.AddItem(new CommandRemoveLayer(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); // toolbarMenu.AddItem(new CommandLayerAttribute(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); //toolbarMenu.AddItem(new CommandLayerProperties(axTOCControl.Object as ITOCControl2), -1, 5, true, esriCommandStyles.esriCommandStyleTextOnly); toolbarMenu.SetHook(_mapControl); }
private void AddItemToContextMenu() { m_MapContextMenu = new ToolbarMenuClass(); m_MapContextMenu.AddItem(new SetLayerVisible(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_MapContextMenu.AddItem(new SetLayerVisible(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_MapContextMenu.AddItem(new ZoomToSelectedFeatures(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_MapContextMenu.SetHook(m_MapControl); m_SetScaleRangeContextMenu = new ToolbarMenuClass(); m_SetScaleRangeContextMenu.Caption = "设置比例尺"; m_SetScaleRangeContextMenu.AddItem(new SetScaleRange(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_SetScaleRangeContextMenu.AddItem(new SetScaleRange(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_SetScaleRangeContextMenu.AddItem(new SetScaleRange(), 3, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_LayerContextMenu = new ToolbarMenuClass(); m_LayerContextMenu.AddItem(new ZoomToLayer(), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly); m_LayerContextMenu.AddItem(new RemoveLayer(), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly); m_LayerContextMenu.AddItem(new OpenAttributeTable(m_MapControl), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly); m_LayerContextMenu.AddItem(new OpenFormLableByField(m_MapControl), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly); m_LayerContextMenu.AddSubMenu(m_SetScaleRangeContextMenu, 2, true); m_LayerContextMenu.SetHook(m_MapControl); }
private void MainForm_Load(object sender, EventArgs e) { // 设置标签编辑模式为手动 axTOCControl1.LabelEdit = ESRI.ArcGIS.Controls.esriTOCControlEdit.esriTOCControlManual; if (System.IO.File.Exists(PersistedItems) && LoadPersistedItems) { LoadToolbarControlItems(PersistedItems); } else { // 添加常规命令 axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsSelectTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); // 添加Map视图导航命令 axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", -1, - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem( "esriControls.ControlsMapZoomToLastExtentForwardCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // 添加Map视图查询命令 axToolbarControl1.AddItem("esriControls.ControlsMapIdentifyTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapFindCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapMeasureTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); } // 设置工具栏自定义对话框 CreateCustomizeDialog(); // 创建快捷菜单 mMapMenu = new ToolbarMenuClass(); mMapMenu.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); mMapMenu.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); mMapMenu.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); mMapMenu.SetHook(axMapControl1); mLayerMenu = new ToolbarMenuClass(); mLayerMenu.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //mLayerMenu.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); //mLayerMenu.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //mLayerMenu.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly); //mLayerMenu.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); //mLayerMenu.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly); mLayerMenu.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); mLayerMenu.AddItem(new OpenAttributeTable(), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); mLayerMenu.SetHook(axMapControl1); // 设定协同控件 axToolbarControl1.SetBuddyControl(axMapControl1); axTOCControl1.SetBuddyControl(axMapControl1); // 允许MapControl拦截方向键 axMapControl1.KeyIntercept = (int)esriKeyIntercept.esriKeyInterceptArrowKeys; axMapControl1.AutoKeyboardScrolling = true; axMapControl1.AutoMouseWheel = true; // 允许图层拖放 axTOCControl1.EnableLayerDragDrop = true; }
private void MainForm_Load(object sender, EventArgs e) { //get the MapControl and tocControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control for tocControl m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl2.SetBuddyControl(m_mapControl); //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; axToolbarControl2.Select(); //Create a SchematicEditor's MenuDef object IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor(); //Add SchematicEditor on the ToolBarMenu m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); //Set the ToolbarMenu's hook m_CreateMenu.SetHook(axToolbarControl2.Object); //Set the ToolbarMenu's caption m_CreateMenu.Caption = "SchematicEditor"; /// Add ToolbarMenu on the ToolBarControl axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar); ///Create a other ToolbarMenu for layer m_menuSchematicLayer = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); ///Add 3 items on the SchematicLayer properties menu m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); IMenuDef subMenuDef = new CreateSubMenuSchematic(); m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true); ////Add the sub-menu as the third item on the Layer properties menu, making it start a new group m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); ////Set the hook of each menu m_menuSchematicLayer.SetHook(m_mapControl); m_menuLayer.SetHook(m_mapControl); }