zoukankan      html  css  js  c++  java
  • c#中调用mapx5.0(一).NET教程,C#语言

       1:  这是 我在.net环境中调用mapx5.0控件 的一次test,前几次网上没有发现这方面的文章,所以自己 
       2:  把几个代码拿出 来:这里有些代码是自动生成的,但只要把几篇文章的代码直接拷贝到工程里 就 
       3:  能直接运行的。 
       4:   
       5:  using system.drawing; 
       6:  using system.collections; 
       7:  using system.componentmodel; 
       8:  using system.windows.forms; 
       9:  using system.data; 
      10:  using system.io; 
      11:   
      12:  namespace gistestbymyself 
      13:  { 
      14:  /// <summary> 
      15:  /// form1 的摘要说明。 
      16:  /// </summary> 
      17:  public class frmmain : system.windows.forms.form 
      18:  { 
      19:   
      20:  #region 私有变量的声明 
      21:  private axmapxlib.axmap axmap1; 
      22:  private axmapxlib.axmap axmap2; 
      23:   
      24:  private double zoom; 
      25:  private double centerx; 
      26:  private double centery; 
      27:  #endregion 
      28:   
      29:  #region windows 窗体上拖入窗体的控件 
      30:  /// <summary> 
      31:  /// 
      32:  /// 窗体信息。 
      33:  /// </summary> 
      34:   
      35:   
      36:   
      37:   
      38:   
      39:  private system.windows.forms.toolbar toolbar2; 
      40:  private system.windows.forms.toolbarbutton tbfangda; 
      41:  private system.windows.forms.toolbarbutton tbbianxiao; 
      42:  private system.windows.forms.toolbarbutton tbmanyou; 
      43:  private system.windows.forms.toolbarbutton tbbiaozhu; 
      44:  private system.windows.forms.toolbarbutton tbjuli; 
      45:  private system.windows.forms.toolbarbutton tbshuaxin; 
      46:  private system.windows.forms.toolbarbutton tbxiangxi; 
      47:  private system.windows.forms.toolbarbutton tbzuiduan; 
      48:  private system.windows.forms.toolbarbutton tbmianji; 
      49:  private system.windows.forms.label label1; 
      50:  private system.windows.forms.toolbarbutton tbxuanze; 
      51:  private system.windows.forms.mainmenu mainmenu1; 
      52:  private system.windows.forms.menuitem menuitem1; 
      53:  private system.windows.forms.menuitem menuitem2; 
      54:  private system.windows.forms.menuitem menuitem3; 
      55:  private system.windows.forms.menuitem mutuceng; 
      56:  private system.windows.forms.contextmenu comu; 
      57:  private system.windows.forms.menuitem menuitem4; 
      58:  private system.windows.forms.menuitem menuitem5; 
      59:  private system.windows.forms.menuitem menuitem6; 
      60:  private system.windows.forms.menuitem menuitem7; 
      61:  private system.windows.forms.contextmenu comu1; 
      62:  private system.windows.forms.menuitem menuitem8; 
      63:  private system.windows.forms.menuitem menuitem9; 
      64:  private system.windows.forms.toolbarbutton tbtianjiafuhao; 
      65:  private system.windows.forms.menuitem menuitem10; 
      66:  private system.windows.forms.menuitem menuitem11; 
      67:  private system.windows.forms.menuitem menuitem12; 
      68:  private system.windows.forms.menuitem menuitem13; 
      69:  private system.windows.forms.menuitem menuitem14; 
      70:  private system.windows.forms.menuitem menuitem15; 
      71:  private system.windows.forms.menuitem menuitem16; 
      72:  private system.windows.forms.menuitem menuitem17; 
      73:  private system.windows.forms.menuitem menuitem18; 
      74:  private system.windows.forms.menuitem menuitem19; 
      75:  private system.windows.forms.menuitem menuitem20; 
      76:  private system.windows.forms.menuitem menuitem21; 
      77:  private system.windows.forms.menuitem menuitem22; 
      78:  private system.windows.forms.menuitem menuitem23; 
      79:  private system.windows.forms.menuitem menuitem24; 
      80:  private system.windows.forms.menuitem menuitem25; 
      81:  private system.windows.forms.menuitem menuitem26; 
      82:  private system.windows.forms.splitter splitter1; 
      83:  private system.windows.forms.menuitem menuitem27; 
      84:  private system.windows.forms.toolbar toolbar1; 
      85:  private system.windows.forms.toolbarbutton tbadddian; 
      86:  private system.windows.forms.toolbarbutton tbaddxian; 
      87:  private system.windows.forms.toolbarbutton tbaddquxian; 
      88:  private system.windows.forms.toolbarbutton tbaddqumian; 
      89:  private system.windows.forms.toolbarbutton tbshezhi; 
      90:  private system.windows.forms.toolbarbutton tbline; 
      91:  private system.windows.forms.menuitem menuitem28; 
      92:  private system.windows.forms.menuitem menuitem29; 
      93:  private system.windows.forms.menuitem menuitem30; 
      94:  private system.windows.forms.menuitem menuitem31; 
      95:  private system.windows.forms.menuitem menuitem32; 
      96:  private system.windows.forms.menuitem menuitem33; 
      97:  private system.windows.forms.menuitem menuitem34; 
      98:  private system.windows.forms.menuitem menuitem35; 
      99:  /// <summary> 
     100:  /// 必需的设计器变量。 
     101:  /// </summary> 
     102:  private system.componentmodel.container components = null; 
     103:   
     104:  #endregion 
     105:   
     106:  #region frmmain类的初始化和form_load时发生时的动作 
     107:   
     108:  public frmmain() 
     109:  { 
     110:  // 
     111:  // windows 窗体设计器支持所必需的 
     112:  // 
     113:  initializecomponent(); 
     114:   
     115:  // 
     116:  // todo: 在 initializecomponent 调用后添加所有构造函数代码 
     117:  // 
     118:  this.zoom=axmap1.zoom; //取得初始化时的地图比例 
     119:  this.centerx=axmap1.centerx; 
     120:  this.centery=axmap1.centery; //取得初始化时的地图坐标,供刷新时使用 
     121:   
     122:  axmap1.createcustomtool(10,mapxlib.tooltypeconstants.mitooltypepoly,mapxlib.cursorconstants.microsscursor,null,null,false);
     123:  //创建距离工具 
     124:   
     125:  axmap1.createcustomtool(11,mapxlib.tooltypeconstants.mitooltypepolygon,mapxlib.cursorconstants.microsscursor,null,null,false);
     126:  //创建面积工具 
     127:   
     128:   
     129:   
     130:  } 
     131:  //********************************* 
     132:  private void form1_load(object sender, system.eventargs e) 
     133:  { 
     134:   
     135:  axmap1.geoset=@"d:\....\china.gst"; 
     136:   
     137:  axmap2.geoset= directory.getcurrentdirectory()+ @"\....\*.gst"; 
     138:   
     139:  axmap1.titletext="中国"; 
     140:  axmap2.titletext="***"; 
     141:  } 
     142:   
     143:  #endregion 
     144:  //***************************** 
     145:   
     146:  #region windows 窗体设计器生成的代码 
     147:  /// <summary> 
     148:  /// 设计器支持所需的方法 - 不要使用代码编辑器修改 
     149:  /// 此方法的内容。 
     150:  /// </summary> 
     151:  /// <summary> 
     152:  /// 清理所有正在使用的资源。 
     153:  /// </summary> 
     154:  protected override void dispose( bool disposing ) 
     155:  { 
     156:  if( disposing ) 
     157:  { 
     158:  if (components != null) 
     159:  { 
     160:  components.dispose(); 
     161:  } 
     162:  } 
     163:  base.dispose( disposing ); 
     164:  } 
     165:   
     166:   
     167:  private void initializecomponent() 
     168:  { 
     169:  system.resources.resourcemanager resources = new system.resources.resourcemanager(typeof(frmmain)); 
     170:  this.axmap1 = new axmapxlib.axmap(); 
     171:  this.axmap2 = new axmapxlib.axmap(); 
     172:  this.toolbar2 = new system.windows.forms.toolbar(); 
     173:  this.tbxuanze = new system.windows.forms.toolbarbutton(); 
     174:  this.tbfangda = new system.windows.forms.toolbarbutton(); 
     175:  this.tbbianxiao = new system.windows.forms.toolbarbutton(); 
     176:  this.tbmanyou = new system.windows.forms.toolbarbutton(); 
     177:  this.tbbiaozhu = new system.windows.forms.toolbarbutton(); 
     178:  this.tbtianjiafuhao = new system.windows.forms.toolbarbutton(); 
     179:  this.tbjuli = new system.windows.forms.toolbarbutton(); 
     180:  this.tbmianji = new system.windows.forms.toolbarbutton(); 
     181:  this.tbshuaxin = new system.windows.forms.toolbarbutton(); 
     182:  this.tbxiangxi = new system.windows.forms.toolbarbutton(); 
     183:  this.tbzuiduan = new system.windows.forms.toolbarbutton(); 
     184:  this.label1 = new system.windows.forms.label(); 
     185:  this.mainmenu1 = new system.windows.forms.mainmenu(); 
     186:  this.menuitem1 = new system.windows.forms.menuitem(); 
     187:  this.menuitem20 = new system.windows.forms.menuitem(); 
     188:  this.menuitem21 = new system.windows.forms.menuitem(); 
     189:  this.menuitem22 = new system.windows.forms.menuitem(); 
     190:  this.menuitem23 = new system.windows.forms.menuitem(); 
     191:  this.menuitem24 = new system.windows.forms.menuitem(); 
     192:  this.menuitem25 = new system.windows.forms.menuitem(); 
     193:  this.menuitem26 = new system.windows.forms.menuitem(); 
     194:  this.menuitem2 = new system.windows.forms.menuitem(); 
     195:  this.menuitem3 = new system.windows.forms.menuitem(); 
     196:  this.menuitem29 = new system.windows.forms.menuitem(); 
     197:  this.menuitem28 = new system.windows.forms.menuitem(); 
     198:  this.menuitem27 = new system.windows.forms.menuitem(); 
     199:  this.menuitem15 = new system.windows.forms.menuitem(); 
     200:  this.menuitem32 = new system.windows.forms.menuitem(); 
     201:  this.menuitem31 = new system.windows.forms.menuitem(); 
     202:  this.mutuceng = new system.windows.forms.menuitem(); 
     203:  this.menuitem30 = new system.windows.forms.menuitem(); 
     204:  this.menuitem16 = new system.windows.forms.menuitem(); 
     205:  this.menuitem10 = new system.windows.forms.menuitem(); 
     206:  this.menuitem11 = new system.windows.forms.menuitem(); 
     207:  this.menuitem12 = new system.windows.forms.menuitem(); 
     208:  this.menuitem13 = new system.windows.forms.menuitem(); 
     209:  this.menuitem14 = new system.windows.forms.menuitem(); 
     210:  this.menuitem17 = new system.windows.forms.menuitem(); 
     211:  this.menuitem18 = new system.windows.forms.menuitem(); 
     212:  this.menuitem19 = new system.windows.forms.menuitem(); 
     213:  this.comu = new system.windows.forms.contextmenu(); 
     214:  this.menuitem4 = new system.windows.forms.menuitem(); 
     215:  this.menuitem5 = new system.windows.forms.menuitem(); 
     216:  this.menuitem6 = new system.windows.forms.menuitem(); 
     217:  this.menuitem7 = new system.windows.forms.menuitem(); 
     218:  this.comu1 = new system.windows.forms.contextmenu(); 
     219:  this.menuitem8 = new system.windows.forms.menuitem(); 
     220:  this.menuitem9 = new system.windows.forms.menuitem(); 
     221:  this.splitter1 = new system.windows.forms.splitter(); 
     222:  this.toolbar1 = new system.windows.forms.toolbar(); 
     223:  this.tbadddian = new system.windows.forms.toolbarbutton(); 
     224:  this.tbaddxian = new system.windows.forms.toolbarbutton(); 
     225:  this.tbaddquxian = new system.windows.forms.toolbarbutton(); 
     226:  this.tbaddqumian = new system.windows.forms.toolbarbutton(); 
     227:  this.tbline = new system.windows.forms.toolbarbutton(); 
     228:  this.tbshezhi = new system.windows.forms.toolbarbutton(); 
     229:  this.menuitem33 = new system.windows.forms.menuitem(); 
     230:  this.menuitem34 = new system.windows.forms.menuitem(); 
     231:  this.menuitem35 = new system.windows.forms.menuitem(); 
     232:  ((system.componentmodel.isupportinitialize)(this.axmap1)).begininit(); 
     233:  ((system.componentmodel.isupportinitialize)(this.axmap2)).begininit(); 
     234:  this.suspendlayout(); 
     235:  // 
     236:  // axmap1 
     237:  // 
     238:  this.axmap1.anchor = ((system.windows.forms.anchorstyles)((((system.windows.forms.anchorstyles.top | system.windows.forms.anchorstyles.bottom) 
     239:  | system.windows.forms.anchorstyles.left) 
     240:  | system.windows.forms.anchorstyles.right))); 
     241:  this.axmap1.enabled = true; 
     242:  this.axmap1.location = new system.drawing.point(8, 120); 
     243:  this.axmap1.name = "axmap1"; 
     244:  this.axmap1.ocxstate = ((system.windows.forms.axhost.state)(resources.getobject("axmap1.ocxstate"))); 
     245:  this.axmap1.size = new system.drawing.size(424, 339); 
     246:  this.axmap1.tabindex = 0; 
     247:  this.axmap1.polytoolused += new axmapxlib.cmapxevents_polytoolusedeventhandler(this.mapmain_polytoolused); 
     248:  this.axmap1.mouseupevent += new axmapxlib.cmapxevents_mouseupeventhandler(this.axmap1_mouseupevent); 
     249:  this.axmap1.thememodifyrequested += new axmapxlib.cmapxevents_thememodifyrequestedeventhandler(this.axmap1_thememodifyrequested); 
     250:  this.axmap1.mousedownevent += new axmapxlib.cmapxevents_mousedowneventhandler(this.axmap1_mousedownevent); 
     251:  this.axmap1.mapviewchanged += new system.eventhandler(this.axmap1_mapviewchanged); 
     252:  // 
     253:  // axmap2 
     254:  // 
     255:  this.axmap2.anchor = ((system.windows.forms.anchorstyles)((((system.windows.forms.anchorstyles.top | system.windows.forms.anchorstyles.bottom) 
     256:  | system.windows.forms.anchorstyles.left) 
     257:  | system.windows.forms.anchorstyles.right))); 
     258:  this.axmap2.enabled = true; 
     259:  this.axmap2.location = new system.drawing.point(472, 136); 
     260:  this.axmap2.name = "axmap2"; 
     261:  this.axmap2.ocxstate = ((system.windows.forms.axhost.state)(resources.getobject("axmap2.ocxstate"))); 
     262:  this.axmap2.size = new system.drawing.size(240, 203); 
     263:  this.axmap2.tabindex = 1; 
     264:  // 
     265:  // toolbar2 
     266:  // 
     267:  this.toolbar2.buttons.addrange(new system.windows.forms.toolbarbutton[] { 
     268:  this.tbxuanze, 
     269:  this.tbfangda, 
     270:  this.tbbianxiao, 
     271:  this.tbmanyou, 
     272:  this.tbbiaozhu, 
     273:  this.tbtianjiafuhao, 
     274:  this.tbjuli, 
     275:  this.tbmianji, 
     276:  this.tbshuaxin, 
     277:  this.tbxiangxi, 
     278:  this.tbzuiduan}); 
     279:  this.toolbar2.buttonsize = new system.drawing.size(55, 35); 
     280:  this.toolbar2.dropdownarrows = true; 
     281:  this.toolbar2.location = new system.drawing.point(0, 0); 
     282:  this.toolbar2.name = "toolbar2"; 
     283:  this.toolbar2.showtooltips = true; 
     284:  this.toolbar2.size = new system.drawing.size(776, 41); 
     285:  this.toolbar2.tabindex = 3; 
     286:  this.toolbar2.buttonclick += new system.windows.forms.toolbarbuttonclickeventhandler(this.toolbar2_buttonclick); 
     287:  // 
     288:  // tbxuanze 
     289:  // 
     290:  this.tbxuanze.text = "选择"; 
     291:  // 
     292:  // tbfangda 
     293:  // 
     294:  this.tbfangda.text = "放大"; 
     295:  this.tbfangda.tooltiptext = "放大"; 
     296:  // 
     297:  // tbbianxiao 
     298:  // 
     299:  this.tbbianxiao.text = "缩小"; 
     300:  // 
     301:  // tbmanyou 
     302:  // 
     303:  this.tbmanyou.text = "漫游"; 
     304:  // 
     305:  // tbbiaozhu 
     306:  // 
     307:  this.tbbiaozhu.text = "标注"; 
     308:  // 
     309:  // tbtianjiafuhao 
     310:  // 
     311:  this.tbtianjiafuhao.text = "添加符号"; 
     312:  // 
     313:  // tbjuli 
     314:  // 
     315:  this.tbjuli.text = "测距"; 
     316:  // 
     317:  // tbmianji 
     318:  // 
     319:  this.tbmianji.text = "面积"; 
     320:  // 
     321:  // tbshuaxin 
     322:  // 
     323:  this.tbshuaxin.text = "刷新"; 
     324:  // 
     325:  // tbxiangxi 
     326:  // 
     327:  this.tbxiangxi.text = "周详"; 
     328:  // 
     329:  // tbzuiduan 
     330:  // 
     331:  this.tbzuiduan.text = "最短实体"; 
     332:  // 
     333:  // label1 
     334:  // 
     335:  this.label1.location = new system.drawing.point(48, 104); 
     336:  this.label1.name = "label1"; 
     337:  this.label1.size = new system.drawing.size(208, 16); 
     338:  this.label1.tabindex = 4; 
     339:  this.label1.text = "label1"; 
     340:  // 
     341:  // mainmenu1 
     342:  // 
     343:  this.mainmenu1.menuitems.addrange(new system.windows.forms.menuitem[] { 
     344:  this.menuitem1, 
     345:  this.menuitem3, 
     346:  this.menuitem10, 
     347:  this.menuitem17, 
     348:  this.menuitem18}); 
     349:  // 
     350:  // menuitem1 
     351:  // 
     352:  this.menuitem1.index = 0; 
     353:  this.menuitem1.menuitems.addrange(new system.windows.forms.menuitem[] { 
     354:  this.menuitem20, 
     355:  this.menuitem21, 
     356:  this.menuitem22, 
     357:  this.menuitem23, 
     358:  this.menuitem24, 
     359:  this.menuitem25, 
     360:  this.menuitem26, 
     361:  this.menuitem33, 
     362:  this.menuitem35, 
     363:  this.menuitem34, 
     364:  this.menuitem2}); 
     365:  this.menuitem1.text = "文件"; 
     366:  // 
     367:  // menuitem20 
     368:  // 
     369:  this.menuitem20.index = 0; 
     370:  this.menuitem20.text = "打开地图..."; 
     371:  this.menuitem20.click += new system.eventhandler(this.menuitem20_click); 
     372:  // 
     373:  // menuitem21 
     374:  // 
     375:  this.menuitem21.index = 1; 
     376:  this.menuitem21.text = "添加图层..."; 
     377:  this.menuitem21.click += new system.eventhandler(this.menuitem21_click); 
     378:  // 
     379:  // menuitem22 
     380:  // 
     381:  this.menuitem22.index = 2; 
     382:  this.menuitem22.text = "-"; 
     383:  // 
     384:  // menuitem23 
     385:  // 
     386:  this.menuitem23.index = 3; 
     387:  this.menuitem23.text = "保存"; 
     388:  this.menuitem23.click += new system.eventhandler(this.menuitem23_click); 
     389:  // 
     390:  // menuitem24 
     391:  // 
     392:  this.menuitem24.index = 4; 
     393:  this.menuitem24.text = "另存为..."; 
     394:  this.menuitem24.click += new system.eventhandler(this.menuitem24_click); 
     395:  // 
     396:  // menuitem25 
     397:  // 
     398:  this.menuitem25.index = 5; 
     399:  this.menuitem25.text = "导出.."; 
     400:  this.menuitem25.click += new system.eventhandler(this.menuitem25_click); 
     401:  // 
     402:  // menuitem26 
     403:  // 
     404:  this.menuitem26.index = 6; 
     405:  this.menuitem26.text = "-"; 
     406:  // 
     407:  // menuitem2 
     408:  // 
     409:  this.menuitem2.index = 10; 
     410:  this.menuitem2.text = "退出"; 
     411:  // 
     412:  // menuitem3 
     413:  // 
     414:  this.menuitem3.index = 1; 
     415:  this.menuitem3.menuitems.addrange(new system.windows.forms.menuitem[] { 
     416:  this.menuitem29, 
     417:  this.menuitem28, 
     418:  this.menuitem27, 
     419:  this.menuitem15, 
     420:  this.menuitem32, 
     421:  this.menuitem31, 
     422:  this.mutuceng, 
     423:  this.menuitem30, 
     424:  this.menuitem16}); 
     425:  this.menuitem3.text = "地图"; 
     426:  // 
     427:  // menuitem29 
     428:  // 
     429:  this.menuitem29.index = 0; 
     430:  this.menuitem29.text = "坐标变换(投影)"; 
     431:  this.menuitem29.click += new system.eventhandler(this.menuitem29_click); 
     432:  // 
     433:  // menuitem28 
     434:  // 
     435:  this.menuitem28.index = 1; 
     436:  this.menuitem28.text = "-"; 
     437:  // 
     438:  // menuitem27 
     439:  // 
     440:  this.menuitem27.index = 2; 
     441:  this.menuitem27.text = "编辑"; 
     442:  this.menuitem27.click += new system.eventhandler(this.menuitem27_click); 
     443:  // 
     444:  // menuitem15 
     445:  // 
     446:  this.menuitem15.index = 3; 
     447:  this.menuitem15.text = "-"; 
     448:  // 
     449:  // menuitem32 
     450:  // 
     451:  this.menuitem32.index = 4; 
     452:  this.menuitem32.text = "缩放图层"; 
     453:  this.menuitem32.click += new system.eventhandler(this.menuitem32_click); 
     454:  // 
     455:  // menuitem31 
     456:  // 
     457:  this.menuitem31.index = 5; 
     458:  this.menuitem31.text = "选择图层"; 
     459:  this.menuitem31.click += new system.eventhandler(this.menuitem31_click); 
     460:  // 
     461:  // mutuceng 
     462:  // 
     463:  this.mutuceng.index = 6; 
     464:  this.mutuceng.text = "图层控制"; 
     465:  this.mutuceng.click += new system.eventhandler(this.mutuceng_click); 
     466:  // 
     467:  // menuitem30 
     468:  // 
     469:  this.menuitem30.index = 7; 
     470:  this.menuitem30.text = "-"; 
     471:  // 
     472:  // menuitem16 
     473:  // 
     474:  this.menuitem16.index = 8; 
     475:  this.menuitem16.text = "属性"; 
     476:  this.menuitem16.click += new system.eventhandler(this.menuitem16_click); 
     477:  // 
     478:  // menuitem10 
     479:  // 
     480:  this.menuitem10.index = 2; 
     481:  this.menuitem10.menuitems.addrange(new system.windows.forms.menuitem[] { 
     482:  this.menuitem11, 
     483:  this.menuitem12, 
     484:  this.menuitem13, 
     485:  this.menuitem14}); 
     486:  this.menuitem10.text = "注释"; 
     487:  // 
     488:  // menuitem11 
     489:  // 
     490:  this.menuitem11.index = 0; 
     491:  this.menuitem11.text = "添加符号"; 
     492:  this.menuitem11.click += new system.eventhandler(this.menuitem11_click); 
     493:  // 
     494:  // menuitem12 
     495:  // 
     496:  this.menuitem12.index = 1; 
     497:  this.menuitem12.text = "添加文本"; 
     498:  this.menuitem12.click += new system.eventhandler(this.menuitem12_click); 
     499:  // 
     500:  // menuitem13 
     501:  // 
     502:  this.menuitem13.index = 2; 
     503:  this.menuitem13.text = "移除"; 
     504:  this.menuitem13.click += new system.eventhandler(this.menuitem13_click); 
     505:  // 
     506:  // menuitem14 
     507:  // 
     508:  this.menuitem14.index = 3; 
     509:  this.menuitem14.text = "设置"; 
     510:  this.menuitem14.click += new system.eventhandler(this.menuitem14_click); 
     511:  // 
     512:  // menuitem17 
     513:  // 
     514:  this.menuitem17.index = 3; 
     515:  this.menuitem17.text = "窗口"; 
     516:  // 
     517:  // menuitem18 
     518:  // 
     519:  this.menuitem18.index = 4; 
     520:  this.menuitem18.menuitems.addrange(new system.windows.forms.menuitem[] { 
     521:  this.menuitem19}); 
     522:  this.menuitem18.text = "帮助"; 
     523:  // 
     524:  // menuitem19 
     525:  // 
     526:  this.menuitem19.index = 0; 
     527:  this.menuitem19.text = "关于mapx"; 
     528:  this.menuitem19.click += new system.eventhandler(this.menuitem19_click); 
     529:  // 
     530:  // comu 
     531:  // 
     532:  this.comu.menuitems.addrange(new system.windows.forms.menuitem[] { 
     533:  this.menuitem4, 
     534:  this.menuitem5, 
     535:  this.menuitem6, 
     536:  this.menuitem7}); 
     537:  // 
     538:  // menuitem4 
     539:  // 
     540:  this.menuitem4.index = 0; 
     541:  this.menuitem4.text = "普通"; 
     542:  this.menuitem4.click += new system.eventhandler(this.menuitem4_click); 
     543:  // 
     544:  // menuitem5 
     545:  // 
     546:  this.menuitem5.index = 1; 
     547:  this.menuitem5.text = "矩形"; 
     548:  this.menuitem5.click += new system.eventhandler(this.menuitem5_click); 
     549:  // 
     550:  // menuitem6 
     551:  // 
     552:  this.menuitem6.index = 2; 
     553:  this.menuitem6.text = "圆形"; 
     554:  this.menuitem6.click += new system.eventhandler(this.menuitem6_click); 
     555:  // 
     556:  // menuitem7 
     557:  // 
     558:  this.menuitem7.index = 3; 
     559:  this.menuitem7.text = "多边形"; 
     560:  this.menuitem7.click += new system.eventhandler(this.menuitem7_click); 
     561:  // 
     562:  // comu1 
     563:  // 
     564:  this.comu1.menuitems.addrange(new system.windows.forms.menuitem[] { 
     565:  this.menuitem8, 
     566:  this.menuitem9}); 
     567:  // 
     568:  // menuitem8 
     569:  // 
     570:  this.menuitem8.index = 0; 
     571:  this.menuitem8.text = "添加符号"; 
     572:  this.menuitem8.click += new system.eventhandler(this.menuitem8_click); 
     573:  // 
     574:  // menuitem9 
     575:  // 
     576:  this.menuitem9.index = 1; 
     577:  this.menuitem9.text = "添加"; 
     578:  this.menuitem9.click += new system.eventhandler(this.menuitem9_click); 
     579:  // 
     580:  // splitter1 
     581:  // 
     582:  this.splitter1.location = new system.drawing.point(0, 41); 
     583:  this.splitter1.name = "splitter1"; 
     584:  this.splitter1.size = new system.drawing.size(3, 432); 
     585:  this.splitter1.tabindex = 5; 
     586:  this.splitter1.tabstop = false; 
     587:  // 
     588:  // toolbar1 
     589:  // 
     590:  this.toolbar1.buttons.addrange(new system.windows.forms.toolbarbutton[] { 
     591:  this.tbadddian, 
     592:  this.tbaddxian, 
     593:  this.tbaddquxian, 
     594:  this.tbaddqumian, 
     595:  this.tbline, 
     596:  this.tbshezhi}); 
     597:  this.toolbar1.dock = system.windows.forms.dockstyle.none; 
     598:  this.toolbar1.dropdownarrows = true; 
     599:  this.toolbar1.location = new system.drawing.point(0, 40); 
     600:  this.toolbar1.name = "toolbar1"; 
     601:  this.toolbar1.showtooltips = true; 
     602:  this.toolbar1.size = new system.drawing.size(488, 28); 
     603:  this.toolbar1.tabindex = 6; 
     604:  this.toolbar1.textalign = system.windows.forms.toolbartextalign.right; 
     605:  this.toolbar1.visible = false; 
     606:  this.toolbar1.wrappable = false; 
     607:  this.toolbar1.buttonclick += new system.windows.forms.toolbarbuttonclickeventhandler(this.toolbar1_buttonclick); 
     608:  // 
     609:  // tbadddian 
     610:  // 
     611:  this.tbadddian.text = "点 "; 
     612:  this.tbadddian.visible = false; 
     613:  // 
     614:  // tbaddxian 
     615:  // 
     616:  this.tbaddxian.text = "线 "; 
     617:  this.tbaddxian.visible = false; 
     618:  // 
     619:  // tbaddquxian 
     620:  // 
     621:  this.tbaddquxian.text = "曲线 "; 
     622:  this.tbaddquxian.visible = false; 
     623:  // 
     624:  // tbaddqumian 
     625:  // 
     626:  this.tbaddqumian.text = "面 "; 
     627:  this.tbaddqumian.visible = false; 
     628:  // 
     629:  // tbline 
     630:  // 
     631:  this.tbline.style = system.windows.forms.toolbarbuttonstyle.separator; 
     632:  // 
     633:  // tbshezhi 
     634:  // 
     635:  this.tbshezhi.text = "设置 "; 
     636:  this.tbshezhi.visible = false; 
     637:  // 
     638:  // menuitem33 
     639:  // 
     640:  this.menuitem33.index = 7; 
     641:  this.menuitem33.text = "打印设置"; 
     642:  // 
     643:  // menuitem34 
     644:  // 
     645:  this.menuitem34.index = 9; 
     646:  this.menuitem34.text = "-"; 
     647:  // 
     648:  // menuitem35 
     649:  // 
     650:  this.menuitem35.index = 8; 
     651:  this.menuitem35.text = "打印..."; 
     652:  // 
     653:  // frmmain 
     654:  // 
     655:  this.autoscalebasesize = new system.drawing.size(6, 14); 
     656:  this.clientsize = new system.drawing.size(776, 473); 
     657:  this.controls.add(this.toolbar1); 
     658:  this.controls.add(this.splitter1); 
     659:  this.controls.add(this.label1); 
     660:  this.controls.add(this.toolbar2); 
     661:  this.controls.add(this.axmap2); 
     662:  this.controls.add(this.axmap1); 
     663:  this.menu = this.mainmenu1; 
     664:  this.name = "frmmain"; 
     665:  this.text = "frmmain"; 
     666:  this.load += new system.eventhandler(this.form1_load); 
     667:  ((system.componentmodel.isupportinitialize)(this.axmap1)).endinit(); 
     668:  ((system.componentmodel.isupportinitialize)(this.axmap2)).endinit(); 
     669:  this.resumelayout(false); 
     670:   
     671:  } 
     672:  #endregion 
     673:   
     674:  #region 应用程式的主入口点 
     675:  /// <summary> 
     676:  /// 应用程式的主入口点。 
     677:  /// </summary> 
     678:  [stathread] 
     679:  static void main() 
     680:  { 
     681:  frmmain fmain; 
     682:  application.run(fmain=new frmmain()); 
     683:  } 
     684:  #endregion 
     685:   
     686:  //**************************************** 
     687:  #region axmap1对象的属性操作,一般都在其他窗口里被使用 
     688:  /// <summary> 
     689:  /// 在这里适用属性主要是为了axmap1这个私有的对象能在其他窗体中获得一些需要的改动 
     690:  /// </summary> 
     691:  /// 
     692:  //属性1 
     693:  public mapxlib.style systyle //属性操作,设置或取得符号的样式,在 frmannotation 中使用了该属性, 
     694:  { 
     695:  set 
     696:  { 
     697:  axmap1.defaultstyle=value; 
     698:  } 
     699:  get 
     700:  { 
     701:  return axmap1.defaultstyle; 
     702:  } 
     703:  } 
     704:  //属性2 
     705:  public mapxlib.style editstyle //属性操作,设置或取得在编辑图层时,改动的点,线和曲面的样式 在frmeditable 
     706:  { 
     707:  set //中使用了该属性, 
     708:  { 
     709:  axmap1.autoredraw=true; 
     710:  axmap1.layers.insertionlayer.style=value; 
     711:  } 
     712:  get 
     713:  { 
     714:  axmap1.layers.insertionlayer.overridestyle=true; 
     715:  axmap1.autoredraw=false; 
     716:  return axmap1.layers.insertionlayer.style; 
     717:  } 
     718:  } 
     719:  //属性3 
     720:  public mapxlib.layers layer //属性操作,通过该属性,图层选择显示窗口(frmviewlyr)能操作axmap1的layers属性,
     721:  { //在frmviewlyr_load 时能得到 layers 
     722:  get 
     723:  { 
     724:  return axmap1.layers; 
     725:  } 
     726:   
     727:  } 
     728:  //属性4 
     729:  public string lyrname //属性操作,通过该属性,得到图层选择显示窗口(frmviewlyr)中coblyr.text中的值 
     730:  { //来显示那个图层将被显示 
     731:  set 
     732:  { 
     733:  if(value=="all layers") 
     734:  axmap1.ctlbounds=axmap1.layers.bounds; //注意,这里使用ctlbounds属性(mapx的属性),而不是bounds(.net本身的属性)在.net 
     735:  else 
     736:  axmap1.ctlbounds=axmap1.layers[value].bounds; //环境下,有点改动, 
     737:   
     738:  } 
     739:  } 
     740:   
     741:   
     742:  #endregion 
     743:   
     744:  //*********************************** 
     745:  #region 工具条,里面包含选择、拖动漫游、放大缩小等一些工具 
     746:   
     747:  private void toolbar2_buttonclick(object sender, system.windows.forms.toolbarbuttonclickeventargs e) 
     748:  { 
     749:  try 
     750:  { 
     751:   
     752:  if(e.button==tbfangda) 
     753:  axmap1.currenttool=mapxlib.toolconstants.mizoomintool;//1003 
     754:  if(e.button==tbbianxiao) 
     755:  axmap1.currenttool=mapxlib.toolconstants.mizoomouttool;//缩小地图 
     756:  if(e.button==tbmanyou) 
     757:  axmap1.currenttool=mapxlib.toolconstants.mipantool;//漫游地图 
     758:  if(e.button==tbbiaozhu) //标注地图 
     759:  { 
     760:  axmap1.currenttool=mapxlib.toolconstants.milabeltool; 
     761:   
     762:  //point p=new point(20+55*5,20); 
     763:  //comu1.show(toolbar2,p); 
     764:   
     765:  } 
     766:  if(e.button==tbtianjiafuhao) 
     767:  axmap1.currenttool=mapxlib.toolconstants.misymboltool; 
     768:  if(e.button==tbjuli) 
     769:  axmap1.currenttool=( mapxlib.toolconstants ) 10; 
     770:  if(e.button==tbmianji) 
     771:  axmap1.currenttool=(mapxlib.toolconstants ) 11; 
     772:  if(e.button==tbshuaxin) 
     773:  { 
     774:  //刷新地图,回到初始状态 
     775:  axmap1.zoomto(this.zoom,this.centerx,this.centery); //恢复初始时的比例 
     776:  //axmap1.annotations.removeall(); 
     777:  axmap1.refresh(); 
     778:  } 
     779:  if(e.button==tbxuanze) 
     780:  { 
     781:  point p=new point(20,20); 
     782:  comu.show(toolbar2,p); //显示选择工具菜单,他允许选择矩形,圆形,多边形等 
     783:  } 
     784:   
     785:   
     786:  } 
     787:  catch(exception e1) 
     788:  { 
     789:  messagebox.show(e1.message); 
     790:  } 
     791:  } 
     792:   
     793:  #endregion 
  • 相关阅读:
    《Twinkle Twinkle Little Star》
    《牛客IOI周赛24-普及组B》
    You have to remove (or rename) that container to be able to reuse that name.
    MySQL查看服务器状态、数据库、表的命令
    【用户不在sudoers文件中】的两种解决方式
    Ubuntu20.04安装Docker时摊上的那些事儿
    Ubuntu20.04安装Docker以后设置阿里云镜像加速
    Ubuntu20.04默认更新源sources.list和第三方源推荐(干货!)
    Ubuntu必备软件之搜狗输入法
    Ubuntu20.04必备软件之截图工具
  • 原文地址:https://www.cnblogs.com/googlegis/p/2978851.html
Copyright © 2011-2022 走看看