private void MapLoadBtn_Click(object sender, EventArgs e) { //地图数据由XML编写 #region 默认数据 MapClass defaultmap = new MapClass(); //临时地图 map.Posptlst.Clear(); //清空地图 map.linestrlst.Clear(); //清空地图 double scale = 18; //地图缩放比例 double Xoffset = 10; double Yoffset = 10; //[wall,point,xy] double[,,] defaultMapWallData = { { { 0, 0 }, { 0, 15 } }, { { 0, 15 }, { 25, 15 } }, { { 25, 15 }, { 25, 0 } }, { { 25, 0 }, { 0, 0 } }, { { 0, 0 }, { 0, 15 } }, { { 8.5, 15 }, { 8.5, 10 } }, { { 8.5, 10 }, { 7.5, 10 } }, { { 0, 7.5 }, { 5, 7.5 } }, { { 5, 7.5 }, { 5.0, 10 } }, { { 0.0, 10 }, { 2.5, 10 } }, { { 4.5, 10 }, { 5, 10 } }, { { 7.5, 7.5 }, { 8.5, 7.5 } }, { { 8.5, 7.5 }, { 8.5, 4.5 } }, { { 8.5, 2.5 }, { 8.5, 0 } }, { { 8.5, 1.5 }, { 9, 1.5 } }, { { 8.5, 5.5 }, { 14.5, 5.5 } }, { { 11, 5.5 }, { 11, 1.5 } }, { { 11, 1.5 }, { 10.5, 1.5 } }, { { 16.5, 5.5 }, { 20, 5.5 } }, { { 17.5, 5.5 }, { 17.5, 0 } }, { { 10.5, 1.5 }, { 11, 1.5 } }, { { 11, 1.5 }, { 11.0, 0 } }, { { 15.5, 15 }, { 15.5, 12.5 } }, { { 15.5, 10.5 }, { 19.5, 10.5 } }, { { 19.5, 10.5 }, { 19.5, 8 } }, { { 19.5, 8 }, { 15.5, 8 } }, { { 15.5, 8 }, { 15.5, 10.5 } } }; MapKeyPoint st = new MapKeyPoint(); MapKeyPoint et = new MapKeyPoint(); for (int i = 0; i < defaultMapWallData.GetLength(0); i++) { for (int j = 0; j < defaultMapWallData.GetLength(1); j++) { PointF p = new PointF(); for (int k = 0; k < defaultMapWallData.GetLength(2); k++) { if (k == 0) { p.X = (float)(defaultMapWallData[i, j, k] * scale + Xoffset); } else { p.Y = (float)(defaultMapWallData[i, j, k] * scale + Yoffset); } } MapKeyPoint mkp = new MapKeyPoint(p, MapKeyPoint.ptype.地形边界点); defaultmap.Posptlst.Add(mkp); if (j == 0) { st = mkp; } else { et = mkp; } } LineStr ls = new LineStr(st, et); defaultmap.linestrlst.Add(ls); } #endregion #region 画布重绘,加载地图 for (int i = 0; i < defaultmap.Posptlst.Count; i++) { add1point(defaultmap.Posptlst[i]); } for (int i = 0; i < defaultmap.linestrlst.Count; i++) { draw1line(defaultmap.linestrlst[i].startpt, defaultmap.linestrlst[i].endpt); } #endregion }