Example #1
0
 //保存地图文档
 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());
             }
         }
     }
 }
Example #2
0
        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();
        }
Example #3
0
 /// <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 !");
 }
Example #4
0
 public static void SaveMxd()
 {
     if (m_pMapDoc.get_IsReadOnly(m_pMapDoc.DocumentFilename))
     {
         m_pMapDoc.Save();
     }
     else
     {
         MessageBox.Show("当前地图文档为只读文档,不能进行保存");
     }
 }
Example #5
0
 public static void Save()
 {
     if (m_pMapDoc.get_IsReadOnly(m_pMapDoc.DocumentFilename))
     {
         m_pMapDoc.Save();
     }
     else
     {
         MessageBox.Show(String.Format("无法保存地图文档", m_pMapDoc.DocumentFilename));
     }
 }
Example #6
0
 //保存地图文档
 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("成功保存地图!");
 }
Example #7
0
 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("已保存当前地图文档");
     }
 }
Example #9
0
        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());
     }
 }
Example #11
0
        //保存地图文档
        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());
            }
        }
Example #12
0
        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());
            }
        }
Example #13
0
    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;
        }
    }
Example #14
0
    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;
        }
    }