In C #, mapx5.0 is called.

Source: Internet
Author: User

This is a test that I used to call the mapx5.0 control in the. net environment. I have not found this article on the internet several times before.
Some code is automatically generated, but you only need to copy the code of several articles directly to the project.
Can run directly.


Using System. Drawing;
Using System. Collections;
Using System. ComponentModel;
Using System. Windows. Forms;
Using System. Data;
Using System. IO;


Namespace gistestbymyself
{
/// <Summary>
/// Summary of Form1.
/// </Summary>
Public class FrmMain: System. Windows. Forms. Form
{


# Region private variable Declaration
Private AxMapXLib. AxMap axMap1;
Private AxMapXLib. AxMap axMap2;


Private double zoom;
Private double centerx;
Private double centery;
# Endregion


# Region Windows form drag the Form Control
/// <Summary>
///
/// Form information.
/// </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>
/// Required designer variables.
/// </Summary>
Private System. ComponentModel. Container components = null;


# Endregion


# Actions when region FrmMain class initialization and Form_Load occur


Public FrmMain ()
{
//
// Required for Windows Form Designer support
//
InitializeComponent ();


//
// TODO: add Any constructor code after InitializeComponent calls
//
This. zoom = axMap1.Zoom; // obtain the map ratio at initialization.
This. centerx = axMap1.CenterX;
This. centery = axMap1.CenterY; // obtain the map coordinate at initialization for Refresh.


AxMap1.CreateCustomTool (10, MapXLib. ToolTypeConstants. miToolTypePoly, MapXLib. CursorConstants. miCrossCursor, null, null, false );
// Create a distance tool


AxMap1.CreateCustomTool (11, MapXLib. ToolTypeConstants. miToolTypePolygon, MapXLib. CursorConstants. miCrossCursor, null, null, false );
// Create an area Tool


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

AxMap1.GeoSet = @ "D:... CHINA. GST ";

AxMap2.GeoSet = Directory. GetCurrentDirectory () + @ "...... *. gst ";


AxMap1.TitleText = "China ";
AxMap2.TitleText = "***";
}


# Endregion
//*****************************


# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
/// <Summary>
/// Clear all resources in use.
/// </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 ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.