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 frmMain_Load(object sender, EventArgs e) { //绑定图层和工具条到map控件 this.axToolbarControl.SetBuddyControl(this.axMapControl); this.axTOCControl.SetBuddyControl(this.axMapControl); //控件填充 this.axMapControl.Dock = DockStyle.Fill; this.axMapControlEagle.Dock = DockStyle.Fill; this.axTOCControl.Dock = DockStyle.Fill; this.ucWorkFlow.Dock = DockStyle.Fill; //获取地图控件引用 m_tocControl = (ITOCControl2)axTOCControl.Object; m_mapControl = (IMapControl3)axMapControl.Object; m_toolBarControl = (IToolbarControl2)axToolbarControl.Object; CMDInitializer.Initialize(m_toolBarControl); //工具条列表 List <Bar> barList = new List <Bar>(); barList.Add(this.barTop); GFSApplication app = new GFSApplication(m_mapControl, (IMapControl3)axMapControlEagle.Object, m_tocControl, m_toolBarControl, this); app.Initialize(barList, appMenu, popupMenuFrame, popupMenulayer, popupMenuRGB, barEditItemLayer, staticSpt, staticXY, staticRaster, barBtnSwipe, barBtnEagleEye, dpEagle, listRecently, controlContainer1); if (Internet.IsConnectInternet()) { BaseMap.Add(BaseMapLayer.ChinaPoi); } }
private void ContextMenu_Load(object sender, EventArgs e) { m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl1.SetBuddyControl(m_mapControl); //Add pre-defined control commands to the ToolbarControl axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Add custom commands to the map menu m_menuMap = new ToolbarMenuClass(); m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); //Add pre-defined menu to the map menu as a sub menu m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); //Add custom commands to the map menu m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly); //Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
private void 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(); }
private void MainForm_Load(object sender, EventArgs e) { // m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //设置控件的关联 axToolbarControl1.SetBuddyControl(axMapControl1); axTOCControl1.SetBuddyControl(axMapControl1); axTOCControl1.EnableLayerDragDrop = true; //设置钩子 map_hookHelper.Hook = this.axMapControl1.Object; //图层快捷菜单 m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //m_menuLayer.AddItem(new ExportToFGDB(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_submenuRender = new ToolbarMenuClass(); m_submenuRender.Caption = "渲染"; m_submenuRender.AddItem(new ClassBreakRender(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //Set the hook of each menu m_menuLayer.AddSubMenu(m_submenuRender, 1, true); m_menuLayer.AddItem(new LayerProperty(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.SetHook(m_mapControl); //加载分类码 loadcode(); axToolbarControl1.Enabled = true; //控制TOC控件中图层名称的修改 this.axTOCControl1.LabelEdit = esriTOCControlEdit.esriTOCControlManual; // }
private void 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); }
public frmSymbology(IRasterLayer rasterLayer, IMapControl2 mainMap, ITOCControl2 mainToc) { InitializeComponent(); m_RasterLayer = rasterLayer; m_MainMap = mainMap; m_MainTOC = mainToc; }
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); }
/// <inheritdoc /> public LayerPropertiesCmd(ITOCControl2 mTocControl, ILayer pLayer, string name = "ͼ²ãÊôÐÔ(&P)") { base.m_caption = name; base.m_enabled = true; tocControl = mTocControl; currentLayer = pLayer; }
private void Form1_Load(object sender, EventArgs e) { axToolbarControl1.SetBuddyControl(axMapControl1); axMapControl1.Map.Name = "图层"; axTOCControl1.SetBuddyControl(axMapControl1); Func.CreateCustomizeDialog(); m_mapControl = (IMapControl3)axMapControl1.Object; m_pTocControl = (ITOCControl2)axTOCControl1.Object; }
public GLayersView() { InitializeComponent(); this._tocControl = (ITOCControl2)this.axTOCControl1.Object; this.axTOCControl1.EnableLayerDragDrop = true; _removeLayer = new RemoveLayerInToc(); _labelor = new Labelor(); //_layerSym = new FeatureLayerSymbology(); }
public void SetControls(IMapControl3 map, ITOCControl2 toc) { _mapControl = map; _tocControl = toc; _view.SetMapControl(_mapControl); _view.SetTocControl(_tocControl); //_thematic = new Thematic(_mapControl); //_thematic.SetTocControl(_tocControl); //_controller = new ThematicController(_thematic, _view); }
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); } }
/// <summary> /// Get Selected layer from table of contents /// </summary> /// <param name="iTOCControl2"> pass by ref the toccontol </param> /// <returns></returns> public ILayer getSelectedLayerInTOC(ITOCControl2 iTOCControl2) { try { return getIlayer(iTOCControl2); } catch (Exception) { throw; } }
private void MainForm_Load(object sender, EventArgs e) { //get a reference to the MapControl and the PageLayoutControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; m_pageLayoutControl = (IPageLayoutControl2)axPageLayoutControl1.Object; //initialize the controls synchronization class m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //bind the controls together (both point at the same map) and set the MapControl as the active control m_controlsSynchronizer.BindControls(true); //add the framework controls (TOC and Toolbars) in order to synchronize then when the //active control changes (call SetBuddyControl) m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(axTOCControl1.Object); //add the Open Map Document command onto the toolbar OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); //Add custom commands to the map menu m_menuMap = new ToolbarMenuClass(); m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new BufferAnalysis(), 3, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //Add pre-defined menu to the map menu as a sub menu m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true); //Add custom commands to the map menu m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerRendering(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerProperties(), -1, 8, false, esriCommandStyles.esriCommandStyleTextOnly); axToolbarControl1.AddItem(new IdentifyTool(), -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); }
private void MainForm_Load(object sender, EventArgs e) { //get the MapControl and tocControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control for tocControl m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl2.SetBuddyControl(m_mapControl); //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; axToolbarControl2.Select(); //Create a SchematicEditor's MenuDef object IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor(); //Add SchematicEditor on the ToolBarMenu m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); //Set the ToolbarMenu's hook m_CreateMenu.SetHook(axToolbarControl2.Object); //Set the ToolbarMenu's caption m_CreateMenu.Caption = "SchematicEditor"; /// Add ToolbarMenu on the ToolBarControl axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar); ///Create a other ToolbarMenu for layer m_menuSchematicLayer = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); ///Add 3 items on the SchematicLayer properties menu m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); IMenuDef subMenuDef = new CreateSubMenuSchematic(); m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true); ////Add the sub-menu as the third item on the Layer properties menu, making it start a new group m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); ////Set the hook of each menu m_menuSchematicLayer.SetHook(m_mapControl); m_menuLayer.SetHook(m_mapControl); }
private void AeMap_Load(object sender, EventArgs e) { sMapUnits = "Unknown"; m_mapControl = (IMapControl3)this.axMapControl1.Object; m_pageLayoutControl = (IPageLayoutControl2)this.axPageLayoutControl1.Object; //初始化controls synchronization class m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //把MapControl和PageLayoutControl绑定起来(两个都指向同一个Map),然后设置MapControl为活动的Control m_controlsSynchronizer.BindControls(true); //为了在切换MapControl和PageLayoutControl视图同步,要添加Framework Control m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(this.axTOCControl1.Object); //添加打开命令按钮到工具条 OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); //初始化菜单创建 m_menuMap = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); //添加自定义菜单项到TOCCOntrol的Map菜单中 //打开文档菜单 m_menuMap.AddItem(new OpenNewMapDocument(m_controlsSynchronizer), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); //添加数据菜单 m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText); //打开全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); //关闭全部图层菜单 m_menuMap.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); //以二级菜单的形式添加内置的“选择”菜单 m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 4, true); //以二级菜单的形式添加内置的“地图浏览”菜单 m_menuMap.AddSubMenu("esriControls.ControlsMapViewMenu", 5, true); //添加自定义菜单项到TOCControl的图层菜单中 m_menuLayer = new ToolbarMenuClass(); //添加“移除图层”菜单项 m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //添加“放大到整个图层”菜单项 m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); //设置菜单的Hook m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); m_tocControl = (ITOCControl2)this.axTOCControl1.Object; }
private void MainForm_Load(object sender, EventArgs e) { //get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; m_MenuTOC = new ToolbarMenuClass(); //添加自定义菜单项到TOCCOntrol的图层菜单中 m_MenuLayer = new ToolbarMenuClass(); m_TOCControl = (ITOCControl2)this.axTOCControl1.Object; m_MenuLayer.AddItem(new OpenAttributeTb(axMapControl1), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly); m_MenuLayer.SetHook(m_mapControl); m_MenuTOC.SetHook(m_mapControl); }
//加载主界面 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 }
/// <summary> /// 传递所有GIS控件和主窗体 /// </summary> /// <param name="mapControl">地图控件</param> /// <param name="mapControlEagle">鹰眼控件</param> /// <param name="tocControl">图层控件</param> /// <param name="toolbarControl">gis工具条</param> /// <param name="mainForm">主窗体</param> public GFSApplication(IMapControl3 mapControl, IMapControl3 mapControlEagle, ITOCControl2 tocControl, IToolbarControl2 toolbarControl, Form mainForm) { this._mapControl = mapControl; this._mapControlEagle = mapControlEagle; this._tocControl = tocControl; this._toolbarControl = toolbarControl; this._mainForm = mainForm; EnviVars.instance.MapControl = mapControl; EnviVars.instance.TOCControl = tocControl; EnviVars.instance.MainForm = mainForm; (mapControl as IMapControlEvents2_Event).OnMouseMove += new IMapControlEvents2_OnMouseMoveEventHandler(this.mapControl_OnMouseMove); (mapControl as IMapControlEvents2_Event).OnAfterScreenDraw += new IMapControlEvents2_OnAfterScreenDrawEventHandler(this.mapControl_OnAfterScreenDraw); (mapControl as IMapControlEvents2_Event).OnMouseDown += new IMapControlEvents2_OnMouseDownEventHandler(this.mapControl_OnMouseDown); (tocControl as ITOCControlEvents_Event).OnMouseDown += new ITOCControlEvents_OnMouseDownEventHandler(this.tocControl_OnMouseDown); (tocControl as ITOCControlEvents_Event).OnDoubleClick += new ITOCControlEvents_OnDoubleClickEventHandler(this.tocControl_OnDoubleClick); (tocControl as ITOCControlEvents_Event).OnBeginLabelEdit += new ITOCControlEvents_OnBeginLabelEditEventHandler(this.tocControl_OnBeginLabelEdit); (tocControl as ITOCControlEvents_Event).OnEndLabelEdit += new ITOCControlEvents_OnEndLabelEditEventHandler(this.tocControl_OnEndLabelEdit); mainForm.FormClosed += new FormClosedEventHandler(this.MainFormClosed); }
public static void RegisterCMD(BarButtonItem btn, IMapControl3 curMap, ITOCControl2 toc, string cmd) { try { if (cmd == "MaxClassCommand") { CommandUtility.RegisterCommand(new MaxClassCommand(btn, curMap, toc)); } else if (cmd == "CV1Commad") { CommandUtility.RegisterCommand(new CV1Commad(btn, curMap)); } else { XtraMessageBox.Show("未知命令!"); } } catch (Exception ex) { XtraMessageBox.Show("注册 MaxClassCommand失败:" + ex.Message); } }
private void frmMain_Load(object sender, EventArgs e) { //绑定图层和工具条到map控件 this.axToolbarControl.SetBuddyControl(this.axMapControl); this.axTOCControl.SetBuddyControl(this.axMapControl); //控件填充 this.axMapControl.Dock = DockStyle.Fill; this.axMapControlEagle.Dock = DockStyle.Fill; this.axTOCControl.Dock = DockStyle.Fill; this.ucWorkFlow.Dock = DockStyle.Fill; //获取地图控件引用 m_tocControl = (ITOCControl2)axTOCControl.Object; m_mapControl = (IMapControl3)axMapControl.Object; m_toolBarControl = (IToolbarControl2)axToolbarControl.Object; CMDInitializer.Initialize(m_toolBarControl); //工具条列表 List <Bar> barList = new List <Bar>(); barList.Add(this.barTop); GFSApplication app = new GFSApplication(m_mapControl, (IMapControl3)axMapControlEagle.Object, m_tocControl, m_toolBarControl, this); app.Initialize(barList, appMenu, popupMenuFrame, popupMenulayer, popupMenuRGB, barEditItemLayer, staticSpt, staticXY, staticRaster, barBtnSwipe, barBtnEagleEye, dpEagle, listRecently, controlContainer1); //BaseMap.Add(BaseMapLayer.ChinaPoi); if (Internet.IsConnectInternet()) { BaseMap.Add(BaseMapLayer.ChinaPoi); } //axMapControl.LoadMxFile(@"G:\高分统计项目一期\遥感所模块\SampleTestForm\测试数据\DataMap0.mxd"); //遥感所IDL模块初始化 GFS.Integration.Initialize.InitializeIDL(); GFS.Integration.Initialize.RegisterCMD(btnMaxClass, m_mapControl, m_tocControl, "MaxClassCommand"); GFS.Integration.Initialize.RegisterCMD(btnCV, m_mapControl, m_tocControl, "CV1Commad"); }
/// <summary> /// Overloaded OpenAttributeTable Constructor class /// </summary> /// <param name="iTOCControl2"> pass by reference the toc control</param> public OpenAttributeTable(ITOCControl2 iTOCControl2) { base.m_caption = "Open Attribute Table"; getSetITOCControl2 = iTOCControl2; }
public frmAutoLayer() { InitializeComponent(); _pMapControl = EnviVars.instance.MapControl; _pTOCControl = EnviVars.instance.TOCControl; }
//public event RaserLayerRendererEventHandler RaserLayerRenderer; public void InitializeLayer(IRasterLayer rasterLayer, IMapControl2 mainMap,ITOCControl2 mainToc) { m_RasterLayer = rasterLayer; m_MainMap = mainMap; m_MainTOC = mainToc; getMaxMinValue(m_RasterLayer); }
private void MainForm_Load(object sender, EventArgs e) { //Get Start up path to set a sample data path and path of temporary folder strPath = System.Windows.Forms.Application.StartupPath; axMapControl1.ActiveView.FocusMap.Name = "Layers"; //get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; lstRenderedLayers = new List <clsRenderedLayers>(); m_pSnippet = new clsSnippet(); try { //Load sample mxd //string filePath = strPath + @"\Sample.mxd"; //string filePath = strPath + @"\SampleData\Sample_plano.mxd";//For Plano //string filePath = strPath + @"\SampleData\Classification\Iowa_cnties.mxd";//For Iowa //if (axMapControl1.CheckMxFile(filePath)) // axMapControl1.LoadMxFile(filePath, Type.Missing, Type.Missing); //else // MessageBox.Show("Wrong direction"); ////Get Envelope of mxd //IActiveView pActiveView1 = axMapControl1.ActiveView.FocusMap as IActiveView; ////ILayer pLayer1 = pActiveView1.FocusMap.get_Layer(2); //ILayer pLayer1 = pActiveView1.FocusMap.get_Layer(0); ////adjust extent to fit a screen resolution //IFeatureLayer pFLayer1 = pLayer1 as IFeatureLayer; //IEnvelope envelope1 = new EnvelopeClass(); //envelope1.PutCoords(pFLayer1.AreaOfInterest.Envelope.XMin - (pFLayer1.AreaOfInterest.Envelope.XMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.YMin - (pFLayer1.AreaOfInterest.Envelope.YMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.XMax * 1.0005, pFLayer1.AreaOfInterest.Envelope.YMax * 1.0005); //axMapControl1.ActiveView.Extent = envelope1; //axMapControl1.ActiveView.Refresh(); } catch (Exception ex) { MessageBox.Show("Error 101: " + ex.Message); } try { //R environment setting #region Previous Methods //var envPath = Environment.GetEnvironmentVariable("PATH"); //var rBinPath = strPath + @"\R-3.1.2\bin\i386"; // R is copited into startup path //Environment.SetEnvironmentVariable("PATH", envPath + System.IO.Path.PathSeparator + rBinPath); ////Environment.SetEnvironmentVariable("PATH", rBinPath); //Not working //Environment.SetEnvironmentVariable("R_HOME", strPath + @"\R-3.1.2"); ////Loading REngine //pEngine = REngine.CreateInstance(strREngineName); //pEngine.Initialize(); ////string[] strRHOME = pEngine.Evaluate("R.home(component = 'home')").AsCharacter().ToArray(); //For Deburgging //LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray(); //string strLibPath = strPath.Replace(@"\", @"/") + "/R-3.1.2/library"; ////pEngine.Evaluate(".libPaths(" + strLibPath + ")"); ////pEngine.Evaluate(".libPaths(c(" + strLibPath + ", .Library.site, .Library))");//Same results with the above ////pEngine.Evaluate(".libPaths(c(" + strLibPath + "))");//Same results with the above //pEngine.Evaluate(".Library.site <- file.path('"+strLibPath+"')"); //Same results with the above //pEngine.Evaluate("Sys.setenv(R_LIBS_USER='******')"); ////string[] tempstring1 = pEngine.Evaluate("Sys.getenv('R_LIBS_USER')").AsCharacter().ToArray(); ////string[] tempstring = pEngine.Evaluate(".Library.site").AsCharacter().ToArray(); //pEngine.Evaluate(".libPaths(c('" + strLibPath + "', .Library.site, .Library))"); //LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray(); //pEngine.Evaluate("ip <- installed.packages()").AsCharacter(); //string[] installedPackages = pEngine.Evaluate("ip[,1]").AsCharacter().ToArray(); //To Check Installed Packages in R //clsRPackageNames pPckNames = new clsRPackageNames(); //blnsInstalledPcks = pPckNames.CheckedRequiredPackages(installedPackages); #endregion //Current version of R is 3.4.4 (03/19/18 HK) var envPath = Environment.GetEnvironmentVariable("PATH"); var rBinPath = strPath + @"\R-3.4.4\bin\i386"; // R is copited into startup path Environment.SetEnvironmentVariable("PATH", envPath + System.IO.Path.PathSeparator + rBinPath); Environment.SetEnvironmentVariable("R_HOME", strPath + @"\R-3.4.4"); //Loading REngine pEngine = REngine.CreateInstance(strREngineName); pEngine.Initialize(); //Set Library home and remove local home! LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray(); string strLibPath = strPath.Replace(@"\", @"/") + "/R-3.4.4/library"; //path for R packages pEngine.Evaluate(".Library.site <- file.path('" + strLibPath + "')"); pEngine.Evaluate("Sys.setenv(R_LIBS_USER='******')"); pEngine.Evaluate(".libPaths(c('" + strLibPath + "', .Library.site, .Library))"); //Checked installed packages and R LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray(); pEngine.Evaluate("ip <- installed.packages()").AsCharacter(); string[] installedPackages = pEngine.Evaluate("ip[,1]").AsCharacter().ToArray(); //To Check Installed Packages in R clsRPackageNames pPckNames = new clsRPackageNames(); blnsInstalledPcks = pPckNames.CheckedRequiredPackages(installedPackages); ////Installing Additional Package //Currently required pacakges:: MASS, geoR, car, spdep, maptools, deldir, rgeos, e1071 //package required for Testing: fpc //pEngine.Evaluate("install.packages('fpc')"); //pEngine.Evaluate("install.packages('e1071')"); } catch (Exception ex) { MessageBox.Show("Error 102:" + ex.Message); } try { //Toolbar Control, insert new tools here!! m_ToolbarControl = (IToolbarControl2)axToolbarControl1.Object; int intItemCounts = m_ToolbarControl.Count; m_ToolbarControl.AddItem(new toolDenPlot(), -1, intItemCounts, true, 0, esriCommandStyles.esriCommandStyleIconOnly); //Probability density plot tool //m_ToolbarControl.AddItem(new toolUncernFeature(), -1, intItemCounts+1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Remove now 07/31/15 m_ToolbarControl.AddItem(new ToolCumsum(), -1, intItemCounts + 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Empirical cumulative density function m_ToolbarControl.AddItem(new toolHistogram(), -1, intItemCounts + 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Histogram tool m_ToolbarControl.AddItem(new LinkingTool(), -1, intItemCounts + 3, true, 0, esriCommandStyles.esriCommandStyleIconOnly); // Histogram tool m_ToolbarControl.AddItem(new AddFeatureClass(), -1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Histogram tool } catch (Exception ex) { MessageBox.Show("Error 103: " + ex.Message); } try { //Loading Context menu at TOC m_tocControl = axTOCControl1.Object as ITOCControl2; m_tocControl.SetBuddyControl(m_mapControl); m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new OpenAttriTable(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToSelectedFeatures(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new SaveLayerFile(), -1, 4, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSymbology(), -1, 5, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerProperty(), -1, 6, false, esriCommandStyles.esriCommandStyleTextOnly); //m_menuLayer.AddItem(new Symbology(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); //m_menuLayer.AddItem(new SimpleSymbology(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.SetHook(m_mapControl); } catch (Exception ex) { MessageBox.Show("Error 104:" + ex.Message); } }
/// <summary> /// Overloaded constructor /// </summary> /// <param name="iTOCControl2">pass by ref the toccontol </param> public MyTOCClass(ITOCControl2 iTOCControl2) { m_ITOCControl2 = iTOCControl2; }
/// <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); } }
/// <summary> /// Get Ilayer from TOC Control /// </summary> /// <param name="iTOCControl2">pass by ref the toccontol</param> /// <returns></returns> private ILayer getIlayer(ITOCControl2 iTOCControl2) { try { ILayer iLayer = null; IBasicMap map = null; ILayer layer = null; Object other = null; Object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; iTOCControl2.GetSelectedItem(ref item, ref map, ref layer, ref other, ref index); //Attempt a cast iLayer = layer as ESRI.ArcGIS.Carto.ILayer; //return layer of type ilayer return iLayer; } catch (Exception) { throw; } }
private void TOCCControl_Load(object sender, EventArgs e) { _tocControl = (ITOCControl2)ATOCControl.Object; }
void IThematicView.SetTocControl(ITOCControl2 tocControl) { _tocControl = tocControl; _thematic.SetTocControl(_tocControl); }
void IThematic.SetTocControl(ITOCControl2 tocControl) { this._tocControl = tocControl; }
private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //if (e.button == 1) //{ // esriTOCControlItem pItem = new esriTOCControlItem(); // IBasicMap pMap = new MapClass(); // ILayer pLayer = new FeatureLayerClass(); // object other = new object(); // object index = new object(); // ILegendGroup pLegendGroup; // _SelSymLayer = null; // axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref other, ref index); // if (pLayer == null) // return; // if (pItem == esriTOCControlItem.esriTOCControlItemLayer) // { // if (pLayer.GetType() is IAnnotationSublayer) return; // else // { // _SelSymLayer = pLayer; // } // } //} IBasicMap pMap = null; ILayer pLayer = null; System.Object other = null; System.Object LayerIndex = null; System.Drawing.Point pPoint = new System.Drawing.Point(e.x, e.y); esriTOCControlItem TOCItem = esriTOCControlItem.esriTOCControlItemNone; ITOCControl2 tocControl = (ITOCControl2)axTOCControl.Object; tocControl.HitTest(e.x, e.y, ref TOCItem, ref pMap, ref pLayer, ref other, ref LayerIndex); if (e.button == 2 && GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu != null) { DevComponents.DotNetBar.ButtonItem item = null; DevComponents.DotNetBar.ContextMenuBar menuBar = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"]; DevComponents.DotNetBar.ContextMenuBar menuBarLayer = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"]; this.Controls.Add(menuBar); this.Controls.Add(menuBarLayer); switch (TOCItem) { case esriTOCControlItem.esriTOCControlItemMap: if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCContextMenu2")) { if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"] != null) { if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items.Count > 0) { item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem; if (item != null) { item.Popup(axTOCControl.PointToScreen(pPoint)); } } } } break; case esriTOCControlItem.esriTOCControlItemLayer: if (!(pLayer is IGroupLayer || pLayer is IFeatureLayer || pLayer is IDataLayer)) { return; } if (pLayer is IFeatureLayer || pLayer is IDataLayer) { IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCLayerContextMenu2")) { if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"] != null) { if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items.Count > 0) { item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem; if (item != null) { item.Popup(axTOCControl.PointToScreen(pPoint)); } } } } if (axTOCControl.Buddy is IPageLayoutControl2) { IPageLayoutControl2 pPageLayoutControl = axTOCControl.Buddy as IPageLayoutControl2; pPageLayoutControl.CustomProperty = pLayer; } else if (axTOCControl.Buddy is IMapControl3) { IMapControl3 pMapcontrol = axTOCControl.Buddy as IMapControl3; pMapcontrol.CustomProperty = pLayer; } } break; } } }
private void iniMapController() { this._map = new GMap() ; this._mapView = (IMapView)this.gMapView1; this._layersView = (ILayersView)this.gLayersView1; this._mapView.SetParentDockControl(this.dpnMap4Thua); //FrmLandPriceInfo frmLandPriceView = FrmLandPriceInfo.CallMe; _xemVungGiaDatTinh = FrmLandPriceInfo.CallMe.GetView(); _xemVungGiaDatTinh.Config = CurrentConfig.CallMe(); _xemVungGiaDatCongBo = FrmLandPriceInfoPublic.CallMe.GetView(); _xemVungGiaDatCongBo.Config = CurrentConfig.CallMe(); this._mapView.SetLandpriceView("giadatcongbo", _xemVungGiaDatCongBo); this._mapView.SetLandpriceView("giadatdatinh",_xemVungGiaDatTinh); this._mapView.SetCalcMethodBuilderView(FrmCalcMethodBuilder.CallMe.GetView()); _editPosView = FrmSetPositionParam.CallMe; _mapView.EditPosView = _editPosView; this._mapViewController = new MapViewController(this._mapView, this._layersView, this._map); this._mapControl=(IMapControl3)this._map.GetHook(); this._tocControl = this._layersView.GetTocControl(); //this._map4Thua = new GMap(); //this._mapView4thua = this.gMapView1 as IMapView; //this._mapView4thua.SetParentDockControl(this.dpnMap4Thua); //this._layersView4Thua = this.gLayersView1 as ILayersView; //this._mapController4Thua = new MapViewController(this._mapView4thua, this._layersView4Thua, this._map4Thua); //this._mapView4thua.SetController(this._mapController4Thua); //_landPriceTool = new Landprices(); //_landPriceTool.XemGiaDat += new Landprices.XemGiaDatEventHandler(landPriceTool_Changed); //_mapContextMenu = new MapContextMenu(_mapControl); //_mapContextMenu.AddItem(_landPriceTool, false, -1); //this._mapView.ContextMenu.AddItem(_landPriceTool,false,-1); }
private void Form1_Load(object sender, EventArgs e) { axTOCControl1.SetBuddyControl(axMapControl1); //启动默认为pan ICommand command = new ControlsMapPanToolClass(); command.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = command as ITool; m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; m_menuMap = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); istoolenable(false); }
public frmSampleSummary() { InitializeComponent(); _pMapControl = EnviVars.instance.MapControl; _pTOCControl = EnviVars.instance.TOCControl; }