Пример #1
0
        private void BtnSaveMXD_Click(object sender, EventArgs e)
        {
            //make sure that the current MapDoc is valid first
            if (m_documentFileName != string.Empty && m_mapControl.CheckMxFile(m_documentFileName))
            {
                //create a new instance of a MapDocument class
                IMapDocument mapDoc = new MapDocumentClass();
                //Open the current document into the MapDocument
                mapDoc.Open(m_documentFileName, string.Empty);

                //Make sure that the MapDocument is not readonly
                if (mapDoc.get_IsReadOnly(m_documentFileName))
                {
                    MessageBox.Show("سند فقط خواندنی است");
                    mapDoc.Close();
                    return;
                }

                //Replace the map with the one of the PageLayout
                mapDoc.ReplaceContents((IMxdContents)m_pageLayoutControl.PageLayout);

                //save the document
                mapDoc.Save(mapDoc.UsesRelativePaths, false);
                mapDoc.Close();
            }
        }
Пример #2
0
 /// <summary>
 /// 保存地图文档命令
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Save_Click(object sender, EventArgs e)
 {
     // 首先确认当前地图文档是否有效
     if (null != m_pageLayoutControl.DocumentFilename && m_mapControl.CheckMxFile(m_pageLayoutControl.DocumentFilename))
     {
         // 创建一个新的地图文档实例
         IMapDocument mapDoc = new MapDocumentClass();
         // 打开当前地图文档
         mapDoc.Open(m_pageLayoutControl.DocumentFilename, string.Empty);
         // 用 PageLayout 中的文档替换当前文档中的 PageLayout 部分
         mapDoc.ReplaceContents((IMxdContents)m_pageLayoutControl.PageLayout);
         // 保存地图文档
         mapDoc.Save(mapDoc.UsesRelativePaths, false);
         mapDoc.Close();
     }
 }
        /// <summary>
        /// Save document menu event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>Save the current MapDocument</remarks>
        private void menuSaveDoc_Click(object sender, System.EventArgs e)
        {
            //make sure that the current MapDoc is valid first
            if (m_documentFileName != string.Empty && m_mapControl.CheckMxFile(m_documentFileName))
            {
                //create a new instance of a MapDocument class
                IMapDocument mapDoc = new MapDocumentClass();
                //Open the current document into the MapDocument
                mapDoc.Open(m_documentFileName, string.Empty);

                //Replace the map with the one of the PageLayout
                mapDoc.ReplaceContents((IMxdContents)m_pageLayoutControl.PageLayout);

                //save the document
                mapDoc.Save(mapDoc.UsesRelativePaths, false);
                mapDoc.Close();
            }
        }