阅读:1419回复:1
[下载]共享AO资料
IMapDocument m_MapDocument;<BR>private void LoadMapDoc()<BR>{<BR>m_MapDocument = new MapDocumentClass();<BR>try<BR>{<BR>//􁠧􁓔􁭛􀓊􁇍􄆱􁸚􄗝􀦪MXD􁭛􀓊<BR>System.Windows.Forms.OpenFileDialog openFileDialog2;<BR>openFileDialog2 = new OpenFileDialog();<BR>openFileDialog2.Title = "Open Map Document";<BR>openFileDialog2.Filter = "Map Documents (*.mxd)|*.mxd";<BR>openFileDialog2.ShowDialog();<BR>string sFilePath = openFileDialog2.FileName;<BR>//􁇚􁭄􁥂􄕑􀜹pMapDocument􁑊􀏢map􁥻􀓊􃘨􃋏􄍋􁴹<BR>m_MapDocument.Open(sFilePath, "");<BR>int i;<BR>for (i = 0 ; i<= pMapDocument.MapCount - 1;i++)<BR>{<BR>//􀏔􀏾IMapDocument􁇍􄈵􀐁􀧃􃛑􁳝􀻮􀏾Map􁇍􄈵􀋈􄘡􀥚􂆣􀏾map􁇍􄈵<BR>axMapControl1.Map = m_MapDocument.get_Map(i);<BR>}<BR>//􀠋􁮄􀴄􀳒<BR>axMapControl1.Refresh();<BR>}<BR>catch( Exception ex)<BR>{<BR>MessageBox.Show(ex.ToString());<BR>}<BR>}<BR>private void SaveDocument()<BR>{<BR>100<BR>//Check that the document is not read only<BR>if (m_MapDocument.get_IsReadOnly(m_MapDocument.DocumentFilename)<BR>== true)<BR>{<BR>MessageBox.Show("This map document is read only!");<BR>return;<BR>}<BR>//Save with the current relative path setting<BR>m_MapDocument.Save(m_MapDocument.UsesRelativePaths,true);<BR>MessageBox.Show("Changes saved successfully!");<BR>}<BR>private void SaveAsDocument ()<BR>{<BR>//Open a file dialog for saving map documents<BR>saveFileDialog1.Title = "Save Map Document As";<BR>saveFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";<BR>saveFileDialog1.ShowDialog();<BR>//Exit if no map document is selected<BR>string sFilePath = saveFileDialog1.FileName;<BR>if (sFilePath == "")<BR>{<BR>return;<BR>}<BR>if (sFilePath == m_MapDocument.DocumentFilename)<BR>{<BR>//Save changes to the current document<BR>SaveDocument();<BR>}<BR>else<BR>{<BR>//SaveAs a new document with relative paths<BR>m_MapDocument.SaveAs(sFilePath, true, true);<BR>//Open document<BR>OpenDocument((sFilePath));<BR>MessageBox.Show("Document saved successfully!");<BR>101<BR>}<BR>}<BR>􁮄􁓎􀏔􀏾􃁎􂱘􀴄􀳒􁭛􁸷􀋈􁑊􁇚􀝊􄕑􀽖 MapControl 􂱘􀒷􂷕􀽖􀏟􀋖<BR>private void mnuNew_Click(object sender, System.EventArgs e)<BR>{<BR>// IMap pMap = new MapClass();<BR>// axMapControl1.Map = pMap ;<BR>MapDocument pMapDocument = new MapDocumentClass();<BR>string sFilePath = @"d:\temp\untitled.mxd";<BR>pMapDocument.New(sFilePath);<BR>pMapDocument.Open(sFilePath,"");<BR>axMapControl1.Map = pMapDocument.get_Map(0);<BR>}
|
|
1楼#
发布于:2008-01-23 09:13
<P>毫无说明,这个。。。太马虎了</P>
<P>而且只是一个加载mxd文档的功能,改进改进</P><img src="images/post/smile/dvbbs/em02.gif" /> |
|
|