private void Mainwindow_Load(object sender, System.EventArgs e)
        {
            // 取得 MapControl 和 PageLayoutControl 的引用
            pTocControl = (ITOCControl2)axTOCControl1.Object;
            pMapControl = (IMapControl3)axMapControl1.Object;

            // 创建菜单
            pToolMenuMap   = new ToolbarMenuClass();
            pToolMenuLayer = new ToolbarMenuClass();
            pToolMenuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new RemoveLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.SetHook(pMapControl);

            ISpatialReferenceFactory srFact = new SpatialReferenceEnvironmentClass();///

            gcs = srFact.CreateGeographicCoordinateSystem(4214);
            axMapControl1.MapScale = 4000000;
            axMapControl2.MapScale = 125000000;
            // axMapControl2.
            IDisplayTransformationScales DTS = axMapControl2.ActiveView.ScreenDisplay.DisplayTransformation as IDisplayTransformationScales;

            DTS.RemoveAllUserScales();
            DTS.AddUserScale(125000000);
            DTS.ScaleSnapping = esriScaleSnapping.esriUserScaleSnapping;
        }
        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);
        }
        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);
        }
示例#4
0
        private void MatchMain_Load(object sender, EventArgs e)
        {
            sMapUnits           = "未知单位";
            m_mapControl        = (IMapControl3)this.axMapControl1.Object;
            m_pageLayoutControl = (IPageLayoutControl2)this.axPageLayoutControl1.Object;
            m_tocControl        = (ITOCControl2)this.axTOCControl1.Object;
            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.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);
        }
示例#5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no file yet)
            menuSaveFile.Enabled = false;

            // 取得 MapControl 和 PageLayoutControl 的引用
            pTocControl = (ITOCControl2)axTOCControl1.Object;
            pMapControl = (IMapControl3)axMapControl1.Object;
            // 创建菜单
            pToolMenuMap   = new ToolbarMenu();
            pToolMenuLayer = new ToolbarMenu();
            //添加菜单项
            pToolMenuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new RemoveLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);


            //设置菜单的hook
            pToolMenuLayer.SetHook(pMapControl);

            m_TOCControl = this.axTOCControl1.Object as ITOCControl;

            //Set buddy control
            axToolbarControl1.SetBuddyControl(axMapControl1);
            axToolbarControl2.SetBuddyControl(axMapControl1);
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            //Set buddy control
            axToolbarControl1.SetBuddyControl(axMapControl1);

            //Create UID's and add new items to the ToolbarControl
            UID uID = new UIDClass();

            uID.Value = "esriControls.ControlsOpenDocCommand";
            axToolbarControl1.AddItem(uID, -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText);
            uID.Value = "esriControls.ControlsMapZoomInTool";
            axToolbarControl1.AddItem(uID, -1, -1, true, -1, esriCommandStyles.esriCommandStyleIconAndText);
            uID.Value = "esriControls.ControlsMapZoomOutTool";
            axToolbarControl1.AddItem(uID, -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText);
            uID.Value = "esriControls.ControlsMapPanTool";
            axToolbarControl1.AddItem(uID, -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText);
            uID.Value = "esriControls.ControlsMapFullExtentCommand";
            axToolbarControl1.AddItem(uID, -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText);

            //Create a MenuDef object
            IMenuDef menuDef = new NavigationMenu();

            //Create a ToolbarMenu
            m_navigationMenu.AddItem(menuDef, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //Set the ToolbarMenu's hook
            m_navigationMenu.SetHook(axToolbarControl1.Object);
            //Set the ToolbarMenu's caption
            m_navigationMenu.Caption = "Navigation";
        }
示例#7
0
        private void MainFrom_Load(object sender, EventArgs e)
        {
            //将地图控件赋给变量,这样就可以使用接口所暴露的属性和方法了
            //axMapControl1属于主框架的私有控件,外部不能访问,所以采用这种模式可以通过公共变量的形式操作
            m_mapControl  = (IMapControl3)axMapControl1.Object;
            m_pTocControl = (ITOCControl2)axTOCControl1.Object;

            toolComboBox = this.toolStripComboBox2;
            //TOC控件绑定地图控件
            m_pTocControl.SetBuddyControl(m_mapControl);
            //pCurrentTOC = m_pTocControl;
            //构造地图右键菜单
            mapMenu = new ToolbarMenuClass();
            mapMenu.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            mapMenu.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //构造图层右键菜单
            layerMenu = new ToolbarMenuClass();
            //添加“移除图层”菜单项
            layerMenu.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            //添加“放大到整个图层”菜单项
            layerMenu.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            //右键菜单绑定
            mapMenu.SetHook(m_mapControl);
            layerMenu.SetHook(m_mapControl);
            // IMap map = MapUtil.OpenMap(Common.MapPath);
            MapUtil.LoadMxd(this.axMapControl1, Common.MapPath);
            ClearNoData();
            //SetInitialRouteNetLayerStyle();
        }
示例#8
0
        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);
        }
示例#9
0
 private void CreateMapPopupMenu()
 {
     toolbarMenu = new ToolbarMenuClass();
     toolbarMenu.SetHook(_mapControl);
     //toolbarMenu.AddItem(new CmdClearEmptyLayerFromMap(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
     toolbarMenu.AddItem(new CommandRemoveAllLayers(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
 }
示例#10
0
        public MainGIS()
        {
            InitializeComponent();
            //设置图层控件的同步控件
            axTOCControl.SetBuddyControl(axMapControl);
            //初始化公共变量
            _mapControl        = axMapControl.Object as IMapControlDefault;
            _pageLayoutControl = axPageLayoutControl.Object as IPageLayoutControlDefault;
            _tocControl        = axTOCControl.Object as ITOCControlDefault;
            _DataSet           = new DataSet();
            //初始化主框架
            _App                   = new NBGIS.PluginEngine.Application();
            _App.StatusBar         = this.uiStatusBar;
            _App.MapControl        = _mapControl;
            _App.PageLayoutControl = _pageLayoutControl;
            _App.MainPlatfrom      = this;
            _App.Caption           = this.Text;
            _App.Visible           = this.Visible;
            _App.CurrentTool       = null;
            _App.MainDataSet       = _DataSet;

            //让MapControl和PageLatoutControl保存同步
            m_controlsSynchronizer = new ControlsSynchronizer(_mapControl, _pageLayoutControl);
            m_controlsSynchronizer.BindControls(true);
            m_controlsSynchronizer.AddFrameWorkControl(axTOCControl.Object);

            //TOCControl的esriTOOControlItemMap被右键点击后弹出的快捷菜单
            _mapMenu = new ToolbarMenuClass();
            _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.SetHook(this._mapControl);
        }
示例#11
0
        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;
            //
        }
示例#12
0
        //初始化函数
        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
        }
示例#13
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            //获取用户权限
            CommonClass common = new CommonClass();
            string      user   = common.GetConfigValue("USER");
            ConnectDB   db     = new ConnectDB();
            DataTable   dt     = db.GetDataBySql("select * from GISDATA_USER WHERE USER ='******'");
            DataRow     dr     = dt.Select(null)[0];
            string      ROLE   = dr["ROLE"].ToString();

            if (ROLE == "超级管理员")
            {
                this.用户管理ToolStripMenuItem.Visible = true;
                this.报表设计ToolStripMenuItem.Visible = true;
                this.任务管理ToolStripMenuItem.Visible = true;
                this.质检配置ToolStripMenuItem.Visible = true;
                this.字典管理ToolStripMenuItem.Visible = true;
                this.数据注册ToolStripMenuItem.Visible = true;
            }
            else
            {
                this.用户管理ToolStripMenuItem.Visible = false;
                this.报表设计ToolStripMenuItem.Visible = false;
                this.任务管理ToolStripMenuItem.Visible = false;
                this.质检配置ToolStripMenuItem.Visible = false;
                this.字典管理ToolStripMenuItem.Visible = false;
                this.数据注册ToolStripMenuItem.Visible = false;
            }
            try
            {
                //在Form1_Load函数进行初始化,即菜单的创建:
                m_menuMap = new ToolbarMenuClass();
                //添加自定义菜单项到TOCCOntrol的图层菜单中
                m_menuLayer = new ToolbarMenuClass();

                m_tocControl = (ITOCControl2)this.axTOCControl1.Object;
                // 取得 MapControl 和 PageLayoutControl 的引用
                m_mapControl = (IMapControl3)this.axMapControl1.Object;

                //这样就可以把AxMapControl传递给其它要用到的地方
                //添加“移除图层”菜单项
                m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                //添加“放大到整个图层”菜单项
                m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                //查看属性表
                m_menuLayer.AddItem(new OpenAttribute(this.axMapControl1), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                //设置菜单的Hook
                m_menuLayer.SetHook(m_mapControl);
                m_menuMap.SetHook(m_mapControl);
                m_hookHelper.Hook = this.axMapControl1.Object;
            }catch (Exception exc)
            {
                LogHelper.WriteLog(typeof(FormMain), exc);
            }
        }
示例#14
0
        public frmPrintByAnyRegion(IMap pMap, IGeometry pGeometry, string txtTitle, string txtName, string txtProj, string txtTime, string textElevation, string textOtherInfo)
        //bool  checkBLengend ,bool  checkBNorthA ,bool  checkBMapG ,bool  checkBScaleB ,bool  checkBText )
        {
            InitializeComponent();
            m_pageLayoutControl = this.axPageLayoutControl1.Object as IPageLayoutControlDefault;
            m_Map           = pMap;
            m_Geometry      = pGeometry;
            m_textTitle     = txtTitle;      //标题
            m_textName      = txtName;       //制作人姓名
            m_textProject   = txtProj;       //投影系统
            m_textDate      = txtTime;       //时间
            m_textElevation = textElevation; //高程系统
            m_textOtherInfo = textOtherInfo;

            #region  PageLayout的右键菜单
            m_menuPageLayout = new ToolbarMenuClass();
            m_menuPageLayout.AddItem(new ControlsPageZoomInToolClass(), 1, 0,
                                     false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomOutToolClass(), 2, 1,
                                     false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPagePanToolClass(), 3, 2, false,
                                     esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomWholePageCommandClass(), 4,
                                     3, false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomOutFixedCommandClass(), 5, 4,
                                     false, esriCommandStyles.esriCommandStyleIconOnly);
            //Add PageLayOUTControl navigation commands.
            m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentBackCommandClass(), 6, 5,
                                     false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentForwardCommandClass(), 7, 6,
                                     false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.SetHook(m_pageLayoutControl);

            #endregion
            this.axPageLayoutControl1.LoadMxFile(System.Windows.Forms.Application.StartupPath + @"\pagelayoutTemplate\海域图.mxt", Type.Missing);
            SetMapFrame();

            //产生一个地图容器IMaps对象
            IMaps maps = new Maps();
            maps.Add(m_Map);
            m_pageLayoutControl.PageLayout.ReplaceMaps(maps);

            if (m_Map.MapUnits == esriUnits.esriUnknownUnits)
            {
                m_Map.MapUnits      = esriUnits.esriMeters;
                m_Map.DistanceUnits = esriUnits.esriMeters;
            }
            m_mapScale = m_Map.MapScale;

            axPageLayoutControl1.ActiveView.Refresh();
            axPageLayoutControl1.ActiveView.ShowScrollBars = true;
            InitializePrintPreviewDialog();
            printDialog1 = new PrintDialog();
            InitializePageSetupDialog();
        }
示例#15
0
 private void BindRightMenu()                                                                                            //添加右键菜单
 {
     m_ToolbarMenu.AddItem(new FixeZoomIn(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);                   //地图放大
     m_ToolbarMenu.AddItem(new FixeZoomOut(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);                  //地图缩小
     m_ToolbarMenu.AddItem(new FullExtent(), 1, 2, false, esriCommandStyles.esriCommandStyleTextOnly);                   //显示全图
     m_ToolbarMenu.AddItem(new PanClass(), 1, 3, false, esriCommandStyles.esriCommandStyleTextOnly);                     //地图平移
     m_ToolbarMenu.AddItem(new Measuredis(), 1, 4, false, esriCommandStyles.esriCommandStyleTextOnly);                   //地图测量
     m_ToolbarMenu.AddItem(new PrintPage(axMapControl1), 1, 5, false, esriCommandStyles.esriCommandStyleTextOnly);       //地图打印
     m_ToolbarMenu.AddItem(new ExportImg(axMapControl1, this), 1, 6, false, esriCommandStyles.esriCommandStyleTextOnly); //导成图片
     m_ToolbarMenu.SetHook(axMapControl1);
 }
示例#16
0
 private void rightMenu()
 {
     // 取得 MapControl 和 PageLayoutControl 的引用
     ///  pTocControl = (ITOCControl2)axTOCControl1.Object;
     pMapControl = (IMapControl3)axMapControl1.Object;
     // 创建菜单
     ///pToolMenuMap = new ToolbarMenuClass();
     pToolMenuLayer = new ToolbarMenuClass();
     pToolMenuLayer.AddItem(new MapTableCommand(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new LayerScaleCommand(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.SetHook(pMapControl);
 }
示例#17
0
文件: MainForm.cs 项目: jzChia/demo
        private void Initialize()
        {
            xtraTabControl1.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
            xtraTabControl2.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;

            m_mapControl = (IMapControl3)axMapControl1.Object;

            #region 命令按钮初始化
            m_pMapPanTool             = new ControlsMapPanTool() as ITool;
            m_pMapZoomInTool          = new ControlsMapZoomInTool() as ITool;
            m_pMapZoomOutTool         = new ControlsMapZoomOutTool() as ITool;
            m_pMapFullExtentCommand   = new ControlsMapFullExtentCommand() as ICommand;
            m_pMapFixedZoomInCommand  = new ControlsMapZoomInFixedCommand() as ICommand;
            m_pMapFixedZoomOutCommand = new ControlsMapZoomOutFixedCommand() as ICommand;
            m_pMapPreExtentCommand    = new ControlsMapZoomToLastExtentForwardCommand() as ICommand;
            m_pMapNextExtentCommand   = new ControlsMapZoomToLastExtentBackCommand() as ICommand;
            m_pMapRefreshCommand      = new ControlsMapRefreshViewCommand() as ICommand;
            m_pMapAddDataCommand      = new ControlsAddDataCommand() as ICommand;
            #endregion

            #region TOC右键菜单
            m_pTOCLayerMenu = new ToolbarMenu() as IToolbarMenu;
            m_pTOCLayerMenu.AddItem(new TOCTools.RemoveLayerCommand(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_pTOCLayerMenu.AddItem(new TOCTools.ZoomToLayerCommand(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_pTOCLayerMenu.AddItem(new TOCTools.LayerPropertiesCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_pTOCLayerMenu.SetHook(m_mapControl);

            m_pTOCMapMenu = new ToolbarMenu() as IToolbarMenu;
            m_pTOCMapMenu.AddItem(new TOCTools.TOCLayersVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_pTOCMapMenu.AddItem(new TOCTools.TOCLayersVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_pTOCMapMenu.SetHook(m_mapControl);
            #endregion

            axTOCControl1.SetBuddyControl(m_mapControl);
            m_mapControl.Map.Name = "图层";
            axTOCControl2.SetBuddyControl(axPageLayoutControl1);

            IPrincipal _principal = System.Threading.Thread.CurrentPrincipal;

            if (_principal.Identity.IsAuthenticated)
            {
                CurrentUser cu = (CurrentUser)_principal;
                MessageBox.Show("您已经登录,当前用户:" + _principal.Identity.Name + "     权限  " + cu.GetGetRight() + "---" + cu.GetQueryRight() + "\t\r\n" +
                                "当前角色:" + (_principal.IsInRole("管理员") ? "管理员" : "非管理员"));
            }
            else
            {
                MessageBox.Show("您还没有登录");
            }

            transferTaskListControl1.Initialize();
        }
        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);
        }
示例#19
0
文件: MainForm.cs 项目: arcpad/epsgis
        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);
        }
示例#20
0
        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;
        }
示例#21
0
        public void OnCreate(IApplication hook)
        {
            if (hook != null)
            {
                this.hk = hook;

                _layerMenu  = new ToolbarMenuClass();
                _rightMenu1 = new PageRightBtnMenu(this.hk.PageLayoutControl);
                _rightMenu2 = new PageRightBtnMenu(this.hk.PageLayoutControl);
                _layerMenu.AddItem(_rightMenu1, 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                _layerMenu.AddItem(_rightMenu2, 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                _layerMenu.SetHook(this.hk.PageLayoutControl);
            }
        }
示例#22
0
        private void Main_Form_Load(object sender, EventArgs e)
        {
            TOCControl.SetBuddyControl(MapControl.Object);
            m_pToolbarMenu = new ToolbarMenuClass();
            m_pToolbarMenu.SetHook(MapControl.Object);
            m_pToolbarMenu.AddItem(new Analysis_GeneralTools.ToolbarMenuItems.SelectAll.C_SelectAll(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_pToolbarMenu.AddItem(new Analysis_GeneralTools.ToolbarMenuItems.UnSelectAll.Cmd_UnSelectAll(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_pToolbarMenu.AddItem(new Analysis_GeneralTools.ToolbarMenuItems.AddData.Cmd_AddLayer(), -1, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_pToolbarMenu.AddItem(new Analysis_GeneralTools.ToolbarMenuItems.DeleteLayer.Cmd_DeleteLayer(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            // m_pToolbarMenu.AddItem(new Analysis_GeneralTools.ToolbarMenuItems.ShowAttributeTable.Cmd_AttributeTable(), -1, -1, true, esriCommandStyles.esriCommandStyleIconAndText);


            bar2.Text = "لیست لایه های مکانی";
        }
示例#23
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl        = (IMapControl3)axMapControl1.Object;
            m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object;

            menuSaveDoc.Enabled = false;

            basicToolbarControl.AddItem(new CreateNewDocument(), 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //TOCControl图层右键菜单
            m_TocLayerMenu.AddItem(new OpenAttributeTableCmd(), 0, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.AddItem(new RemoveLayerCmd(), 0, 1, false, esriCommandStyles.esriCommandStyleIconAndText);

            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ZoomToLayerCmd(), 0, 7, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.AddItem(new LayerPropertiesCmd(), 0, 8, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.SetHook(axMapControl1);

            //TOCControlMap右键菜单
            m_TocMapMenu.AddItem(new ControlsAddDataCommandClass(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOnCmd(), 0, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOffCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new SetReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new ClearReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new ZoomToReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.SetHook(axMapControl1);

            //axMapControl控件中右键菜单
            m_toolbarMenu.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new ClearFeatureSelection(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new ZoomIn3X(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new Refresh(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            // m_toolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_toolbarMenu.SetHook(axMapControl1);

            //axPageLayoutControl右键菜单
            m_toolbarMenu2.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu2.SetHook(m_pageLayoutControl);

            CreateCustomizeDialog();

            SetupNetworkAnalysis();
        }
示例#24
0
        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 HookActions_Load(object sender, EventArgs e)
        {
            //Add generic commands 
            axToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            //Add map navigation commands
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add generic commands 
            axToolbarControl2.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            //Add globe navigation commands
            axToolbarControl2.AddItem("esriControls.ControlsGlobeZoomInOutTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobePanDragTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobeFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobeSelectFeaturesTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Create menu 
             m_ToolbarMenu1 = new ToolbarMenuClass();
            //Set hook and command pool
            m_ToolbarMenu1.SetHook(axToolbarControl1);
            m_ToolbarMenu1.CommandPool = axToolbarControl1.CommandPool;
            //Add custom commands
            m_ToolbarMenu1.AddItem(new hookActionsPan(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsZoom(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsFlash(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsGraphic(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsLabel(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsCallout(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);

            //Create menu 
            m_ToolbarMenu2 = new ToolbarMenuClass();
            //Set hook and command pool
            m_ToolbarMenu2.SetHook(axToolbarControl2);
            m_ToolbarMenu2.CommandPool = axToolbarControl2.CommandPool;
            //Add custom commands
            m_ToolbarMenu2.AddItem(new hookActionsPan(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsZoom(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsFlash(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsGraphic(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsLabel(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsCallout(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);

        }
示例#26
0
        private void HookActions_Load(object sender, EventArgs e)
        {
            //Add generic commands
            axToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            //Add map navigation commands
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add generic commands
            axToolbarControl2.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            //Add globe navigation commands
            axToolbarControl2.AddItem("esriControls.ControlsGlobeZoomInOutTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobePanDragTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobeFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl2.AddItem("esriControls.ControlsGlobeSelectFeaturesTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Create menu
            m_ToolbarMenu1 = new ToolbarMenuClass();
            //Set hook and command pool
            m_ToolbarMenu1.SetHook(axToolbarControl1);
            m_ToolbarMenu1.CommandPool = axToolbarControl1.CommandPool;
            //Add custom commands
            m_ToolbarMenu1.AddItem(new hookActionsPan(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsZoom(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsFlash(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsGraphic(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsLabel(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu1.AddItem(new hookActionsCallout(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);

            //Create menu
            m_ToolbarMenu2 = new ToolbarMenuClass();
            //Set hook and command pool
            m_ToolbarMenu2.SetHook(axToolbarControl2);
            m_ToolbarMenu2.CommandPool = axToolbarControl2.CommandPool;
            //Add custom commands
            m_ToolbarMenu2.AddItem(new hookActionsPan(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsZoom(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsFlash(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsGraphic(), 0, -1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsLabel(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_ToolbarMenu2.AddItem(new hookActionsCallout(), 0, -1, false, esriCommandStyles.esriCommandStyleTextOnly);
        }
示例#27
0
        //TOCControl打开属性表
        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;

            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(axMapControl1, null);
                }
                else
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }

                //将该图层设置为地图控件的自定义属性;
                axMapControl1.CustomProperty = pLayer;
                //弹出右键菜单
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_pMenuMap = new ToolbarMenuClass();
                    m_pMenuMap.AddItem(new OpenAttribute(pLayer), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuMap.SetHook(axMapControl1);
                    m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;
            }
        }
 //加载主界面
 private void MainForm_Load(object sender, EventArgs e)
 {
     this.axMapControl1.Map.Name = "Map"; //修改初始地图名为Map3的bug
     string strInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
     #region     //右键功能相关设置--添加功能项
     pTocControl = (ITOCControl2)axTOCControl1.Object;
     pMapControl = (IMapControl3)axMapControl1.Object;
     pToolMenuMap = new ToolbarMenuClass(); 
     pToolMenuLayer = new ToolbarMenuClass();
     pToolMenuLayer.AddItem(new RemoveLayerCommand(), 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new OpenAttributeCommand(this.axMapControl1), 0, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ZoomToLayerCommand(), 0, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 1, 3, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 2, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 3, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new LayerSelectableCommand(), 1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.SetHook(pMapControl);
     #endregion
 }
示例#29
0
        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);
                }
            }
        }
示例#30
0
        //加载主界面
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.axMapControl1.Map.Name = "Map"; //修改初始地图名为Map3的bug
            string strInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;

            #region     //右键功能相关设置--添加功能项
            pTocControl    = (ITOCControl2)axTOCControl1.Object;
            pMapControl    = (IMapControl3)axMapControl1.Object;
            pToolMenuMap   = new ToolbarMenuClass();
            pToolMenuLayer = new ToolbarMenuClass();
            pToolMenuLayer.AddItem(new RemoveLayerCommand(), 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new OpenAttributeCommand(this.axMapControl1), 0, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new ZoomToLayerCommand(), 0, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 1, 3, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 2, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 3, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new LayerSelectableCommand(), 1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.SetHook(pMapControl);
            #endregion
        }
示例#31
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;
            activeView   = m_mapControl.ActiveView;
            LayerMenu.SetHook(m_mapControl);
            LayerMenu.AddItem(new ZoomToLayer(), 0, 0, false, esriCommandStyles.esriCommandStyleIconAndText);

            //打开两张影像。
            if (BaseMap != null && TopMap != null)
            {
                topRasterLayer.CreateFromFilePath(TopMap);
                axMapControl1.AddLayer(topRasterLayer, 0);
                baseRasterLayer.CreateFromFilePath(BaseMap);
                axMapControl1.AddLayer(baseRasterLayer, 1);
                geoReference           = topRasterLayer as IGeoReference;
                this.Text              = "正在配准:" + System.IO.Path.GetFileName(TopMap) + " -> " + System.IO.Path.GetFileName(BaseMap);
                TransparencyLabel.Text = "顶层透明度:" + TransparencyTrackBar.Value.ToString() + "%";
            }
        }
示例#32
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            axMapControl1.LoadMxFile(SystemSet.Base_Map + "\\基础底图.mxd", 0, Type.Missing);
            //axMapControl1.LoadMxFile(@"D:\各种结课作业\地籍测量\地块拓展.mxd", 0, Type.Missing);
            //axMapControl1.AddShapeFile(@"I:\四平项目\实验数据", "东丰县行政区域");
            m_menuMap   = new ToolbarMenuClass();
            m_menuLayer = new ToolbarMenuClass();
            p_menuLayer = new ToolbarMenuClass();

            p_menuLayer.AddItem(new AddName(this.axPageLayoutControl1), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddLegend(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddNorthArrow(this.axPageLayoutControl1), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddScal(this.axPageLayoutControl1), -1, 3, true, esriCommandStyles.esriCommandStyleTextOnly);
            //打开文档菜单
            // m_menuMap.AddItem(new GISTools(AddData), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            //刷新
            m_menuMap.AddItem(new refresh(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            //

            //添加数据菜单
            //m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new addData(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //全局显示
            //m_menuMap.AddItem(new ControlsMapFullExtentCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new fullExtent(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
            //移动
            //m_menuMap.AddItem(new ControlsMapPanToolClass(), 1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new pan(), 2, 3, false, esriCommandStyles.esriCommandStyleIconAndText);
            //移除图层菜单
            m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            //放大到整个图层
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.SetHook((IMapControl3)this.axMapControl1.Object);
            m_menuMap.SetHook((IMapControl3)this.axMapControl1.Object);
            axTOCControl1.SetBuddyControl(axMapControl1);
            // axTOCControl1.SetBuddyControl(axMapControl2);
        }
示例#33
0
        /// <summary>
        /// 初始化地图及其图层/表格控制、鹰眼图、导航工具的组合控件
        /// </summary>
        public MapViewer()
        {
            InitializeComponent();
            MxdLaoder               = new MapDocLoader(axMapControlMainMap, axPageLayoutControl);
            _measureTool            = new MeasureTools(axMapControlMainMap);
            measureResultLabel.Text = "";
            _layer2FieldsMenuItems  = new Dictionary <string, ToolStripMenuItem[]>();
            LayerRemoved            = (obj, evt) =>
            {
                if (_attributeForm != null && !_attributeForm.IsDisposed && _attributeForm.FeatLayer != null)
                {
                    _attributeForm.Clear();
                }
            };
            MapActiveViewEvents = axMapControlMainMap.Map as IActiveViewEvents_Event;
            //向map/PageLayout中添加数据,包括图层、表格等都会触发ItemAdded事件
            MapActiveViewEvents.ItemAdded += (item) =>
            {
                if (item is ILayer layer)
                {
                    LayerAdded?.Invoke(layer, new EventArgs());
                    GoToMapView();
                    GotoLayerToc();
                }
                else if (item is ITable table)
                {
                    this.tableListBox1.AddTable(table);
                    GoToMapView();
                    GotoTableListBox();
                }
            };

            _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(axMapControlMainMap.Object);
        }
示例#34
0
        private IToolbarMenu _menuLayer = null; //�һ�Layer

        #endregion Fields

        #region Methods

        public void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e,AxMapControl pAxMapControl)
        {
            pTocControlDef = ((AxTOCControl)sender).Object as ITOCControlDefault;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;
            pTocControlDef.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //ȷ������Ŀ��ѡ��
            if (item == esriTOCControlItem.esriTOCControlItemMap)
                pTocControlDef.SelectItem(map, null);
            else
                pTocControlDef.SelectItem(layer, null);

            //������Ҽ����,�����˵�
            if (e.button == 2)
            {
                //ѡ�����Map
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    _mapMenu = new ToolbarMenuClass();
                    _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _mapMenu.SetHook(pAxMapControl);
                    _mapMenu.PopupMenu(e.x, e.y, pTocControlDef.hWnd);
                }
                else if (item == esriTOCControlItem.esriTOCControlItemLayer) //ѡ����� Layer
                {
                    _menuLayer = new ToolbarMenuClass();
                    _menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new OpenAttributeTable(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    //_menuLayer.AddItem(new LayerProperty(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);

                    //Set the hook of each menu
                    pTocControlDef.SelectItem(layer, null);
                    _menuLayer.SetHook(pAxMapControl);
                    //Set the layer into the CustomProperty (this is used by the custom layer commands)
                    pAxMapControl.CustomProperty = layer;
                    //�����˵�
                    _menuLayer.PopupMenu(e.x, e.y, pTocControlDef.hWnd);
                }
            }
            if (e.button == 1)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer) return;
                    else
                    {
                        //pmovelayer = layer;
                    }
                }
            }
        }
示例#35
0
        //bool  checkBLengend ,bool  checkBNorthA ,bool  checkBMapG ,bool  checkBScaleB ,bool  checkBText )
        public frmPrintByAnyRegion(IMap pMap,IGeometry pGeometry,string  txtTitle ,string  txtName ,string  txtProj ,string  txtTime ,string textElevation,string textOtherInfo)
        {
            InitializeComponent();
            m_pageLayoutControl = this.axPageLayoutControl1.Object as IPageLayoutControlDefault;
            m_Map = pMap;
            m_Geometry = pGeometry;
            m_textTitle = txtTitle;//����
            m_textName = txtName;//����������
            m_textProject = txtProj;//ͶӰϵͳ
            m_textDate = txtTime;//ʱ��
            m_textElevation = textElevation;//�߳�ϵͳ
            m_textOtherInfo = textOtherInfo;

            #region  PageLayout���Ҽ��˵�
            m_menuPageLayout = new ToolbarMenuClass();
            m_menuPageLayout.AddItem(new ControlsPageZoomInToolClass(), 1, 0,
                false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomOutToolClass(), 2, 1,
                false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPagePanToolClass(), 3, 2, false,
                 esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomWholePageCommandClass(), 4,
               3, false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomOutFixedCommandClass(), 5, 4,
                false, esriCommandStyles.esriCommandStyleIconOnly);
            //Add PageLayOUTControl navigation commands.
            m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentBackCommandClass(), 6, 5,
              false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentForwardCommandClass(), 7, 6,
               false, esriCommandStyles.esriCommandStyleIconOnly);
            m_menuPageLayout.SetHook(m_pageLayoutControl);

            #endregion
            this.axPageLayoutControl1.LoadMxFile(System.Windows.Forms.Application.StartupPath + @"\pagelayoutTemplate\����ͼ.mxt", Type.Missing);
            SetMapFrame();

            //����һ����ͼ����IMaps����
            IMaps maps = new Maps();
            maps.Add(m_Map);
            m_pageLayoutControl.PageLayout.ReplaceMaps(maps);

            if (m_Map.MapUnits == esriUnits.esriUnknownUnits)
            {
                m_Map.MapUnits = esriUnits.esriMeters;
                m_Map.DistanceUnits = esriUnits.esriMeters;
            }
            m_mapScale = m_Map.MapScale;

            axPageLayoutControl1.ActiveView.Refresh();
            axPageLayoutControl1.ActiveView.ShowScrollBars = true;
            InitializePrintPreviewDialog();
            printDialog1 = new PrintDialog();
            InitializePageSetupDialog();
        }
		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);
		}
示例#37
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            axMapControl1.LoadMxFile(SystemSet.Base_Map + "\\基础底图.mxd", 0, Type.Missing);
            //axMapControl1.LoadMxFile(@"D:\各种结课作业\地籍测量\地块拓展.mxd", 0, Type.Missing);
            //axMapControl1.AddShapeFile(@"I:\四平项目\实验数据", "东丰县行政区域");
            m_menuMap = new ToolbarMenuClass();
            m_menuLayer = new ToolbarMenuClass();
            p_menuLayer = new ToolbarMenuClass();

            p_menuLayer.AddItem(new AddName(this.axPageLayoutControl1), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddLegend(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddNorthArrow(this.axPageLayoutControl1), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);

            p_menuLayer.AddItem(new AddScal(this.axPageLayoutControl1), -1, 3, true, esriCommandStyles.esriCommandStyleTextOnly);
            //打开文档菜单
               // m_menuMap.AddItem(new GISTools(AddData), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            //刷新
            m_menuMap.AddItem(new refresh(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            //

            //添加数据菜单
            //m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new addData(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //全局显示
            //m_menuMap.AddItem(new ControlsMapFullExtentCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new fullExtent(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
            //移动
            //m_menuMap.AddItem(new ControlsMapPanToolClass(), 1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuMap.AddItem(new pan(), 2, 3, false, esriCommandStyles.esriCommandStyleIconAndText);
            //移除图层菜单
            m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            //放大到整个图层
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.SetHook((IMapControl3)this.axMapControl1.Object);
            m_menuMap.SetHook((IMapControl3)this.axMapControl1.Object);
            axTOCControl1.SetBuddyControl(axMapControl1);
               // axTOCControl1.SetBuddyControl(axMapControl2);
        }
示例#38
0
        public MainGIS()
        {
            InitializeComponent();

            //设置图层控件的同步控件
            this.axTOCControl1.SetBuddyControl(this.axMapControl1.Object);

            //初始化公共变量
            _mapControl = axMapControl1.Object as IMapControlDefault;
            _pageLayoutControl = axPageLayoutControl1.Object as IPageLayoutControlDefault;
            _tocControl = axTOCControl1.Object as ITOCControlDefault;
            _DataSet = new DataSet();

            //初始化主框架
            _App = new MyPluginEngine.Application();
            _App.StatusBar = this.uiStatusBar;
            _App.MapControl = _mapControl;
            _App.PageLayoutControl = _pageLayoutControl;
            _App.TOCControl = _tocControl;
            _App.MainPlatfrom = this;
            _App.Caption = this.Text;
            _App.Visible = this.Visible;
            _App.CurrentTool = null;
            _App.MainDataSet = _DataSet;

            //让MapControl和PageLatoutControl保存同步
            axTOCControl1.SetBuddyControl(_mapControl);
            m_controlsSynchronizer = new ControlsSynchronizer(_mapControl, _pageLayoutControl);

            //在同步是同时设置好与TOCControl和ToolBarControl的buddy
            m_controlsSynchronizer.AddFrameWorkControl(axTOCControl1.Object);
            m_controlsSynchronizer.AddFrameWorkControl(axToolbarControl1.Object);

            m_controlsSynchronizer.BindControls(true);

            //TOCControl的esriTOOControlItemMap被右键点击后弹出的快捷菜单
            _mapMenu = new ToolbarMenuClass();
            //通过自己的 MapMent进行添加功能,这里只有两个功能
            _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //使用 uid
            //IUID uid = new UIDClass();
            //uid.Value = "esriControlCommands.ControlsMapFullExtent";
            //_mapMenu.AddItem(uid, -1, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.AddItem(new ControlsMapFindCommand(), -1, 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            //使用 progid
            string progid = "esriControlCommands.ControlsMapViewMenu";
            _mapMenu.AddItem(progid, -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //使用内置 Command
            _mapMenu.AddItem(new ControlsAddDataCommand(), -1 , 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.SetHook(this._mapControl);

            //2015/7/17
            //TOCControl的esriTOOControlItemLayer被右键点击后弹出的快捷菜单
            _layerMenu = new ToolbarMenuClass();
            // 分别为缩放至图层、删除图层、打开属性表   +
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 3, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.SetHook(this._mapControl);
        }
		private void frmMain_Load(object sender, System.EventArgs e)
		{
			// Add commands to the NALayer context menu
			m_menuLayer = new ToolbarMenuClass();

			int nItem = -1;
			m_menuLayer.AddItem(new cmdLoadLocations(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly);
			m_menuLayer.AddItem(new cmdRemoveLayer(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly);
			m_menuLayer.AddItem(new cmdClearAnalysisLayer(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly);
			m_menuLayer.AddItem(new cmdNALayerProperties(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly);

			// Since this ToolbarMenu is a standalone popup menu use the SetHook method to
			//  specify the object that will be sent as a "hook" to the menu commands in their OnCreate methods.
			m_menuLayer.SetHook(axMapControl1);

			// Add command for ArcGIS Network Analyst extension env properties to end of "Network Analyst" dropdown menu
			nItem = -1;
			for (int i = 0; i < axToolbarControl1.Count; ++i)
			{
				IToolbarItem item = axToolbarControl1.GetItem(i);
				IToolbarMenu mnu = item.Menu;

				if (mnu == null) continue;

				IMenuDef mnudef = mnu.GetMenuDef();
				string name = mnudef.Name;

				// Find the ArcGIS Network Analyst extension solver menu drop down and note the index
				if (name == "ControlToolsNetworkAnalyst_SolverMenu")
				{
					nItem = i;
					//break;
				}
			}

			if (nItem >= 0)
			{
				// Using the index found above, get the solver menu drop down and add the Properties command to the end of it.
				IToolbarItem item = axToolbarControl1.GetItem(nItem);
				IToolbarMenu mnu = item.Menu;
				if (mnu != null)
					mnu.AddItem(new cmdNAProperties(), -1, mnu.Count, true, esriCommandStyles.esriCommandStyleTextOnly);

				// Since this ToolbarMenu is an item on the ToolbarControl the Hook is shared and initialized by the ToolbarControl.
				//  Therefore, SetHook is not called here, like it is for the menu above.
			}

			// Initialize naEnv variables
			m_naEnv = CommonFunctions.GetTheEngineNetworkAnalystEnvironment();
			if (m_naEnv == null)
			{
				MessageBox.Show("Error: EngineNetworkAnalystEnvironment is not properly configured");
				return;
			}

			m_naEnv.ZoomToResultAfterSolve = false;
			m_naEnv.ShowAnalysisMessagesAfterSolve = (int)(esriEngineNAMessageType.esriEngineNAMessageTypeInformative | 
														   esriEngineNAMessageType.esriEngineNAMessageTypeWarning);

			// Set up the buddy control and initialize the NA extension, so we can get to NAWindow to listen to window events.
			// This is necessary, as the various controls are not yet set up. They need to be in order to get the NAWindow's events.
			axToolbarControl1.SetBuddyControl(axMapControl1);
			IExtension ext = m_naEnv as IExtension;
			object obj = axToolbarControl1.Object;
			
			ext.Startup(ref obj);
			
			// m_naWindow is set after Startup of the Network Analyst extension
			m_naWindow = m_naEnv.NAWindow;
			if (m_naWindow == null)
			{
				MessageBox.Show("Error: Unexpected null NAWindow");
				return;
			}

			m_onContextMenu = new IEngineNAWindowEventsEx_OnContextMenuEventHandler(OnContextMenu);
			((IEngineNAWindowEventsEx_Event)m_naWindow).OnContextMenu += m_onContextMenu;

            m_OnNetworkLayersChanged = new IEngineNetworkAnalystEnvironmentEvents_OnNetworkLayersChangedEventHandler(OnNetworkLayersChanged);
            ((IEngineNetworkAnalystEnvironmentEvents_Event)m_naEnv).OnNetworkLayersChanged += m_OnNetworkLayersChanged;

            m_OnCurrentNetworkLayerChanged = new IEngineNetworkAnalystEnvironmentEvents_OnCurrentNetworkLayerChangedEventHandler(OnCurrentNetworkLayerChanged);
            ((IEngineNetworkAnalystEnvironmentEvents_Event)m_naEnv).OnCurrentNetworkLayerChanged += m_OnCurrentNetworkLayerChanged;
		}
示例#40
0
 //PageLayout右键菜单
 private void PageLayoutToolBarInit()
 {
     m_menuPageLayout = new ToolbarMenuClass();
     m_menuPageLayout.AddItem(new ControlsPageZoomInToolClass(), 1, 0,false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPageZoomOutToolClass(), 2, 1,false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPagePanToolClass(), 3, 2, false,esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPageZoomWholePageCommandClass(), 4,3, false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPageZoomOutFixedCommandClass(), 5, 4,false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentBackCommandClass(), 6, 5,false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.AddItem(new ControlsPageZoomPageToLastExtentForwardCommandClass(), 7, 6,false, esriCommandStyles.esriCommandStyleIconOnly);
     m_menuPageLayout.SetHook(m_pageLayoutControl);
 }