IMapDocument pMapDoc;
private void 保存地图ToolStripMenuItem_Click(object sender, EventArgs e)
{
pMapDoc = new MapDocumentClass();//实例化
pMapDoc.Open(axMapControl1.DocumentFilename, "");//必须的一步,用于将AxMapControl的实例的DocumentFileName传递给pMapDoc的
if (pMapDoc.get_IsReadOnly(pMapDoc.DocumentFilename) == true)//判断是否只读
{
MessageBox.Show("This map is read only");
return;
}
pMapDoc.Save(pMapDoc.UsesRelativePaths, true);
MessageBox.Show("saved successfully");
}
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog2 = new SaveFileDialog();
saveFileDialog2.Title = "save map document as";
saveFileDialog2.Filter = "map document(*.mxd)|*.mxd";
saveFileDialog2.ShowDialog();//打开保存对话框
string filePath = saveFileDialog2.FileName;
if (filePath == "")
{
return;
}
if (filePath == pMapDoc.DocumentFilename)
{
pMapDoc.Save(pMapDoc.UsesRelativePaths, true);
}
else
{
pMapDoc.SaveAs(filePath, true, true);
pMapDoc.Open(filePath, ""); //打开地图
}
}
保存、另存为地图文件
最新推荐文章于 2021-03-31 22:06:34 发布