日期:2013-03-21  浏览次数:20384 次

接下来:
//******************************
#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