物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 569|回复: 0

c#中调用mapx5.0(一)_第一部分

[复制链接]
发表于 2013-3-15 18:11:30 | 显示全部楼层 |阅读模式
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace gistestbymyself
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class FrmMain : System.Windows.Forms.Form
{
  #region 私有变量的声明
  private  AxMapXLib.AxMap axMap1;
  private AxMapXLib.AxMap axMap2;
  private double zoom;
  private double centerx;
  private double centery;
  #endregion
  #region Windows 窗体上拖入窗体的控件
  /// <summary>
  ///
  /// 窗体信息。
  /// </summary>


  private System.Windows.Forms.ToolBar toolBar2;
  private System.Windows.Forms.ToolBarButton tbfangda;
  private System.Windows.Forms.ToolBarButton tbbianxiao;
  private System.Windows.Forms.ToolBarButton tbmanyou;
  private System.Windows.Forms.ToolBarButton tbbiaozhu;
  private System.Windows.Forms.ToolBarButton tbjuli;
  private System.Windows.Forms.ToolBarButton tbshuaxin;
  private System.Windows.Forms.ToolBarButton tbxiangxi;
  private System.Windows.Forms.ToolBarButton tbzuiduan;
  private System.Windows.Forms.ToolBarButton tbmianji;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.ToolBarButton tbxuanze;
  private System.Windows.Forms.MainMenu mainMenu1;
  private System.Windows.Forms.MenuItem menuItem1;
  private System.Windows.Forms.MenuItem menuItem2;
  private System.Windows.Forms.MenuItem menuItem3;
  private System.Windows.Forms.MenuItem mutuceng;
  private System.Windows.Forms.ContextMenu comu;
  private System.Windows.Forms.MenuItem menuItem4;
  private System.Windows.Forms.MenuItem menuItem5;
  private System.Windows.Forms.MenuItem menuItem6;
  private System.Windows.Forms.MenuItem menuItem7;
  private System.Windows.Forms.ContextMenu comu1;
  private System.Windows.Forms.MenuItem menuItem8;
  private System.Windows.Forms.MenuItem menuItem9;
  private System.Windows.Forms.ToolBarButton tbtianjiafuhao;
  private System.Windows.Forms.MenuItem menuItem10;
  private System.Windows.Forms.MenuItem menuItem11;
  private System.Windows.Forms.MenuItem menuItem12;
  private System.Windows.Forms.MenuItem menuItem13;
  private System.Windows.Forms.MenuItem menuItem14;
  private System.Windows.Forms.MenuItem menuItem15;
  private System.Windows.Forms.MenuItem menuItem16;
  private System.Windows.Forms.MenuItem menuItem17;
  private System.Windows.Forms.MenuItem menuItem18;
  private System.Windows.Forms.MenuItem menuItem19;
  private System.Windows.Forms.MenuItem menuItem20;
  private System.Windows.Forms.MenuItem menuItem21;
  private System.Windows.Forms.MenuItem menuItem22;
  private System.Windows.Forms.MenuItem menuItem23;
  private System.Windows.Forms.MenuItem menuItem24;
  private System.Windows.Forms.MenuItem menuItem25;
  private System.Windows.Forms.MenuItem menuItem26;
  private System.Windows.Forms.Splitter splitter1;
  private System.Windows.Forms.MenuItem menuItem27;
  private System.Windows.Forms.ToolBar toolBar1;
  private System.Windows.Forms.ToolBarButton tbadddian;
  private System.Windows.Forms.ToolBarButton tbaddxian;
  private System.Windows.Forms.ToolBarButton tbaddquxian;
  private System.Windows.Forms.ToolBarButton tbaddqumian;
  private System.Windows.Forms.ToolBarButton tbshezhi;
  private System.Windows.Forms.ToolBarButton tbline;
  private System.Windows.Forms.MenuItem menuItem28;
  private System.Windows.Forms.MenuItem menuItem29;
  private System.Windows.Forms.MenuItem menuItem30;
  private System.Windows.Forms.MenuItem menuItem31;
  private System.Windows.Forms.MenuItem menuItem32;
  private System.Windows.Forms.MenuItem menuItem33;
  private System.Windows.Forms.MenuItem menuItem34;
  private System.Windows.Forms.MenuItem menuItem35;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  #endregion
  #region FrmMain类的初始化和Form_Load时发生时的动作
  public FrmMain()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
   this.zoom=axMap1.Zoom;            //取得初始化时的地图比例
   this.centerx=axMap1.CenterX;
   this.centery=axMap1.CenterY;      //取得初始化时的地图坐标,供刷新时使用
   axMap1.CreateCustomTool(10,MapXLib.ToolTypeConstants.miToolTypePoly,MapXLib.CursorConstants.miCrossCursor,null,null,false);
   //创建距离工具
   axMap1.CreateCustomTool(11,MapXLib.ToolTypeConstants.miToolTypePolygon,MapXLib.CursorConstants.miCrossCursor,null,null,false);
   //创建面积工具


  }
  //*********************************
  private void Form1_Load(object sender, System.EventArgs e)
  {

   axMap1.GeoSet=@"D:\....\CHINA.GST";

   axMap2.GeoSet= Directory.GetCurrentDirectory()+ @"\....\*.gst";
   axMap1.TitleText="中国";
   axMap2.TitleText="***";   
  }
     #endregion
  //*****************************
  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  private void InitializeComponent()
  {
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmMain));
   this.axMap1 = new AxMapXLib.AxMap();
   this.axMap2 = new AxMapXLib.AxMap();
   this.toolBar2 = new System.Windows.Forms.ToolBar();
   this.tbxuanze = new System.Windows.Forms.ToolBarButton();
   this.tbfangda = new System.Windows.Forms.ToolBarButton();
   this.tbbianxiao = new System.Windows.Forms.ToolBarButton();
   this.tbmanyou = new System.Windows.Forms.ToolBarButton();
   this.tbbiaozhu = new System.Windows.Forms.ToolBarButton();
   this.tbtianjiafuhao = new System.Windows.Forms.ToolBarButton();
   this.tbjuli = new System.Windows.Forms.ToolBarButton();
   this.tbmianji = new System.Windows.Forms.ToolBarButton();
   this.tbshuaxin = new System.Windows.Forms.ToolBarButton();
   this.tbxiangxi = new System.Windows.Forms.ToolBarButton();
   this.tbzuiduan = new System.Windows.Forms.ToolBarButton();
   this.label1 = new System.Windows.Forms.Label();
   this.mainMenu1 = new System.Windows.Forms.MainMenu();
   this.menuItem1 = new System.Windows.Forms.MenuItem();
   this.menuItem20 = new System.Windows.Forms.MenuItem();
   this.menuItem21 = new System.Windows.Forms.MenuItem();
   this.menuItem22 = new System.Windows.Forms.MenuItem();
   this.menuItem23 = new System.Windows.Forms.MenuItem();
   this.menuItem24 = new System.Windows.Forms.MenuItem();
   this.menuItem25 = new System.Windows.Forms.MenuItem();
   this.menuItem26 = new System.Windows.Forms.MenuItem();
   this.menuItem2 = new System.Windows.Forms.MenuItem();
   this.menuItem3 = new System.Windows.Forms.MenuItem();
   this.menuItem29 = new System.Windows.Forms.MenuItem();
   this.menuItem28 = new System.Windows.Forms.MenuItem();
   this.menuItem27 = new System.Windows.Forms.MenuItem();
   this.menuItem15 = new System.Windows.Forms.MenuItem();
   this.menuItem32 = new System.Windows.Forms.MenuItem();
   this.menuItem31 = new System.Windows.Forms.MenuItem();
   this.mutuceng = new System.Windows.Forms.MenuItem();
   this.menuItem30 = new System.Windows.Forms.MenuItem();
   this.menuItem16 = new System.Windows.Forms.MenuItem();
   this.menuItem10 = new System.Windows.Forms.MenuItem();
   this.menuItem11 = new System.Windows.Forms.MenuItem();
   this.menuItem12 = new System.Windows.Forms.MenuItem();
   this.menuItem13 = new System.Windows.Forms.MenuItem();
   this.menuItem14 = new System.Windows.Forms.MenuItem();
   this.menuItem17 = new System.Windows.Forms.MenuItem();
   this.menuItem18 = new System.Windows.Forms.MenuItem();
   this.menuItem19 = new System.Windows.Forms.MenuItem();
   this.comu = new System.Windows.Forms.ContextMenu();
   this.menuItem4 = new System.Windows.Forms.MenuItem();
   this.menuItem5 = new System.Windows.Forms.MenuItem();
   this.menuItem6 = new System.Windows.Forms.MenuItem();
   this.menuItem7 = new System.Windows.Forms.MenuItem();
   this.comu1 = new System.Windows.Forms.ContextMenu();
   this.menuItem8 = new System.Windows.Forms.MenuItem();
   this.menuItem9 = new System.Windows.Forms.MenuItem();
   this.splitter1 = new System.Windows.Forms.Splitter();
   this.toolBar1 = new System.Windows.Forms.ToolBar();
   this.tbadddian = new System.Windows.Forms.ToolBarButton();
   this.tbaddxian = new System.Windows.Forms.ToolBarButton();
   this.tbaddquxian = new System.Windows.Forms.ToolBarButton();
   this.tbaddqumian = new System.Windows.Forms.ToolBarButton();
   this.tbline = new System.Windows.Forms.ToolBarButton();
   this.tbshezhi = new System.Windows.Forms.ToolBarButton();
   this.menuItem33 = new System.Windows.Forms.MenuItem();
   this.menuItem34 = new System.Windows.Forms.MenuItem();
   this.menuItem35 = new System.Windows.Forms.MenuItem();
   ((System.ComponentModel.ISupportInitialize)(this.axMap1)).BeginInit();
   ((System.ComponentModel.ISupportInitialize)(this.axMap2)).BeginInit();
   this.SuspendLayout();

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-5-10 17:25 , Processed in 0.109534 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表