1: 接下来:
2: //******************************
3: #region 文件/打开*另存为*导出*按钮的代码
4:
5: private void menuitem20_click(object sender, system.eventargs e) //打开地图文件(*.gst)(模式对话框)
6: {
7: openfiledialog openfd=new openfiledialog();
8: openfd.title="打开地图"; //
9: openfd.defaultext=".gst";
10: openfd.filename="";
11: openfd.filter="geoset files (*.gst)|*.gst";
12: if(openfd.showdialog()==dialogresult.ok)
13: if( (openfd.openfile() )!=null )
14: {
15: axmap1.geoset=openfd.filename; //这里存在已各bug,就是当可编辑工具可见时,能打开地图,再点击编辑按钮时,
16: //会出现错误;回避这个错误,请先点击"取消编辑".
17: }
18:
19: }
20: private void menuitem21_click(object sender, system.eventargs e) //打开图层文件(*.tab)(模式对话框)
21: {
22: openfiledialog openfd=new openfiledialog();
23: openfd.title="打开图层";
24: openfd.defaultext=".tab";
25: openfd.filename="";
26: openfd.filter="mapinfo tables (*.tab)|*.tab";
27: if(openfd.showdialog()==dialogresult.ok)
28: if( (openfd.openfile() )!=null )
29: {
30: axmap1.layers.add(openfd.filename,0);
31:
32: }
33:
34: }
35: private void menuitem23_click(object sender, system.eventargs e) //保存按钮,保存为 *.gst 形式
36: {
37: if(messagebox.show("确定要保存吗?","ok or nor",messageboxbuttons.yesno)==dialogresult.ok)
38: axmap1.savemapasgeoset(axmap1.titletext,axmap1.geoset);
39:
40: }
41:
42: private void menuitem24_click(object sender, system.eventargs e) //另存为... *.gst 形式
43: {
44: savefiledialog savefd =new savefiledialog();
45: savefd.title="保存地图";
46: savefd.filename="";
47: savefd.filter="geoset files (*.gst)|*.gst";
48: if(savefd.showdialog()==dialogresult.ok)
49: if( (savefd.openfile() )!=null )
50: {
51: try
52: {
53:
54: axmap1.savemapasgeoset("",savefd.filename); //这里有错误,不能保存!!!!!!!!!!!!
55: }
56: catch(exception e1)
57: {
58: messagebox.show(e1.message);
59: }
60:
61: }
62:
63: }
64:
65: private void menuitem25_click(object sender, system.eventargs e) //到处地图,能 以各种图像的形式到出地图
66: {
67: //string exfmtstr1=.tostring();
68:
69:
70: savefiledialog exportfd =new savefiledialog();
71: exportfd.title="保存地图";
72: exportfd.filename="";
73: exportfd.filter= "windows bitmap(*.bmp)|*.bmp";
74: if(exportfd.showdialog()==dialogresult.ok)
75: if( (exportfd.openfile() )!=null )
76: {
77: try
78: { //mapxlib.exportformatconstants.miformatbmp
79: axmap1.exportmap(exportfd.filename,mapxlib.exportformatconstants.miformatbmp,axmap1.mappaperwidth,axmap1.mapscreenheight);
80: //这里有错误,不能保存!!!!!!!!!!!!
81: }
82: catch(exception e1)
83: {
84: messagebox.show(e1.message);
85: }
86:
87: }
88:
89: }
90: #endregion
91:
92: //*************************
93:
94: //*********************************
95: #region 编辑菜单按钮事件,创建编辑地图工具栏
96: //*********************
97: private void menuitem27_click(object sender, system.eventargs e) //菜单按钮事件,点击后,增加可编辑图层
98: {
99: if(this.menuitem27.text.trim()=="编辑")
100: {
101: ///******************
102: this.menuitem27.text="取消编辑";
103: this.tbadddian.visible = true;
104: this.tbaddxian.visible = true;
105: this.tbaddquxian.visible = true;
106: this.tbaddqumian.visible = true;
107: this.tbline.visible = true;
108: this.tbshezhi.visible = true;
109: ///***************
110: ///添加信息,初始化可编辑图层
111: ///
112: mapxlib.layer newlayer;//=new mapxlib.layerclass();
113: mapxlib.layerinfoclass newlyinfo=new mapxlib.layerinfoclass();
114: mapxlib.fieldsclass newfield=new mapxlib.fieldsclass();
115:
116: newfield.addstringfield("geoname",10,10);
117:
118: newlyinfo.type=mapxlib.layerinfotypeconstants.milayerinfotypetemp;
119: newlyinfo.addparameter("name","temporary layer");
120: newlyinfo.addparameter("fields",newfield);
121:
122: newlayer=axmap1.layers.add(newlyinfo,1);
123: newlayer.editable=true;
124: axmap1.layers.insertionlayer=newlayer;
125:
126: ///******************************
127: ///结束
128: ///
129:
130: }
131: else if(this.menuitem27.text.trim()=="取消编辑")
132: {
133: this.tbadddian.visible = false;
134: this.tbaddxian.visible = false;
135: this.tbaddquxian.visible = false;
136: this.tbaddqumian.visible = false;
137: this.tbline.visible = false;
138: this.tbshezhi.visible = false;
139: this.menuitem27.text="编辑";
140:
141: ///********************
142: ///取消那个可编辑图层
143: ///
144: axmap1.layers.remove(1);
145:
146: }
147:
148: }
149: #endregion
150:
151: //*********************************
152: #region 可编辑地图的工具的工具栏
153:
154: private void toolbar1_buttonclick(object sender, system.windows.forms.toolbarbuttonclickeventargs e)
155: {
156: if(e.button==tbadddian)
157: axmap1.currenttool=mapxlib.toolconstants.miaddpointtool; //菜单按钮事件,在有可编辑地图的图层上,添加点,使用“添加点工具”
158: if(e.button==tbaddxian)
159: axmap1.currenttool=mapxlib.toolconstants.miaddlinetool; //菜单按钮事件,在有可编辑地图的图层上,添加线,使用“添加线工具”
160: if(e.button==tbaddquxian)
161: axmap1.currenttool=mapxlib.toolconstants.miaddpolylinetool; //菜单按钮事件,在有可编辑地图的图层上,添加曲线,使用“添加曲线工具”
162: if(e.button==tbaddqumian)
163: axmap1.currenttool=mapxlib.toolconstants.miaddregiontool; //菜单按钮事件,在有可编辑地图的图层上,添加区域,使用“添加区域工具”
164: if(e.button==tbshezhi)
165: {
166: frmeditable frm=new frmeditable(); //惨淡按钮事件,是对点、线、区域的样式进行设置的窗口
167: frm.owner=this;
168: frm.showdialog();
169: }
170:
171: }
172: #endregion
173:
174: //*****************************
175: }
176: }