接下来: //****************************** #region 文件/打开*另存为*导出*按钮的代码
private void menuItem20_Click(object sender, System.EventArgs e) //打开地图文件(*.gst)(模式对话框) { OpenFileDialog openFD=new OpenFileDialog(); openFD.Title="打开地图"; // openFD.DefaultExt=".gst"; openFD.FileName=""; openFD.Filter="Geoset Files (*.gst)|*.gst"; if(openFD.ShowDialog()==DialogResult.OK) if( (openFD.OpenFile() )!=null ) { axMap1.GeoSet=openFD.FileName; //这里存在已各bug,就是当可编辑工具可见时,能打开地图,再点击编辑按钮时, //会出现错误;回避这个错误,请先点击"取消编辑". } } private void menuItem21_Click(object sender, System.EventArgs e) //打开图层文件(*.tab)(模式对话框) { OpenFileDialog openFD=new OpenFileDialog(); openFD.Title="打开图层"; openFD.DefaultExt=".tab"; openFD.FileName=""; openFD.Filter="MapInfo Tables (*.tab)|*.tab"; if(openFD.ShowDialog()==DialogResult.OK) if( (openFD.OpenFile() )!=null ) { axMap1.Layers.Add(openFD.FileName,0); } } private void menuItem23_Click(object sender, System.EventArgs e) //保存按钮,保存为 *.gst 形式 { if(MessageBox.Show("确定要保存吗?","OK or nor",MessageBoxButtons.YesNo)==DialogResult.OK) axMap1.SaveMapAsGeoset(axMap1.TitleText,axMap1.GeoSet); }
private void menuItem24_Click(object sender, System.EventArgs e) //另存为... *.gst 形式 { SaveFileDialog saveFD =new SaveFileDialog(); saveFD.Title="保存地图"; saveFD.FileName=""; saveFD.Filter="Geoset Files (*.gst)|*.gst"; if(saveFD.ShowDialog()==DialogResult.OK) if( (saveFD.OpenFile() )!=null ) { try { axMap1.SaveMapAsGeoset("",saveFD.FileName); //这里有错误,不能保存!!!!!!!!!!!! } catch(Exception e1) { MessageBox.Show(e1.Message); } } }
private void menuItem25_Click(object sender, System.EventArgs e) //到处地图,可以 以各种图像的形式到出地图 { //string ExFmtStr1=.ToString();
SaveFileDialog exportFD =new SaveFileDialog(); exportFD.Title="保存地图"; exportFD.FileName=""; exportFD.Filter= "windows bitmap(*.bmp)|*.bmp"; if(exportFD.ShowDialog()==DialogResult.OK) if( (exportFD.OpenFile() )!=null ) { try { //MapXLib.ExportFormatConstants.miFormatBMP axMap1.ExportMap(exportFD.FileName,MapXLib.ExportFormatConstants.miFormatBMP,axMap1.MapPaperWidth,axMap1.MapScreenHeight); //这里有错误,不能保存!!!!!!!!!!!! } catch(Exception e1) { MessageBox.Show(e1.Message); } } } #endregion
//*************************
//********************************* #region 编辑菜单按钮事件,创建编辑地图工具栏 //********************* private void menuItem27_Click(object sender, System.EventArgs e) //菜单按钮事件,点击后,增加可编辑图层 { if(this.menuItem27.Text.Trim()=="编辑") { ///****************** this.menuItem27.Text="取消编辑"; this.tbadddian.Visible = true; this.tbaddxian.Visible = true; this.tbaddquxian.Visible = true; this.tbaddqumian.Visible = true; this.tbline.Visible = true; this.tbshezhi.Visible = true; ///*************** ///添加信息,初始化可编辑图层 /// MapXLib.Layer newLayer;//=new MapXLib.LayerClass(); MapXLib.LayerInfoClass newLyInfo=new MapXLib.LayerInfoClass(); MapXLib.FieldsClass newField=new MapXLib.FieldsClass(); newField.AddStringField("GeoName",10,10);
newLyInfo.Type=MapXLib.LayerInfoTypeConstants.miLayerInfoTypeTemp; newLyInfo.AddParameter("Name","Temporary Layer"); newLyInfo.AddParameter("Fields",newField); newLayer=axMap1.Layers.Add(newLyInfo,1); newLayer.Editable=true; axMap1.Layers.InsertionLayer=newLayer;
///****************************** ///结束 ///
} else if(this.menuItem27.Text.Trim()=="取消编辑") { this.tbadddian.Visible = false; this.tbaddxian.Visible = false; this.tbaddquxian.Visible = false; this.tbaddqumian.Visible = false; this.tbline.Visible = false; this.tbshezhi.Visible = false; this.menuItem27.Text="编辑";
///******************** ///取消那个可编辑图层 /// axMap1.Layers.Remove(1);
} } #endregion
//********************************* #region 可编辑地图的工具的工具栏
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { if(e.Button==tbadddian) axMap1.CurrentTool=MapXLib.ToolConstants.miAddPointTool; //菜单按钮事件,在有可编辑地图的图层上,添加点,使用“添加点工具” if(e.Button==tbaddxian) axMap1.CurrentTool=MapXLib.ToolConstants.miAddLineTool; //菜单按钮事件,在有可编辑地图的图层上,添加线,使用“添加线工具” if(e.Button==tbaddquxian) axMap1.CurrentTool=MapXLib.ToolConstants.miAddPolylineTool; //菜单按钮事件,在有可编辑地图的图层上,添加曲线,使用“添加曲线工具” if(e.Button==tbaddqumian) axMap1.CurrentTool=MapXLib.ToolConstants.miAddRegionTool; //菜单按钮事件,在有可编辑地图的图层上,添加区域,使用“添加区域工具” if(e.Button==tbshezhi) { Frmeditable frm=new Frmeditable(); //惨淡按钮事件,是对点、线、区域的样式进行设置的窗口 frm.Owner=this; frm.ShowDialog(); }
} #endregion
//***************************** } }

|