Beispiel #1
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            //Set buddy control
            axToolbarControl1.SetBuddyControl(axMapControl1);

            //Add command items to the ToolbarControl
            axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);

            //Create a new ToolbarMenu
            IToolbarMenu2 toolbarMenu = new ToolbarMenuClass();

            //Set a caption
            toolbarMenu.Caption = "Spatial Bookmarks";
            //Add the custom command to the ToolbarMenu
            toolbarMenu.AddItem(new CreateBookmark(), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //Add the custom multiitem to the ToolbarMenu
            toolbarMenu.AddMultiItem(new SpatialBookmarks(), -1, true, esriCommandStyles.esriCommandStyleTextOnly);

            //Add the menu item to the ToolbarControl
            axToolbarControl1.AddItem(toolbarMenu, -1, -1, true, 0, esriCommandStyles.esriCommandStyleMenuBar);
        }
        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);
        }
Beispiel #3
0
 /// <summary>
 /// 地图控件的常用右键菜单
 /// </summary>
 /// <param name="mapCtrl"></param>
 public MapCtrlMenu(AxMapControl mapCtrl)
 {
     MapControl  = mapCtrl;
     ToolBarMenu = new ToolbarMenuClass(); //工具栏菜单类
     ToolBarMenu.AddItem(new ControlsMapViewMenuClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
     ToolBarMenu.AddItem(new ControlsMapPanToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
     ToolBarMenu.AddItem(new ControlsMapZoomOutToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
     ToolBarMenu.AddItem(new ControlsMapZoomInToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
     ToolBarMenu.SetHook(MapControl.Object);
     MapControl.OnMouseDown += (sender, e) =>
     {
         if (e.button == 2)
         {
             ToolBarMenu.PopupMenu(e.x, e.y, MapControl.hWnd);
         }
     };
 }
        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);
        }
Beispiel #5
0
        /// <summary>
        /// Form load event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                //reference existing map ctrl and toc ctrl
                getSetTocControl = (ITOCControl2)axTOCControl1.Object;
                getSetMapControl = (IMapControl3)axMapControl1.Object;

                //Set buddy control
                getSetTocControl.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
                getSetMenuMap = new ToolbarMenuClass();
                getSetMenuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                //Add pre-defined menu to the map menu as a sub menu
                getSetMenuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true);
                //Add custom commands to the map menu
                getSetMenuLayer = new ToolbarMenuClass();
                getSetMenuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);

                //Add Open attribute table command
                getSetMenuLayer.AddItem(new OpenAttributeTable(getSetTocControl), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly);

                //Set the hook of each menu
                getSetMenuLayer.SetHook(getSetMapControl);
                getSetMenuMap.SetHook(getSetMapControl);
            }
            catch (COMException COMex)
            {
                MessageBox.Show("Error " + COMex.ErrorCode.ToString() + ": " + COMex.Message);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Beispiel #6
0
        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 Form1_Load(object sender, System.EventArgs e)
		{
			//Set buddy control
			axToolbarControl1.SetBuddyControl(axMapControl1);
			
			//Add command items to the ToolbarControl
			axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
			axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);
			axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
			axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
			axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand",-1 , -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
			
			//Create a new ToolbarMenu 
			IToolbarMenu2 toolbarMenu = new ToolbarMenuClass();
			
			//Set a caption
			toolbarMenu.Caption = "Spatial Bookmarks";
			//Add the custom command to the ToolbarMenu
			toolbarMenu.AddItem(new CreateBookmark(), -1, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
			//Add the custom multiitem to the ToolbarMenu
			toolbarMenu.AddMultiItem(new SpatialBookmarks(), -1, true, esriCommandStyles.esriCommandStyleTextOnly);
			
			//Add the menu item to the ToolbarControl
			axToolbarControl1.AddItem(toolbarMenu, -1, -1, true, 0, esriCommandStyles.esriCommandStyleMenuBar);
			
		}