国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

MapObjects2.2 在C#中的應用(基本地圖功能

2024-07-21 02:19:37
字體:
來源:轉載
供稿:網友
mapobjects2.2 在c#中的應用(基本地圖功能)

關鍵字:mapobjects 2.2 c#



僅僅實現了地圖的放大、縮小、漫游、全圖、距離、面積等功能。



/*

* 楊雨田 [email protected]

* 2004年7月27日

*/

using system;

using system.drawing;

using system.collections;

using system.componentmodel;

using system.windows.forms;

using system.data;



namespace artemis.ivs.test

{

/// <summary>

/// 處理實例

/// </summary>

public class frmmain : system.windows.forms.form

{

private axmapobjects2.axmap mapmain;

private system.windows.forms.mainmenu mainmenu1;

private system.windows.forms.menuitem mizoomin;

private system.windows.forms.menuitem mizoomout;

private system.windows.forms.menuitem mipan;

private system.windows.forms.menuitem mifullview;

private int curoperate = 0;

private system.windows.forms.menuitem miselectbypoint;

private system.windows.forms.menuitem midistance;

private system.windows.forms.menuitem miarea;

/// <summary>

/// 必需的設計器變量。

/// </summary>

private system.componentmodel.container components = null;



public frmmain()

{

//

// windows 窗體設計器支持所必需的

//

initializecomponent();

}



/// <summary>

/// 清理所有正在使用的資源。

/// </summary>

protected override void dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.dispose();

}

}

base.dispose( disposing );

}



#region windows 窗體設計器生成的代碼

/// <summary>

/// 設計器支持所需的方法 - 不要使用代碼編輯器修改

/// 此方法的內容。

/// </summary>

private void initializecomponent()

{

system.resources.resourcemanager resources = new system.resources.resourcemanager(typeof(frmmain));

this.mapmain = new axmapobjects2.axmap();

this.mainmenu1 = new system.windows.forms.mainmenu();

this.mizoomin = new system.windows.forms.menuitem();

this.mizoomout = new system.windows.forms.menuitem();

this.mipan = new system.windows.forms.menuitem();

this.mifullview = new system.windows.forms.menuitem();

this.miselectbypoint = new system.windows.forms.menuitem();

this.midistance = new system.windows.forms.menuitem();

this.miarea = new system.windows.forms.menuitem();

((system.componentmodel.isupportinitialize)(this.mapmain)).begininit();

this.suspendlayout();

//

// mapmain

//

this.mapmain.dock = system.windows.forms.dockstyle.fill;

this.mapmain.location = new system.drawing.point(0, 0);

this.mapmain.name = "mapmain";

this.mapmain.ocxstate = ((system.windows.forms.axhost.state)(resources.getobject("mapmain.ocxstate")));

this.mapmain.size = new system.drawing.size(592, 401);

this.mapmain.tabindex = 0;

this.mapmain.mousedownevent += new axmapobjects2._dmapevents_mousedowneventhandler(this.mapmain_mousedownevent);

//

// mainmenu1

//

this.mainmenu1.menuitems.addrange(new system.windows.forms.menuitem[] {

this.mizoomin,

this.mizoomout,

this.mipan,

this.mifullview,

this.miselectbypoint,

this.midistance,

this.miarea});

//

// mizoomin

//

this.mizoomin.index = 0;

this.mizoomin.text = "放大";

this.mizoomin.click += new system.eventhandler(this.mizoomin_click);

//

// mizoomout

//

this.mizoomout.index = 1;

this.mizoomout.text = "縮小";

this.mizoomout.click += new system.eventhandler(this.mizoomout_click);

//

// mipan

//

this.mipan.index = 2;

this.mipan.text = "漫游";

this.mipan.click += new system.eventhandler(this.mipan_click);

//

// mifullview

//

this.mifullview.index = 3;

this.mifullview.text = "全圖";

this.mifullview.click += new system.eventhandler(this.mifullview_click);

//

// miselectbypoint

//

this.miselectbypoint.index = 4;

this.miselectbypoint.text = "點選";

this.miselectbypoint.click += new system.eventhandler(this.miselectbypoint_click);

//

// midistance

//

this.midistance.index = 5;

this.midistance.text = "距離";

this.midistance.click += new system.eventhandler(this.midistance_click);

//

// miarea

//

this.miarea.index = 6;

this.miarea.text = "面積";

this.miarea.click += new system.eventhandler(this.miarea_click);

//

// frmmain

//

this.autoscalebasesize = new system.drawing.size(6, 14);

this.clientsize = new system.drawing.size(592, 401);

this.controls.add(this.mapmain);

this.menu = this.mainmenu1;

this.name = "frmmain";

this.text = "artemis.ivs.test";

this.load += new system.eventhandler(this.frmmain_load);

((system.componentmodel.isupportinitialize)(this.mapmain)).endinit();

this.resumelayout(false);



}

#endregion



/// <summary>

/// 應用程序的主入口點。

/// </summary>

[stathread]

static void main()

{

application.run(new frmmain());

}



/// <summary>

/// 全圖

/// </summary>

private void mifullview_click(object sender, system.eventargs e)

{

this.curoperate = 4;

mapmain.extent = mapmain.fullextent;

mapmain.mousepointer = mapobjects2.mousepointerconstants.modefault;

}



/// <summary>

/// 漫游

/// </summary>

private void mipan_click(object sender, system.eventargs e)

{

this.curoperate = 3;

mapmain.mousepointer = mapobjects2.mousepointerconstants.mopan;

}



/// <summary>

/// 縮小

/// </summary>

private void mizoomout_click(object sender, system.eventargs e)

{

this.curoperate = 2;

mapmain.mousepointer = mapobjects2.mousepointerconstants.mozoomout;

}



/// <summary>

/// 放大

/// </summary>

private void mizoomin_click(object sender, system.eventargs e)

{

this.curoperate = 1;

mapmain.mousepointer = mapobjects2.mousepointerconstants.mozoomin;

}



/// <summary>

/// 放大縮小等的處理過程

/// </summary>

private void mapmain_mousedownevent(object sender, axmapobjects2._dmapevents_mousedownevent e)

{

mapobjects2.rectangle rect;

mapobjects2.point pt = mapmain.tomappoint(e.x,e.y);



if(e.button == 2) this.curoperate = 0;//右鍵點擊取消



switch(this.curoperate)

{

case 1://放大

{

rect = mapmain.trackrectangle();



if(rect == null|| (rect.width < 0.00005) || (rect.height < 0.00005))

{

rect = mapmain.extent;

rect.scalerectangle(0.6667);

rect.offset(-(rect.center.x - pt.x),-(rect.center.y - pt.y));

}

mapmain.extent = rect;

break;

}

case 2://縮小

{

rect = mapmain.trackrectangle();



if ((null == rect) || (rect.width < 0.00005) || (rect.height < 0.00005))

{

rect = mapmain.extent;

rect.scalerectangle(1.5);

rect.offset(-(rect.center.x - pt.x),-(rect.center.y - pt.y));

}

else

{

double drate = mapmain.extent.width / rect.width * 10;

rect.scalerectangle(drate);

}



mapmain.extent = rect;

break;

}

case 3://漫游

{

mapmain.pan();

break;

}

case 5://點選

{



break;

}

case 6://距離

{

mapobjects2.points pts;

pts = (mapobjects2.points)mapmain.trackline().parts.item(0);

double ddistance = 0;

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

{

ddistance += math.sqrt(pts.item(i).x*pts.item(i).x + pts.item(i).y*pts.item(i).y);

}

this.text = mapmain.tomapdistance((float)ddistance).tostring();

break;

}

case 7://面積

{

mapobjects2.polygon ply = mapmain.trackpolygon();

double darea = ply.area;

this.text = mapmain.tomapdistance((float)darea).tostring();

break;

}

default://箭頭

{

mapmain.mousepointer = mapobjects2.mousepointerconstants.modefault;

break;

}

}

}



/// <summary>

/// 點選

/// </summary>

private void miselectbypoint_click(object sender, system.eventargs e)

{

this.curoperate = 5;

mapmain.mousepointer = mapobjects2.mousepointerconstants.moarrowquestion;

}



/// <summary>

/// 距離

/// </summary>

private void midistance_click(object sender, system.eventargs e)

{

this.curoperate = 6;

mapmain.mousepointer = mapobjects2.mousepointerconstants.mocross;

}



/// <summary>

/// 面積

/// </summary>

private void miarea_click(object sender, system.eventargs e)

{

this.curoperate = 7;

mapmain.mousepointer = mapobjects2.mousepointerconstants.mocross;

}

}

}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新蔡县| 高安市| 夏邑县| 宜宾县| 广灵县| 界首市| 保康县| 和平县| 永安市| 原平市| 吉隆县| 东至县| 苏尼特左旗| 渝中区| 通江县| 沂南县| 手游| 南城县| 鲁山县| 仲巴县| 静宁县| 巴林左旗| 清新县| 武功县| 精河县| 彩票| 大城县| 二连浩特市| 江永县| 江油市| 施秉县| 常德市| 平江县| 金门县| 武乡县| 都昌县| 马关县| 焉耆| 涞水县| 怀化市| 阆中市|