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
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
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.
}
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.