GIS大賽第一步
開啟,儲存,另存為
private void openFile_Click(object sender, EventArgs e) { ICommand Cmd = new ControlsOpenDocCommandClass(); Cmd.OnCreate(axMapControl1.Object); Cmd.OnClick(); }
private void 儲存ToolStripMenuItem_Click(object sender, EventArgs e) { SaveMap(axMapControl1.DocumentFilename, axMapControl1.Map); } public void SaveMap(string m_FilePath, IMap m_SaveMap) { try { //document和contents可以記為記錄和內容 IMapDocument pMapDoc = new MapDocumentClass(); //imxdcontents pmxdc = new imxdcontents(); IMxdContents pMxdC = m_SaveMap as IMxdContents; pMapDoc.New(m_FilePath); pMapDoc.ReplaceContents(pMxdC); if(pMapDoc.get_IsReadOnly(pMapDoc.DocumentFilename)==true) { MessageBox.Show("本地圖文件只讀","提示",MessageBoxButtons.OK, MessageBoxIcon.Information); } pMapDoc.Save(pMapDoc.UsesRelativePaths, true); } catch {
} }
private void 另存為ToolStripMenuItem_Click(object sender, EventArgs e) { ICommand Cmd = new ControlsSaveAsDocCommandClass(); Cmd.OnCreate(axMapControl1.Object); Cmd.OnClick(); } }