当前位置:编程学习 > C#/ASP.NET >>

C#中调用mapx5.0

这是 我在.net环境中调用mapx5.0控件 的一次test,前几次网上没有发现这方面的文章,所以自己
把几个代码拿出 来:这里有些代码是自动生成的,但只要把几篇文章的代码直接拷贝到工程里 就
能直接运行的。


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();补充:软件开发 , C# ,

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,