private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { GlobeControl.Dispose(); MapControl.Dispose(); TOCControl.Dispose(); ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown(); }
/// <summary> /// 地图更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { IEnvelope envelope = e.newEnvelope as IEnvelope; DrawRectangle(envelope); TOCControl.Update(); }
public index() { //mapControl.AddShapeFile("D:\\Study\\Study_地理信息技术课程\\地信\\实训\\Data\\1.1", "Export_Output.shp"); if (MessageBox.Show("是否立即开始测试程序?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { InitializeComponent(); TOCControl.SetBuddyControl(mapControl); toolbarControl.SetBuddyControl(mapControl); pagelayout_init(); if (map_zoom_r != null && map_zoom_r.map_zoom_init(mapControl)) { MessageBox.Show("Init Success"); } else { MessageBox.Show("Init Error"); Application.Exit(); } } else { System.Environment.Exit(0); } }
private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //make sure that the user right clicked if (1 != e.button) { return; } m_SelectedTOCLayer = null; //use HitTest in order to test whether the user has selected a featureLayer esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //do the HitTest TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Determine what kind of item has been clicked on if (null == layer || !(layer is ILayer)) { return; } m_SelectedTOCLayer = layer; ////set the featurelayer as the custom property of the MapControl //MapControl.CustomProperty = layer; ////popup a context menu with a 'Properties' command //m_contextMenu.PopupMenu(e.x, e.y, TOCControl.hWnd); }
private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button != 2) { return; } //if ( m_pToolbarMenu. IBasicMap map = null; ILayer layer = null; ILayer m_layer = null; object other = null; object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if ((item == esriTOCControlItem.esriTOCControlItemLayer)) { if (layer is IFeatureLayer) { MapControl.CustomProperty = layer; m_pToolbarMenu.PopupMenu(e.x, e.y, (int)TOCControl.Handle); } } }
private void Initialize() { TOCControl.SetBuddyControl(MapControl.Object); m_Synchronous = new Synchronous(); m_MapGlobeControl = GlobeControl.Globe as IMap; if (m_MapGlobeControl == null) { return; } // Add Raster Layer IRasterLayer pRas = new ESRI.ArcGIS.Carto.RasterLayer(); pRas.CreateFromFilePath(@"C:\Users\mgh\Desktop\AirPlane2\AirPlane\AirPlane\bin\Debug\GlobeData\wsiearth.tif"); GlobeControl.Globe.AddLayerType(pRas, esriGlobeLayerType.esriGlobeLayerTypeDraped, true); // Add Graphic Layer graphicsAirplanesLayer = AddGraphicLayers(GraphicsAirPalnesLayerName); graphicsAirlinesLayer = AddGraphicLayers(GraphicsAirlinesLayerName); m_Synchronous.m_Mapglobe = m_MapGlobeControl; m_Synchronous.m_Globe = GlobeControl.Globe; GCon_MapControl = m_MapMapControl as IGraphicsContainer; m_ActiveViewGlobeControl = m_MapGlobeControl as IActiveView; m_ActiveViewGlobeControl.Extent = m_ActiveViewGlobeControl.FullExtent; m_ActiveViewGlobeControl.Refresh(); }
//ProgressBar progressBar = new ProgressBar(); //StatusBar m_StatusBar; #endregion #region 构造函数 /// <summary> /// 构造函数 /// </summary> public MainForm() { InitializeComponent(); // 添加MapControl,this.axMapControl2 = new PIE.AxControls.MapControl(); axMapControl2 = new PIE.AxControls.MapControl(); axMapControl2.ActiveView.TrackerCancel = m_TrackerCancel; //m_MapControl = new MapControl(); axMapControl2.Dock = DockStyle.Fill; splitContainer1.Panel2.Controls.Add(axMapControl2); axMapControl2.MouseMove += axMapControl2_MouseMove; axMapControl2.MouseClick += axMapControl2_MouseClick; //splitContainer1.Panel2.MouseClick+= axMapControl2_MouseClick; //axMapControl2.Click += axMapControl2_MouseClick; //IMap map = axMapControl2.FocusMap; // 添加TOCControl m_TOCControl = new TOCControl(); m_TOCControl.SetBuddyControl(axMapControl2); m_TOCControl.Dock = DockStyle.Fill; splitContainer1.Panel1.Controls.Add(m_TOCControl); m_TOCControl.MouseClick += m_TOCControl_MouseClick; //状态栏 //m_StatusBar = statusStrip1 as IStatusBar; //m_StatusBar.Initial(); // TOC按钮绑定 //ActiveMap_MenuItem.Tag = new ActivateMapCommand(); VectorLoader_MenuItem.Tag = new VectorLoaderMenuCommand(); RasterLoader_MenuItem.Tag = new RasterLoaderMenuCommand(); TurnOffAll_MenuItem.Tag = new TurnOffAllLayersCommand(); TurnOffAllGroupLayer_MenuItem.Tag = new TurnOffAllLayersCommand(); TurnOnAll_MenuItem.Tag = new TurnOnAllLayersCommand(); TurnOnAllGroupLayer_MenuItem.Tag = new TurnOnAllLayersCommand(); ClearAll_MenuItem.Tag = new ClearAllLayersCommand(); ClearAllGroupLayer_MenuItem.Tag = new ClearAllLayersCommand(); OpenFilePathFeatureLayer_MenuItem.Tag = new OpenFilePathCommand(); OpenFilePathGroupLayer_MenuItem.Tag = new OpenFilePathCommand(); OpenFilePathRasterLayer_MenuItem.Tag = new OpenFilePathCommand(); DeleteFeatureLayer_MenuItem.Tag = new DeleteLayerCommand(); DeleteRasterLayer_MenuItem.Tag = new DeleteLayerCommand(); DeleteGroupLayer_MenuItem.Tag = new DeleteLayerCommand(); ZoomtoFeatureLayer_MenuItem.Tag = new ZoomToLayerCommand(); ZoomToGroupLayer_MenuItem.Tag = new ZoomToLayerCommand(); ZoomTORasterLayer_MenuItem.Tag = new ZoomToLayerCommand(); AnnotationFeatureLayer_MenuItem.Tag = new FeatureLayerAnnotationCommand(); AttributeToolStripMenuItem.Tag = new FeatureLayerAttributeCommand(); LayerAttributeMenuItem.Tag = new LayerPropertyCommand(); ZoomInToolStripMenuItem.Tag = new MapZoomInTool(); parentForm = this; }
public UnlockLayerMenuItem(TOCControl control, ITOCElement element, Image image) { _control = control; _element = element; this.Text = element.Name; this.Image = image; this.Click += new EventHandler(UnlockLayerMenuItem_Click); }
/// <summary> /// 构造函数 /// </summary> public Form1() { InitializeComponent(); // 添加MapControl axMapControl2.ActiveView.TrackerCancel = m_TrackerCancel; m_MapControl = new MapControl(); axMapControl2.Dock = DockStyle.Fill; splitContainer1.Panel2.Controls.Add(axMapControl2); axMapControl2.MouseMove += axMapControl2_MouseMove; //IMap map = axMapControl2.FocusMap; // 添加TOCControl m_TOCControl = new TOCControl(); m_TOCControl.SetBuddyControl(axMapControl2); m_TOCControl.Dock = DockStyle.Fill; splitContainer1.Panel1.Controls.Add(m_TOCControl); m_TOCControl.MouseClick += m_TOCControl_MouseClick; //状态栏 //m_StatusBar = statusStrip1 as IStatusBar; //m_StatusBar.Initial(); // TOC按钮绑定 //ActiveMap_MenuItem.Tag = new ActivateMapCommand(); VectorLoader_MenuItem.Tag = new VectorLoaderMenuCommand(); RasterLoader_MenuItem.Tag = new RasterLoaderMenuCommand(); TurnOffAll_MenuItem.Tag = new TurnOffAllLayersCommand(); TurnOffAllGroupLayer_MenuItem.Tag = new TurnOffAllLayersCommand(); TurnOnAll_MenuItem.Tag = new TurnOnAllLayersCommand(); TurnOnAllGroupLayer_MenuItem.Tag = new TurnOnAllLayersCommand(); ClearAll_MenuItem.Tag = new ClearAllLayersCommand(); ClearAllGroupLayer_MenuItem.Tag = new ClearAllLayersCommand(); OpenFilePathFeatureLayer_MenuItem.Tag = new OpenFilePathCommand(); OpenFilePathGroupLayer_MenuItem.Tag = new OpenFilePathCommand(); OpenFilePathRasterLayer_MenuItem.Tag = new OpenFilePathCommand(); DeleteFeatureLayer_MenuItem.Tag = new DeleteLayerCommand(); DeleteRasterLayer_MenuItem.Tag = new DeleteLayerCommand(); DeleteGroupLayer_MenuItem.Tag = new DeleteLayerCommand(); ZoomtoFeatureLayer_MenuItem.Tag = new ZoomToLayerCommand(); ZoomToGroupLayer_MenuItem.Tag = new ZoomToLayerCommand(); ZoomTORasterLayer_MenuItem.Tag = new ZoomToLayerCommand(); AnnotationFeatureLayer_MenuItem.Tag = new FeatureLayerAnnotationCommand(); AttributeToolStripMenuItem.Tag = new FeatureLayerAttributeCommand(); ISODATA.Tag = new MyISODATA(); //ISODATA.Tag = new PIE.Plugin.ISODataClassificationCommand(); testButton.Tag = new ISODataClassificationAlgo(); }
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 = "لیست لایه های مکانی"; }
private void TOCContextMenuItem_RemoveLayer(object sender, EventArgs e) { ESRI.ArcGIS.Controls.esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone; ESRI.ArcGIS.Carto.ILayer pLayer = null; ESRI.ArcGIS.Carto.IBasicMap pMap = null; object pIndex = null; object pOther = null; TOCControl.GetSelectedItem(ref pItem, ref pMap, ref pLayer, ref pIndex, ref pOther); if (pLayer != null) { MainMap.Map.DeleteLayer(pLayer); } }
private void MainForm_Load(object sender, EventArgs e) { TOCControl.SetBuddyControl(MainMap); TOCControl.EnableLayerDragDrop = true; ContextMenuStrip tocContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(); TOCControl.ContextMenuStrip = tocContextMenuStrip; TOCControl.ContextMenuStrip.Items.Add("缩放到图层", null, TOCContextMenuItem_ZoomToLayer); TOCControl.ContextMenuStrip.Items.Add("删除图层", null, TOCContextMenuItem_RemoveLayer); m_selectTool.OnCreate(MainMap.Object); }
public ArcGisPoisonous() { InitializeComponent(); TOCControl.SetBuddyControl(MainMapControl); EagleEyeMapControl.Extent = MainMapControl.FullExtent; pEnv = EagleEyeMapControl.Extent; DrawRectangle(pEnv); //窗体初始化时新建ISelectionEnvironment接口的对象,对象具有默认的选项设置值 selectionEnvironment = new SelectionEnvironmentClass(); // 修改按钮状态 ChangeButtonState(false); }
private void TOCContextMenuItem_ZoomToLayer(object sender, EventArgs e) { esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone; ILayer pLayer = null; IBasicMap pMap = null; object pIndex = null; object pOther = null; TOCControl.GetSelectedItem(ref pItem, ref pMap, ref pLayer, ref pIndex, ref pOther); if (pLayer != null) { IGeoDataset pGeoDataset = pLayer as IGeoDataset; MainMap.ActiveView.Extent = pGeoDataset.Extent; MainMap.ActiveView.Refresh(); } }
private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) { esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; object unk = null; object data = null; ILayer layer = null; TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data); pTocFeatureLayer = layer as IFeatureLayer; if (item == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null) { btnLayerSel.Enabled = !pTocFeatureLayer.Selectable; btnLayerUnSel.Enabled = pTocFeatureLayer.Selectable; contextMenuStrip1.Show(Control.MousePosition); } } }
private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //如果不是右键按下直接返回 if (e.button != 2) { return; } esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //判断所选菜单的类型 TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //确定选定的菜单类型,Map或是图层菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { TOCControl.SelectItem(map, null); } else { TOCControl.SelectItem(layer, null); } //设置CustomProperty为layer (用于自定义的Layer命令) // m_mapControl.CustomProperty = layer; //弹出右键菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { contextMenuStrip1.Show(TOCControl, e.x, e.y); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { contextMenuStrip1.Show(TOCControl, e.x, e.y); } m_SelLayer = layer; }
private void frmlayerToc_Resize(object sender, EventArgs e) { TOCControl.SetBounds(1, 1, this.ClientRectangle.Width - 2, this.ClientRectangle.Height - this.MapHawkEye.Height); MapHawkEye.SetBounds(1, this.TOCControl.Height, this.ClientRectangle.Width - 2, this.ClientRectangle.Height - this.TOCControl.Height); }