C#_状态栏,textbox动态变化

来源:互联网 发布:cad2016 for mac 编辑:程序博客网 时间:2024/05/18 02:57

+

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Controls;

namespace mxd3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }   
        IMapDocument mMapDocument;
        private void LoadMapDocument()
        {
            mMapDocument = new MapDocumentClass();
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "(*.mxd)|*.mxd";
            openFileDialog1.Title = "打开地图文档";
            openFileDialog1.ShowDialog();
            string Path = openFileDialog1.FileName;
            if (axMapControl1.CheckMxFile(Path))
            {
                axMapControl1.LoadMxFile(Path);
            }
            axMapControl1.Refresh();
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            LoadMapDocument();
        }
        private void textBox1_KeyDown_1(object sender, KeyEventArgs e)
        {
            try
            {
                double Value = double.Parse(textBox1.Text);
                axMapControl1.MapScale = Value;
                axMapControl1.Refresh();            
            }
            catch
            {
                MessageBox.Show("请输入正确的比例尺");
            }
        }
      
        private void axMapControl1_OnMouseMove_1(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {        
           
            CoordinateLabel.Text = "当前坐标 X=" + e.mapX.ToString("#0.0000") + "Y=" + e.mapY.ToString("#0.0000") + " " + this.axMapControl1.MapUnits;//坐标加单位
        
        }   
       private void axMapControl1_OnViewRefreshed(object sender, IMapControlEvents2_OnViewRefreshedEvent e)
        {
            textBox1.Text = ((long)this.axMapControl1.MapScale).ToString();
        }
       private void button2_Click(object sender, EventArgs e)
       {
           ICommand Cmd = new ControlsMapFullExtentCommandClass();
           Cmd.OnCreate(this.axMapControl1.Object);
           Cmd.OnClick();
       }       
    }
}