How to use mapx5.0 in C # (II)

Source: Internet
Author: User
Tags tostring
Then the first article, continuing, is the second part of the FrMain.cs file in addition to the code in the first article:
//*******************************

#region Create custom tools to measure distances (can be polylines) and measure area
888
private void Mapmain_polytoolused (object sender, Axmapxlib.cmapxevents_polytoolusedevent e)//After creating a tool of your own definition, Selects execution based on tool ID

{

if (E.toolnum = = 10)//measuring distance, this is a custom tool that measures the distance of multiple points

{

mapxlib.points pts = (mapxlib.points) e.points;

Mapxlib.point Pt1,pt2;

Double d=0.0;

Calculate order two points distance, accumulate total distance

for (int i=1;i<pts. count;i++)

{

Pt1=pts._item (i);

Pt2=pts._item (i+1);

D + + axmap1.distance (pt1. X,pt1. Y,pt2. X,pt2. Y);

}

Label1. text= "Distance:" + d.tostring ();

}

else if (E.toolnum = 11)//area, this is a custom tool, this is borrowed from a Netizen's article, thank you

{

mapxlib.points pts = (mapxlib.points) e.points;

Mapxlib.featurefactory dd = axmap1.featurefactory;

Mapxlib.style Style = Axmap1.defaultstyle;

Label1. text= "Area:" + DD. Createregion (Pts,style). Area.tostring ();

}

}
#endregion
//*******************************

private void Axmap1_mapviewchanged (object sender, System.EventArgs e)//show proportions when map size changes
{
Label1. Text=axmap1.zoom.tostring ();
}

//*******************************
private void Mutuceng_click (object sender, System.EventArgs e)//Menu button event, display Layer Control Panel
{
AXMAP1.LAYERS.LAYERSDLG (Null,null);
}

private void Menuitem31_click (object sender, System.EventArgs e)//menu button event, show layer layer Select Display window
{
Frmviewlyr frm=new Frmviewlyr ();
frm. Owner=this;
frm. ShowDialog ();
}
private void Menuitem32_click (object sender, System.EventArgs e)//menu button events, controlling the display scale of layers in a new window, etc.
{
#region the magnification of the control layer in the new window, here is the omitted code
Omitted here, the main use is mapunit and Mapzoom *******************
Here is pseudocode, is the mapx5.0 of the sample program VB code, and the same as above
//
Zoomtext.text = FMainForm.Map1.Zoom

' Set the Unit combo box to the '

' Take a short cut:units # 0 through correspond to Combo list number

If FMainForm.Map1.MapUnit < Then

Unitcombo.listindex = FMainForm.Map1.MapUnit

Else

Select Case FMainForm.Map1.MapUnit

Case Miunitlink

Unitcombo.listindex = 14

Case Miunitchain

Unitcombo.listindex = 15

Case Miunitrod

Unitcombo.listindex = 16

End Select

End If



' Save the ' parameters so ' view can be

' Restored if ' Cancel ' is pressed

Oldzoom = FMainForm.Map1.Zoom

Oldunit = FMainForm.Map1.MapUnit
#endregion

}
//*******************************
private void Axmap1_thememodifyrequested (object sender, Axmapxlib.cmapxevents_thememodifyrequestedevent e)
{
E.theme
}

private void Axmap1_mousedownevent (object sender, Axmapxlib.cmapxevents_mousedownevent e)
{
e.button=
}

private void Menuitem4_click (object sender, System.EventArgs e)//Menu button event, general selection map
{
Axmap1.currenttool=mapxlib.toolconstants.miselecttool;
Menuitem4.radiocheck=true;
}

private void Menuitem5_click (object sender, System.EventArgs e)//menu button event, rectangular selection map
{
Axmap1.currenttool=mapxlib.toolconstants.mirectselecttool;
Menuitem5.radiocheck=true;
}

private void Menuitem6_click (object sender, System.EventArgs e)//menu button event, circle Select Map
{
Axmap1.currenttool=mapxlib.toolconstants.miradiusselecttool;
Menuitem6.radiocheck=true;
}

private void Menuitem7_click (object sender, System.EventArgs e)
{
Axmap1.currenttool=mapxlib.toolconstants.mipolygonselecttool; Menu button events, polygon selection map
Menuitem7.radiocheck=true;
}

private void Menuitem8_click (object sender, System.EventArgs e)
{
Axmap1.currenttool=mapxlib.toolconstants.milabeltool; Menu button events, line callout map
}

private void Menuitem9_click (object sender, System.EventArgs e)
{
Axmap1.currenttool=mapxlib.toolconstants. ; Menu button Events, polyline callout Map
}

private void Menuitem11_click (object sender, System.EventArgs e)
{
Axmap1.currenttool=mapxlib.toolconstants.misymboltool; Menu button events, creating tools that can add symbols to the map, is actually a annotations operation on MAPX
}

private void Menuitem12_click (object sender, System.EventArgs e)
{
Axmap1.currenttool=mapxlib.toolconstants.mitexttool; Menu button events, creating tools that can add text to the map, is actually a annotations operation on MAPX
}

private void Menuitem13_click (object sender, System.EventArgs e)
{
AxMap1.Annotations.RemoveAll (); To remove all the annotation information is actually the annotations operation of MAPX.
}

private void Menuitem14_click (object sender, System.EventArgs e)
{
Gistestbymyself. Frmannotation frm=new frmannotation (AxMap1.DefaultStyle.Clone ());
frm. Owner=this;
frm. ShowDialog (); Unfinished, see D:\Program files\mapinfo\mapx 5.0\samples50\visualbasic\vb5sample
}

private void Menuitem16_click (object sender, System.EventArgs e)//menu button event, displaying Properties window
{
Axmap1.propertypage ();
}

private void Menuitem19_click (object sender, System.EventArgs e)//Display mapx About dialog box
{
Axmap1.aboutbox ();
}

private void Menuitem29_click (object sender, System.EventArgs e)//menu button event, call window, change coordinates of map, or call projection
{
AxMap1.DisplayCoordSys.PickCoordSys (Null,null);
Axmap1.numericcoordsys=axmap1.displaycoordsys;
}

private void Axmap1_mouseupevent (object sender, Axmapxlib.cmapxevents_mouseupevent e)//mouse event, right-click, Popup property box
{
if (e.button==2)
Axmap1.propertypage ();
}





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.