大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> MapObjects2.2 在C#中的应用(基本地图功能

MapObjects2.2 在C#中的应用(基本地图功能

时间: 2021-07-31 作者:daque

MapObjects2.2 在C#中的应用(基本地图功能)要害字:mapobjects 2.2 c#只是实行了舆图的夸大、减少、遨游、全图、隔绝、表面积等功效。/* * 杨雨田 blue_bat@126.com * 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; } }}

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.