这是 我在.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();
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();
//
// axMap1
//
this.axMap1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.axMap1.Enabled = true;
this.axMap1.Location = new System.Drawing.Point(8, 120);
this.axMap1.Name = "axMap1";
this.axMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap1.OcxState")));
this.axMap1.Size = new System.Drawing.Size(424, 339);
this.axMap1.TabIndex = 0;
this.axMap1.PolyToolUsed += new AxMapXLib.CMapXEvents_PolyToolUsedEventHandler(this.mapMain_PolyToolUsed);
this.axMap1.MouseUpEvent += new AxMapXLib.CMapXEvents_MouseUpEventHandler(this.axMap1_MouseUpEvent);
this.axMap1.ThemeModifyRequested += new AxMapXLib.CMapXEvents_ThemeModifyRequestedEventHandler(this.axMap1_ThemeModifyRequested);
this.axMap1.MouseDownEvent += new AxMapXLib.CMapXEvents_MouseDownEventHandler(this.axMap1_MouseDownEvent);
this.axMap1.MapViewChanged += new System.EventHandler(this.axMap1_MapViewChanged);
//
// axMap2
//
this.axMap2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.axMap2.Enabled = true;
this.axMap2.Location = new System.Drawing.Point(472, 136);
this.axMap2.Name = "axMap2";
this.axMap2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap2.OcxState")));
this.axMap2.Size = new System.Drawing.Size(240, 203);
this.axMap2.TabIndex = 1;
//
// toolBar2
//
this.toolBar2.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tbxuanze,
this.tbfangda,
this.tbbianxiao,
this.tbmanyou,
this.tbbiaozhu,
this.tbtianjiafuhao,
this.tbjuli,
this.tbmianji,
this.tbshuaxin,
this.tbxiangxi,
this.tbzuiduan});
this.toolBar2.ButtonSize = new System.Drawing.Size(55, 35);
this.toolBar2.DropDownArrows = true;
this.toolBar2.Location = new System.Drawing.Point(0, 0);
this.toolBar2.Name = "toolBar2";
this.toolBar2.ShowToolTips = true;
this.toolBar2.Size = new System.Drawing.Size(776, 41);
this.toolBar2.TabIndex = 3;
this.toolBar2.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar2_ButtonClick);
//
// tbxuanze
//
this.tbxuanze.Text = "选择";
//
// tbfangda
//
this.tbfangda.Text = "放大";
this.tbfangda.ToolTipText = "放大";
//
// tbbianxiao
//
this.tbbianxiao.Text = "缩小";
//
// tbmanyou
//
this.tbmanyou.Text = "漫游";
//
// tbbiaozhu
//
this.tbbiaozhu.Text = "标注";
//
// tbtianjiafuhao
//
this.tbtianjiafuhao.Text = "添加符号";
//
// tbjuli
//
this.tbjuli.Text = "测距";
//
// tbmianji
//
this.tbmianji.Text = "面积";
//
// tbshuaxin
//
this.tbshuaxin.Text = "刷新";
//
// tbxiangxi
//
this.tbxiangxi.Text = "详细";
//
// tbzuiduan
//
this.tbzuiduan.Text = "最短实体";
//
// label1
//
this.label1.Location = new System.Drawing.Point(48, 104);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(208, 16);
this.label1.TabIndex = 4;
this.label1.Text = "label1";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem3,
this.menuItem10,
this.menuItem17,
this.menuItem18});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem20,
this.menuItem21,
this.menuItem22,
this.menuItem23,
this.menuItem24,
this.menuItem25,
this.menuItem26,
this.menuItem33,
this.menuItem35,
this.menuItem34,
this.menuItem2});
this.menuItem1.Text = "文件";
//
// menuItem20
//
this.menuItem20.Index = 0;
this.menuItem20.Text = "打开地图...";
this.menuItem20.Click += new System.EventHandler(this.menuItem20_Click);
//
// menuItem21
//
this.menuItem21.Index = 1;
this.menuItem21.Text = "添加图层...";
this.menuItem21.Click += new System.EventHandler(this.menuItem21_Click);
//
// menuItem22
//
this.menuItem22.Index = 2;
this.menuItem22.Text = "-";
//
// menuItem23
//
this.menuItem23.Index = 3;
this.menuItem23.Text = "保存";
this.menuItem23.Click += new System.EventHandler(this.menuItem23_Click);
//
// menuItem24
//
this.menuItem24.Index = 4;
this.menuItem24.Text = "另存为...";
this.menuItem24.Click += new System.EventHandler(this.menuItem24_Click);
//
// menuItem25
//
this.menuItem25.Index = 5;
this.menuItem25.Text = "导出..";
this.menuItem25.Click += new System.EventHandler(this.menuItem25_Click);
//
// menuItem26
//
this.menuItem26.Index = 6;
this.menuItem26.Text = "-";
//
// menuItem2
//
this.menuItem2.Index = 10;
this.menuItem2.Text = "退出";
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem29,
this.menuItem28,
this.menuItem27,
this.menuItem15,
this.menuItem32,
this.menuItem31,
this.mutuceng,
this.menuItem30,
this.menuItem16});
this.menuItem3.Text = "地图";
//
// menuItem29
//
this.menuItem29.Index = 0;
this.menuItem29.Text = "坐标变换(投影)";
this.menuItem29.Click += new System.EventHandler(this.menuItem29_Click);
//
// menuItem28
//
this.menuItem28.Index = 1;
this.menuItem28.Text = "-";
//
// menuItem27
//
this.menuItem27.Index = 2;
this.menuItem27.Text = "编辑";
this.menuItem27.Click += new System.EventHandler(this.menuItem27_Click);
//
// menuItem15
//
this.menuItem15.Index = 3;
this.menuItem15.Text = "-";
//
// menuItem32
//
this.menuItem32.Index = 4;
this.menuItem32.Text = "缩放图层";
this.menuItem32.Click += new System.EventHandler(this.menuItem32_Click);
//
// menuItem31
//
this.menuItem31.Index = 5;
this.menuItem31.Text = "选择图层";
this.menuItem31.Click += new System.EventHandler(this.menuItem31_Click);
//
// mutuceng
//
this.mutuceng.Index = 6;
this.mutuceng.Text = "图层控制";
this.mutuceng.Click += new System.EventHandler(this.mutuceng_Click);
//
// menuItem30
//
this.menuItem30.Index = 7;
this.menuItem30.Text = "-";
//
// menuItem16
//
this.menuItem16.Index = 8;
this.menuItem16.Text = "属性";
this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
//
// menuItem10
//
this.menuItem10.Index = 2;
this.menuItem10.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem11,
this.menuItem12,
this.menuItem13,
this.menuItem14});
this.menuItem10.Text = "注释";
//
// menuItem11
//
this.menuItem11.Index = 0;
this.menuItem11.Text = "添加符号";
this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
// menuItem12
//
this.menuItem12.Index = 1;
this.menuItem12.Text = "添加文本";
this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuItem13
//
this.menuItem13.Index = 2;
this.menuItem13.Text = "移除";
this.menuItem13.Click += new System.EventHandler(this.menuItem13_Click);
//
// menuItem14
//
this.menuItem14.Index = 3;
this.menuItem14.Text = "设置";
this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
//
// menuItem17
//
this.menuItem17.Index = 3;
this.menuItem17.Text = "窗口";
//
// menuItem18
//
this.menuItem18.Index = 4;
this.menuItem18.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem19});
this.menuItem18.Text = "帮助";
//
// menuItem19
//
this.menuItem19.Index = 0;
this.menuItem19.Text = "关于MapX";
this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
//
// comu
//
this.comu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4,
this.menuItem5,
this.menuItem6,
this.menuItem7});
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "普通";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "矩形";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Text = "圆形";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 3;
this.menuItem7.Text = "多边形";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// comu1
//
this.comu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem8,
this.menuItem9});
//
// menuItem8
//
this.menuItem8.Index = 0;
this.menuItem8.Text = "添加符号";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 1;
this.menuItem9.Text = "添加";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(0, 41);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 432);
this.splitter1.TabIndex = 5;
this.splitter1.TabStop = false;
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tbadddian,
this.tbaddxian,
this.tbaddquxian,
this.tbaddqumian,
this.tbline,
this.tbshezhi});
this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;
this.toolBar1.DropDownArrows = true;
this.toolBar1.Location = new System.Drawing.Point(0, 40);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(488, 28);
this.toolBar1.TabIndex = 6;
this.toolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
this.toolBar1.Visible = false;
this.toolBar1.Wrappable = false;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// tbadddian
//
this.tbadddian.Text = "点 ";
this.tbadddian.Visible = false;
//
// tbaddxian
//
this.tbaddxian.Text = "线 ";
this.tbaddxian.Visible = false;
//
// tbaddquxian
//
this.tbaddquxian.Text = "曲线 ";
this.tbaddquxian.Visible = false;
//
// tbaddqumian
//
this.tbaddqumian.Text = "面 ";
this.tbaddqumian.Visible = false;
//
// tbline
//
this.tbline.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbshezhi
//
this.tbshezhi.Text = "设置 ";
this.tbshezhi.Visible = false;
//
// menuItem33
//
this.menuItem33.Index = 7;
this.menuItem33.Text = "打印设置";
//
// menuItem34
//
this.menuItem34.Index = 9;
this.menuItem34.Text = "-";
//
// menuItem35
//
this.menuItem35.Index = 8;
this.menuItem35.Text = "打印...";
//
// FrmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(776, 473);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.label1);
this.Controls.Add(this.toolBar2);
this.Controls.Add(this.axMap2);
this.Controls.Add(this.axMap1);
this.Menu = this.mainMenu1;
this.Name = "FrmMain";
this.Text = "FrmMain";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.axMap1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axMap2)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 应用程序的主入口点
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
FrmMain FMain;
Application.Run(FMain=new FrmMain());
}
#endregion
//****************************************
#region axMap1对象的属性操作,一般都在其他窗口里被使用
/// <summary>
/// 在这里适用属性主要是为了axMap1这个私有的对象能在其他窗体中获得一些需要的改变
/// </summary>
///
//属性1
public MapXLib.Style SyStyle //属性操作,设置或取得符号的样式,在 Frmannotation 中使用了该属性,
{
set
{
axMap1.DefaultStyle=value;
}
get
{
return axMap1.DefaultStyle;
}
}
//属性2
public MapXLib.Style editStyle //属性操作,设置或取得在编辑图层时,改变的点,线和曲面的样式 在Frmeditable
{
set //中使用了该属性,
{
axMap1.AutoRedraw=true;
axMap1.Layers.InsertionLayer.Style=value;
}
get
{
axMap1.Layers.InsertionLayer.OverrideStyle=true;
axMap1.AutoRedraw=false;
return axMap1.Layers.InsertionLayer.Style;
}
}
//属性3
public MapXLib.Layers Layer //属性操作,通过该属性,图层选择显示窗口(FrmViewLyr)可以操作axMap1的Layers属性,
{ //在FrmViewLyr_Load 时可以得到 Layers
get
{
return axMap1.Layers;
}
}
//属性4
public string LyrName //属性操作,通过该属性,得到图层选择显示窗口(FrmViewLyr)中cobLyr.text中的值
{ //来显示那个图层将被显示
set
{
if(value=="All Layers")
axMap1.CtlBounds=axMap1.Layers.Bounds; //注意,这里使用CtlBounds属性(MapX的属性),而不是Bounds(.net本身的属性)在.net
else
axMap1.CtlBounds=axMap1.Layers[value].Bounds; //环境下,有点改变,
}
}
#endregion
//***********************************
#region 工具条,里面包含选择、拖动漫游、放大缩小等一些工具
private void toolBar2_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
try
{
if(e.Button==tbfangda)
axMap1.CurrentTool=MapXLib.ToolConstants.miZoomInTool;//1003
if(e.Button==tbbianxiao)
axMap1.CurrentTool=MapXLib.ToolConstants.miZoomOutTool;//缩小地图
if(e.Button==tbmanyou)
axMap1.CurrentTool=MapXLib.ToolConstants.miPanTool;//漫游地图
if(e.Button==tbbiaozhu) //标注地图
{
axMap1.CurrentTool=MapXLib.ToolConstants.miLabelTool;
//Point p=new Point(20+55*5,20);
//comu1.Show(toolBar2,p);
}
if(e.Button==tbtianjiafuhao)
axMap1.CurrentTool=MapXLib.ToolConstants.miSymbolTool;
if(e.Button==tbjuli)
axMap1.CurrentTool=( MapXLib.ToolConstants ) 10;
if(e.Button==tbmianji)
axMap1.CurrentTool=(MapXLib.ToolConstants ) 11;
if(e.Button==tbshuaxin)
{
//刷新地图,回到初始状态
axMap1.ZoomTo(this.zoom,this.centerx,this.centery); //恢复初始时的比例
//axMap1.Annotations.RemoveAll();
axMap1.Refresh();
}
if(e.Button==tbxuanze)
{
Point p=new Point(20,20);
comu.Show(toolBar2,p); //显示选择工具菜单,它允许选择矩形,圆形,多边形等
}
}
catch(Exception e1)
{
MessageBox.Show(e1.Message);
}
}
#endregion
本文地址:http://com.8s8s.com/it/it43434.htm