private void btnOK_Click(object sender, EventArgs e) { if (m_pPageLayoutCtl == null) { return; } string strFullpath = txtFolder.Text; if (strFullpath[strFullpath.Length - 1] != System.IO.Path.DirectorySeparatorChar) { strFullpath += System.IO.Path.DirectorySeparatorChar; } string strDocName = CreateMxdFolderAndGDB(strFullpath, m_pPageLayoutCtl.DocumentFilename); string strFullGdbName = strFullpath + strDocName + ".gdb"; string strFullDocName = strFullpath + strDocName + ".mxd"; //另存地图文档 ClsGDBDataCommon cls = new ClsGDBDataCommon(); m_pMapDoc = cls.SaveAsDocument(m_pPageLayoutCtl, strFullDocName); //n if (ExportLayers(m_pMapDoc, strFullGdbName, radioLayer.Checked)) { m_pMapDoc.Save(true, false); m_strDocNameNew = m_pMapDoc.DocumentFilename; m_pMapDoc.Close(); MessageBox.Show("导出成功!"); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IPageLayoutControl3 pPageLayoutControl = null; if (m_hookHelper.Hook is IToolbarControl) { pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IPageLayoutControl3) { pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook; } else { MessageBox.Show("µ±Ç°½çÃæ±ØÐëÊÇPageLayoutControl½çÃæ!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } SaveFileDialog dlgFile = new SaveFileDialog();//ÒÔ¶Ô»°¿òÑ¡ÔñÎĵµÂ·¾¶ dlgFile.Title = "Áí´æµØͼÎĵµ"; dlgFile.Filter = "Map Documents(*.mxd)|*.mxd"; string sFilePath = string.Empty; if (dlgFile.ShowDialog() == DialogResult.OK) { sFilePath = dlgFile.FileName; ClsGDBDataCommon cls = new ClsGDBDataCommon(); m_pDoc = cls.SaveAsDocument(pPageLayoutControl, sFilePath); } }