private void barButtonItem101_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.mainMapControl.LayerCount > 0)
     {
         DialogResult result = MessageBox.Show("是否保存当前地图?", "警告", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (result == DialogResult.Cancel)
         {
             return;
         }
         //if (result == DialogResult.Yes) this.btnSaveDoc_Click(null, null);
     }
     this.openFileDialog.Title            = "请选择地图文件";
     this.openFileDialog.Filter           = "MXD地图文件|*.mxd";
     this.openFileDialog.Multiselect      = false;
     this.openFileDialog.RestoreDirectory = true;
     if (this.openFileDialog.ShowDialog() == DialogResult.OK)
     {
         Application.DoEvents();
         string docName = this.openFileDialog.FileName;
         try
         {
             this.pMapDocument = new MapDocumentClass();
             if (pMapDocument.get_IsPresent(docName) && !pMapDocument.get_IsPasswordProtected(docName))
             {
                 pMapDocument.Open(docName, null);
                 IMap pMap = pMapDocument.get_Map(0);
                 m_controlsSynchronizer.ReplaceMap(pMap);
                 this.mainMapControl.DocumentFilename = docName;
                 this.Text = System.IO.Path.GetFileName(this.openFileDialog.FileName) + " - " + "LinGIS - LinInfo";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(this.pMapDocument);
             Application.DoEvents();
             this.pMapDocument = null;
         }
     }
 }
Beispiel #2
0
 private void btnOpenDoc_Click(object sender, EventArgs e)
 {
     if (this.mainMapControl.LayerCount > 0)
     {
         DialogResult result = MessageBox.Show("是否保存当前地图?", "警告", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (result == DialogResult.Cancel) return;
         if (result == DialogResult.Yes) this.btnSaveDoc_Click(null, null);
     }
     this.openFileDialog.Title = "请选择地图文件";
     this.openFileDialog.Filter = "MXD地图文件|*.mxd";
     this.openFileDialog.Multiselect = false;
     this.openFileDialog.RestoreDirectory = true;
     if (this.openFileDialog.ShowDialog() == DialogResult.OK)
     {
         Application.DoEvents();
         string docName = this.openFileDialog.FileName;
         try
         {
             this.pMapDocument = new MapDocumentClass();
             if (pMapDocument.get_IsPresent(docName) && !pMapDocument.get_IsPasswordProtected(docName))
             {
                 pMapDocument.Open(docName, null);
                 IMap pMap = pMapDocument.get_Map(0);
                 m_controlsSynchronizer.ReplaceMap(pMap);
                 this.mainMapControl.DocumentFilename = docName;
                 this.Text = System.IO.Path.GetFileName(this.openFileDialog.FileName) + " - " + "LinGIS - LinInfo";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(this.pMapDocument);
             Application.DoEvents();
             this.pMapDocument = null;
         }
     }
 }