回复 20楼 qq1023569223
哦,是MapInfo,嘿嘿。。。MapX,想替换成MapXtreme,可是代码太多了,无从下手。。。
using System; using System.Collections.Generic; using using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; //using using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.SystemUI; //看这AE编程,看了一下午的接口,晕了 namespace AE1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //窗体载入 private void Form1_Load(object sender, EventArgs e) { this.axToolbarControl1.SetBuddyControl(this.axMapControl1); this.axTOCControl1.SetBuddyControl(this.axMapControl1); this.axTOCControl1.ContextMenuStrip = this.lymean; this.axMapControl1.ContextMenuStrip = this.mapmeau; this.axToolbarControl1.AddItem("esriControlTools.ControlsMapNavigationToolBar"); string s=@"C:\Documents and Settings\Administrator\桌面\0810050225\控制网\地图文档\ctNet.mxd"; if (this.axMapControl1.CheckMxFile(s)) { this.axMapControl1.LoadMxFile(s); this.axMapControl1.Extent = this.axMapControl1.FullExtent; this.Text = (s); } else { MessageBox.Show("Wrong!"); } } //右击显示菜单 private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (e.button==2) { this.lymean.Show(MousePosition.X,MousePosition.Y); } } //添加图层 private void t1_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Title = "添加图层"; of.Filter = "图层文件(*.shp,*.lyr)|*.shp|*.lyr|"; of.Multiselect = true; if( of.ShowDialog()==DialogResult.OK) { string[] file = of.FileNames; for (int i = 0; i < file.Length; i++) { try { if ((file[i]).CompareTo(".shp")==0) { this.axMapControl1.AddShapeFile((file[i]),(file[i])); } else { this.axMapControl1.AddLayerFromFile(file[i]); } } catch { MessageBox.Show("无法加载" + file[i]); } } } } //删除第一个图层 private void t2_Click(object sender, EventArgs e) { if (this.axMapControl1.LayerCount > 0) { if (MessageBox.Show("确定删除图层?", "确认操作", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.axMapControl1.DeleteLayer(0); } } } //保存mxd文档 private void t4_Click(object sender, EventArgs e) { SaveFileDialog sd = new SaveFileDialog(); sd.DefaultExt = ".mxd"; sd.InitialDirectory = Application.StartupPath; sd.RestoreDirectory = true; sd.FileName = "new"; if (sd.ShowDialog() == DialogResult.OK) { try { IMapDocument mapdocumet = new MapDocumentClass(); mapdocumet.Save(mapdocumet.UsesRelativePaths, true); } catch (Exception o) { MessageBox.Show(o.Message); } } } //最后一个图层移到第一个 private void t5_Click(object sender, EventArgs e) { if (this.axMapControl1.LayerCount > 0) { this.axMapControl1.MoveLayerTo(this.axMapControl1.LayerCount - 1, 0); } } private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 2) { this.mapmeau.Show(MousePosition.X, MousePosition.Y); } } private void drawLine_Click(object sender, EventArgs e) { IPoint p = new PointClass(); p.X = MousePosition.X; p.Y = MousePosition.Y; IGeometry pgeo = p as IGeometry; IRgbColor pcolor = new RgbColorClass(); pcolor.Red = 0; pcolor.Green = 0; pcolor.Blue = 0; object symbol = null; ITextSymbol ts = new TextSymbolClass(); ts.Color = pcolor; symbol = ts; this.axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair; this.axMapControl1.DrawText(pgeo, "写文字", ref symbol); //this.axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } } }