private void method_0(IMapDocument imapDocument_0) { if (this.object_0 is IPageLayoutControl2) { imapDocument_0.ReplaceContents(((IPageLayoutControl2)this.object_0).PageLayout as IMxdContents); try { imapDocument_0.Save(true, true); } catch (Exception) { } } else if (this.object_0 is IMapControl2) { imapDocument_0.ReplaceContents(((IMapControl2)this.object_0).Map as IMxdContents); try { imapDocument_0.Save(true, true); } catch (Exception) { } } else if (this.object_0 is MapAndPageLayoutControls) { imapDocument_0.ReplaceContents( (this.object_0 as MapAndPageLayoutControls).PageLayoutControl.PageLayout as IMxdContents); imapDocument_0.Save(true, true); } }
private void 保存地图文档ToolStripMenuItem_Click(object sender, EventArgs e) { try { m_pMapDoc.Save(); } catch { MessageBox.Show("当前地图文档无法保存", "错误信息"); } }
private void SaveMXD(string sName, ESRI.ArcGIS.Carto.IMap map) { try { _pMapDocument.Save(true, false); } catch { _pMapDocument.Save(false, false); } _pMapDocument.Close(); }
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("导出成功!"); } }
//保存地图文档 private void saveDocument() { if (mapDocument == null) { MessageBox.Show("地图文档对象为空,请先加载地图文档"); } else { if (mapDocument.get_IsReadOnly(mapDocument.DocumentFilename) == true) { MessageBox.Show("地图文档是只读的无法保存"); } else { string fileSavePath = @"E:\World\newworld1.mxd"; try { mapDocument.Save(mapDocument.UsesRelativePaths, true); MessageBox.Show("保存地图文档成功"); } catch (Exception e) { MessageBox.Show("保存地图文档失败!!!" + e.ToString()); } } } }
private void menuSaveDoc_Click(object sender, EventArgs e) { if (m_MapDocument.get_IsReadOnly(m_MapDocument.DocumentFilename)) { MessageBox.Show("This map document is read only!"); return; } m_MapDocument.Save(m_MapDocument.UsesRelativePaths, true); MessageBox.Show("Changes saved successfully!"); ////execute Save Document command //if (m_mapControl.CheckMxFile(m_mapDocumentName)) //{ // //create a new instance of a MapDocument // IMapDocument mapDoc = new MapDocumentClass(); // mapDoc.Open(m_mapDocumentName, string.Empty); // //Make sure that the MapDocument is not readonly // if (mapDoc.get_IsReadOnly(m_mapDocumentName)) // { // MessageBox.Show("Map document is read only!"); // mapDoc.Close(); // return; // } // //Replace its contents with the current map // mapDoc.ReplaceContents((IMxdContents)m_mapControl.Map); // //save the MapDocument in order to persist it // mapDoc.Save(mapDoc.UsesRelativePaths, false); // //close the MapDocument // mapDoc.Close(); }
/// <summary> /// 根据地图出图配置,设置地图文档并导出地图 /// </summary> /// <param name="cfg"></param> /// <param name="mapDoc"></param> protected virtual void ExportMapMainOperation(MapExportInfo cfg, IMapDocument mapDoc) { //设置数据源、定义查询、比例尺、显示范围 var graphicsContainer = mapDoc.PageLayout as IGraphicsContainer; foreach (var mapFrameInfo in cfg.MapFrames) { SetMapFrame(graphicsContainer, mapFrameInfo); } //设置元素的值 foreach (var elementInfo in cfg.Elements) { var elements = graphicsContainer.GetElementsByKeyword(elementInfo.Name); SetElementsValue(elements, elementInfo.ValueType, elementInfo.Value); } //保存地图,导出图片 mapDoc.Save(); foreach (var exportPicture in cfg.ExportPictures) { var outputPath = Path.Combine(cfg.ExportDirectory, cfg.ExportFileName + exportPicture.PicExtension); mapDoc.PageLayout.ExportToPicture(outputPath, exportPicture.Dpi); } //关闭文档,释放资源 mapDoc.Close(); Marshal.ReleaseComObject(mapDoc); }
private void FormMain_Load(object sender, EventArgs e) { axTOCControl_main.SetBuddyControl(axMapControl_main); m_pMapC2 = axMapControl_main.Object as IMapControl2; m_pMapDoc = new MapDocumentClass(); axMapControl_main.OnMouseDown += axMapControl_main_OnMouseDown; // 清空地图选择集 btn_clearselect.Click += (object s, EventArgs ent) => { m_pMapC2.Map.ClearSelection(); (m_pMapC2.Map as IGraphicsContainer).DeleteAllElements(); m_pMapC2.Refresh(); m_isIdentify = false; m_isDraw = false; m_isAddpoint = false; }; // a. 打开地图文档功能(地图文档位于AirQuality文件夹下) LoadMxd(); // b. 退出程序并保存地图文档功能 this.FormClosing += (object s, FormClosingEventArgs ent) => { m_pMapDoc.Save(); }; // c. 在地图上点击,选择一个监测站点,并显示该监测站点的属性信息 第①步 btn_Identify.Click += Button_Click; // e. 在地图上选择一个多边形,统计该多边形内部的监测站点内数量,并高亮显示 btn_select.Click += Button_Click; // f. 将Excel中的数据匹配到监测站点 btn_link.Click += Button_Click; // g. 在地图上显示北京各个区县的名称 btn_anno.Click += Button_Click; // h. 为北京各个区县匹配一个符号 btn_symbol.Click += Button_Click; // i. 导出北京区县图层为一个新的数据 btn_outlyr.Click += Button_Click; // j. 在监测站点图层添加一个新站点 btn_addpt.Click += Button_Click; // d. 在监测站点列表中选择一个监测站点后,在地图上高亮显示,缩放至该监测站点,并显示该监测站点的属性信息 第①步 setListBox(); object[] cmds = new object[] { new OpenAttriTable() }; m_pToolbarMenu = new ToolbarMenu(); for (int i = 0; i < cmds.Length; i++) { m_pToolbarMenu.AddItem(cmds[i]); } m_pToolbarMenu.SetHook(m_pMapC2); }
/// <summary> /// 保存当前修改 /// </summary> public void saveDocument() { if (mapDocument.get_IsReadOnly(mapDocument.DocumentFilename) == true)//是否可写 { MessageBox.Show("This map document is read only !"); return; } mapDocument.Save(mapDocument.UsesRelativePaths, true);//以相对路径保存, MessageBox.Show("Changes saved successfully !"); }
void Buttons_Click(object sender, EventArgs e) { #region // 地图文档保存 if ((Button)sender == btn_save) { m_pMapDoc.Save(); MessageBox.Show("地图文档已保存"); } #endregion }
public static void SaveMxd() { if (m_pMapDoc.get_IsReadOnly(m_pMapDoc.DocumentFilename)) { m_pMapDoc.Save(); } else { MessageBox.Show("当前地图文档为只读文档,不能进行保存"); } }
public static void Save() { if (m_pMapDoc.get_IsReadOnly(m_pMapDoc.DocumentFilename)) { m_pMapDoc.Save(); } else { MessageBox.Show(String.Format("无法保存地图文档", m_pMapDoc.DocumentFilename)); } }
//保存地图文档 public void SaveDocument(AxMapControl axMapControl1) { mapDocument.Open(axMapControl1.DocumentFilename, ""); //确保地图文档不是只读的 if (mapDocument.get_IsReadOnly(mapDocument.DocumentFilename) == true) { MessageBox.Show("该地图只读!"); return; } //以相对路径保存 mapDocument.Save(mapDocument.UsesRelativePaths, true); MessageBox.Show("成功保存地图!"); }
private void btn_save_Click(object sender, EventArgs e) { try { m_pMapDoc.Save(); MessageBox.Show(String.Format("地图文档【{0}】已保存", m_pMapDoc.DocumentFilename)); } catch { MessageBox.Show("当前系统未加载地图文档", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool SaveMxd() { if (!m_pMapDoc.get_IsReadOnly(m_pMapDoc.DocumentFilename)) { m_pMapDoc.Save(); return(true); } else { return(false); } }
/// <summary> /// 保存地图文档 /// </summary> public static void SaveDocument(IMapDocument mapDocument) { if (mapDocument.get_IsReadOnly(mapDocument.DocumentFilename)) { MessageBox.Show("当前文档为只读文档,无法保存更改"); } else { mapDocument.Save(mapDocument.UsesRelativePaths); MessageBox.Show("已保存当前地图文档"); } }
private void Save_btn_Click(object sender, EventArgs e) { if (axMapControl1.DocumentFilename == null) { SaveMapAs(); } if (m_bDocModified == false) { return; } try { if (axMapControl1.Map.LayerCount == 0) { return; } if (axMapControl1.DocumentFilename != null && axMapControl1.CheckMxFile(axMapControl1.DocumentFilename)) { if (m_pMapDocument != null) { m_pMapDocument.Close(); m_pMapDocument = null; } m_pMapDocument = new MapDocumentClass(); //实例化 m_pMapDocument.Open(axMapControl1.DocumentFilename, ""); //必须的一步,用于将AxMapControl的实例的DocumentFileName传递给pMapDoc的 if (m_pMapDocument.get_IsReadOnly(m_pMapDocument.DocumentFilename)) //判断是否只读 { MessageBox.Show("文件只读!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Stop); m_pMapDocument.Close(); return; } m_pMapDocument.ReplaceContents((IMxdContents)axMapControl1.Map); //重置 IObjectCopy lip_ObjCopy = new ObjectCopyClass(); //使用Copy,避免共享引用 axMapControl1.Map = (IMap)lip_ObjCopy.Copy(m_pMapDocument.get_Map(0)); lip_ObjCopy = null; m_pMapDocument.Save(m_pMapDocument.UsesRelativePaths, true); axMapControl1.DocumentFilename = m_pMapDocument.DocumentFilename; this.Text = this.Text + " - " + axMapControl1.DocumentFilename; m_bDocModified = false; FileInfo fi = new FileInfo(m_pMapDocument.DocumentFilename); Global.m_sMxdPath = fi.GetDirectory(); MessageBox.Show("保存完成!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SaveDocument() { if (m_MapDocument.get_IsReadOnly(m_MapDocument.DocumentFilename) == true) { MessageBox.Show("ReadOnly Map, fail to save"); } try { m_MapDocument.Save(m_MapDocument.UsesRelativePaths, true); MessageBox.Show("Save map document successfully"); } catch (Exception ex) { MessageBox.Show("Fail to save map document" + ex.ToString()); } }
//保存地图文档 private void saveDocument() { if (mapDocument.get_IsReadOnly(mapDocument.DocumentFilename) == true) { MessageBox.Show("地图文档是只读的无法保存"); } string fileSavePath = @"e:\new.mxd"; try { mapDocument.Save(mapDocument.UsesRelativePaths, true); MessageBox.Show("保存地图文档成功"); } catch (Exception e) { MessageBox.Show("保存地图文档失败!!!" + e.ToString()); } }
private void 保存ToolStripMenuItem_Click(object sender, System.EventArgs e) { string ss = mapDocument.DocumentFilename; if (mapDocument.get_IsReadOnly(ss) == true) { MessageBox.Show("地图文档是只读的无法保存"); } string fileSavePath = @"e:\new.mxd"; try { mapDocument.Save(mapDocument.UsesRelativePaths, true); MessageBox.Show("保存地图文档成功"); } catch (Exception ex) { MessageBox.Show("保存地图文档失败!!!" + ex.ToString()); } }
public static void OperateMapDoc(AxMapControl axMapControl1, AxMapControl axMapControl2, string strOperateType) { OpenFileDialog OpenFileDialog = new OpenFileDialog(); SaveFileDialog SaveFileDialog = new SaveFileDialog(); OpenFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd"; SaveFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd"; string strDocFileN = string.Empty; pMapDocument = new MapDocumentClass(); switch (strOperateType) { case "NewDoc": { SaveFileDialog.Title = "输入需要新建地图文档的名称"; SaveFileDialog.ShowDialog(); strDocFileN = SaveFileDialog.FileName; if (strDocFileN == string.Empty) { return; } pMapDocument.New(strDocFileN); pMapDocument.Open(strDocFileN, ""); axMapControl1.Map = pMapDocument.get_Map(0); break; } case "OpenDoc": { OpenFileDialog.Title = "输入需要加载的地图文档"; OpenFileDialog.ShowDialog(); strDocFileN = OpenFileDialog.FileName; if (strDocFileN == string.Empty) { return; } pMapDocument.Open(strDocFileN, ""); for (int i = 0; i < pMapDocument.MapCount; i++) { axMapControl1.Map = pMapDocument.get_Map(i); //axMapControl2.Map = pMapDocument.get_Map(i); } axMapControl1.Refresh(); break; } case "SaveDoc": { if (pMapDocument.get_IsReadOnly(pMapDocument.DocumentFilename) == true) { MessageBox.Show("此地图为只读文档", "信息提示"); return; } pMapDocument.Save(pMapDocument.UsesRelativePaths, true); MessageBox.Show("保存成功!", "信息提示"); break; } case "SaveDocAS": { SaveFileDialog.Filter = "地图文档另存"; SaveFileDialog.ShowDialog(); strDocFileN = SaveFileDialog.FileName; if (strDocFileN == string.Empty) { return; } if (strDocFileN == pMapDocument.DocumentFilename) { pMapDocument.Save(pMapDocument.UsesRelativePaths, true); MessageBox.Show("保存成功!", "信息提示"); break; } else { pMapDocument.SaveAs(strDocFileN, true, true); MessageBox.Show("保存成功", "信息提示"); } break; } default: break; } }
public static void SaveMxd() { m_pMapDoc.Save(); }
public static void OperateMapDoc(AxMapControl axMapControl1, AxMapControl axMapControl2, string strOperateType) { OpenFileDialog OpenFileDialog = new OpenFileDialog(); SaveFileDialog SaveFileDialog = new SaveFileDialog(); OpenFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd"; SaveFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd"; string strDocFileN = string.Empty; pMapDocument = new MapDocumentClass(); switch (strOperateType) { case "NewDoc": { SaveFileDialog.Title = "输入需要新建地图文档的名称"; SaveFileDialog.ShowDialog(); strDocFileN = SaveFileDialog.FileName; if (strDocFileN == string.Empty) return; pMapDocument.New(strDocFileN); pMapDocument.Open(strDocFileN, ""); axMapControl1.Map = pMapDocument.get_Map(0); break; } case "OpenDoc": { OpenFileDialog.Title = "输入需要加载的地图文档"; OpenFileDialog.ShowDialog(); strDocFileN = OpenFileDialog.FileName; if (strDocFileN == string.Empty) return; pMapDocument.Open(strDocFileN, ""); for (int i = 0; i < pMapDocument.MapCount; i++) { axMapControl1.Map = pMapDocument.get_Map(i); //axMapControl2.Map = pMapDocument.get_Map(i); } axMapControl1.Refresh(); break; } case "SaveDoc": { if (pMapDocument.get_IsReadOnly(pMapDocument.DocumentFilename) == true) { MessageBox.Show("此地图为只读文档", "信息提示"); return; } pMapDocument.Save(pMapDocument.UsesRelativePaths, true); MessageBox.Show("保存成功!", "信息提示"); break; } case "SaveDocAS": { SaveFileDialog.Filter = "地图文档另存"; SaveFileDialog.ShowDialog(); strDocFileN = SaveFileDialog.FileName; if (strDocFileN == string.Empty) return; if (strDocFileN == pMapDocument.DocumentFilename) { pMapDocument.Save(pMapDocument.UsesRelativePaths, true); MessageBox.Show("保存成功!", "信息提示"); break; } else { pMapDocument.SaveAs(strDocFileN, true, true); MessageBox.Show("保存成功", "信息提示"); } break; } default: break; } }
private void btn_save_Click(object sender, EventArgs e) { m_pMapDoc.Save(); MessageBox.Show("当前地图文档已保存"); }