Form1.cs
上传用户:xianghe012
上传日期:2022-07-02
资源大小:77k
文件大小:5k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using ESRI.ArcGIS.esriSystem;
- using ESRI.ArcGIS.SystemUI;
- using ESRI.ArcGIS.Geometry;
- using ESRI.ArcGIS.Display;
- using ESRI.ArcGIS.Geodatabase;
- using ESRI.ArcGIS.Carto;
- using ESRI.ArcGIS.Controls;
- namespace ArcMap
- {
-
- public partial class FrmMain : Form
- {
- public IMapControl2 pMapControl;
- public IToolbarControl2 pToolBarControl;
- public ITOCControl2 pTocControl;
-
- public bool toolSelected = false;
- public FrmMain()
- {
- InitializeComponent();
- }
- private void FrmMain_Load(object sender, EventArgs e)
- {
- pMapControl = (IMapControl2)axMapControl1.Object;
- pTocControl = (ITOCControl2)axTOCControl1.Object;
- pToolBarControl = (IToolbarControl2)axToolbarControl1.Object;
-
- pToolBarControl.SetBuddyControl(pMapControl);
- pTocControl.SetBuddyControl(pMapControl);
- CreateToolBarItem();
- }
- private void CreateToolBarItem()
- {
- pToolBarControl.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsAddDataCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomInFixedCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomOutFixedCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapFullExtentCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapZoomToLastExtentForwardCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsSelectFeaturesTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsClearSelectionCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsSelectTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapIdentifyTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapFindCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- pToolBarControl.AddItem("esriControls.ControlsMapMeasureTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- }
- private void FeatureViaProperty_Click(object sender, EventArgs e)
- {
- FrmQuery fQuery = new FrmQuery(pMapControl);
- fQuery.Show();
- }
- private void PropertyViaFeature_Click(object sender, EventArgs e)
- {
- toolSelected = true;
- }
- private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
- {
- //if (e.button == 1 && toolSelected==true)
- //{
- // X1 = e.mapX;
- // Y1 = e.mapY;
- //}
- //if (e.button == 1 && toolSelected == true)
- //{
- // IEnvelope pEnvelop = pMapControl.TrackRectangle();
- // pMapControl.Map.ClearSelection();
- // frmProperty fProperty = new frmProperty(pMapControl, pEnvelop);
- // fProperty.Show();
- //}
- }
- private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
- {
- //if (e.button == 1 && toolSelected == true)
- //{
- // X2 = e.mapX;
- // Y2 = e.mapY;
- // pEnvelop = new EnvelopeClass();
- // pEnvelop.XMin = X1;
- // pEnvelop.XMax = X2;
- // pEnvelop.YMin = Y2;
- // pEnvelop.YMax = Y1;
- //}
- }
- private void panToolStripMenuItem_Click(object sender, EventArgs e)
- {
- ICommand command = new ControlsMapPanToolClass();
- command.OnCreate(pMapControl);
- if (command.Enabled == true)
- {
- pMapControl.CurrentTool = (ITool)command;
-
- }
- }
- }
- }