/// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add OpenDocument.OnClick implementation
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title  = "选择地图文档";
            dlg.Filter = "地图文档(*.mxd)|*.mxd";
            string docName = null;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                docName = dlg.FileName;
                IMapDocument mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsMapDocument(docName))
                {
                    mapDoc.Open(docName, string.Empty);
                    IMap map = mapDoc.get_Map(0);
                    m_ControlsSynchronizer.ReplaceMap(map);
                    mapDoc.Close();

                    RecnetFilesList.Add(docName);
                }
                else
                {
                    MessageBox.Show("不可用的地图文档", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RecnetFilesList.Remove(docName);
                }
            }
        }
Example #2
0
        private void MainView_Shown(object sender, EventArgs e)
        {
            _rendered = true;

            this.tabContent.SelectedTabPageIndex = 0;
            IMap map = new MapClass();

            map.Name = "地图";
            _controlsSynchronizer.ReplaceMap(map);
            tabContent.TabPages[1].PageVisible = false;
            UpdateView();
            //ForceTaskBarDisplay();
        }
Example #3
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            //launch a new OpenFile dialog
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "Map Documents (*.mxd)|*.mxd";
            dlg.Multiselect = false;
            dlg.Title       = "Open Map Document";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string docName = dlg.FileName;

                IMapDocument mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsPresent(docName) && !mapDoc.get_IsPasswordProtected(docName))
                {
                    mapDoc.Open(docName, string.Empty);

                    // set the first map as the active view
                    IMap map = mapDoc.get_Map(0);
                    mapDoc.SetActiveView((IActiveView)map);

                    m_controlsSynchronizer.PageLayoutControl.PageLayout = mapDoc.PageLayout;

                    m_controlsSynchronizer.ReplaceMap(map);

                    mapDoc.Close();

                    m_sDocumentPath = docName;
                }
            }
        }
Example #4
0
        /// <summary>
        /// 新建地图命令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void New_Click(object sender, EventArgs e)
        {
            //询问是否保存当前地图
            DialogResult res = MessageBox.Show("是否保存当前地图?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                //如果要保存,调用另存为对话框
                ICommand command = new ControlsSaveAsDocCommandClass();
                if (m_mapControl != null)
                {
                    command.OnCreate(m_controlsSynchronizer.MapControl.Object);
                }
                else
                {
                    command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object);
                }
                command.OnClick();
            }

            //创建新的地图实例
            IMap map = new MapClass();

            map.Name = "Map";
            m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty;

            //更新新建地图实例的共享地图文档
            m_controlsSynchronizer.ReplaceMap(map);
        }
Example #5
0
        private void NewMapDoc()
        {
            DialogResult res = MessageBox.Show("是否保存当前文档?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                ICommand command = new ControlsSaveAsDocCommandClass();
                if (m_MapControl != null)
                {
                    command.OnCreate(m_controlsSynchronizer.MapControl.Object);
                }
                else
                {
                    command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object);
                }
                command.OnClick();
            }

            IMap map = new MapClass();

            map.Name = "新建地图文档";
            m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty;

            m_controlsSynchronizer.ReplaceMap(map);
        }
Example #6
0
 private void commandBarItem35_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;
         }
     }
 }
Example #7
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            //check to see if there is an active edit session and whether edits have been made
            IEngineEditor engineEditor = new EngineEditorClass();

            if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && engineEditor.HasEdits())
            {
                DialogResult result = MessageBox.Show(@"Is save the edit?", @"Save the edit",
                                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.No:
                    engineEditor.StopEditing(false);
                    break;

                case DialogResult.Yes:
                    engineEditor.StopEditing(true);
                    break;
                }
            }
            //allow the user to save the current document
            DialogResult res = MessageBox.Show(@"Is save the current document?", @"Save document", MessageBoxButtons.YesNo,
                                               MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                //launch the save command
                ICommand command = new ControlsSaveAsDocCommandClass();
                command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object);
                command.OnClick();
            }

            //create a new Map
            IMap map = new MapClass();

            map.Name = "Map";

            //assign the new map to the MapControl
            //m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty;
            m_controlsSynchronizer.ReplaceMap(map);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add OpenNewMapDocument.OnClick implementation
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "Map Documents (*.mxd)|*.mxd";
            dlg.Multiselect = false;
            dlg.Title       = "Open Map Document";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string       docName = dlg.FileName;
                IMapDocument mapDoc  = new MapDocumentClass();
                if (mapDoc.get_IsPresent(docName) && !mapDoc.get_IsPasswordProtected(docName))
                {
                    mapDoc.Open(docName, string.Empty);
                    IMap map = mapDoc.get_Map(0);
                    m_controlsSynchronizer.ReplaceMap(map);
                    mapDoc.Close();
                }
            }
        }
Example #9
0
        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewMapDocument_Click(object sender, EventArgs e)
        {
            //非空白文档询问是否保存地图
            if (!String.IsNullOrEmpty(m_mapControl.DocumentFilename))
            {
                //询问是否保存当前地图
                DialogResult result = MessageBox.Show("是否保存当前地图?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    //保存地图
                    this.presenter.menuItemSave_Click(null, null);
                }
            }
            //创建新的地图实例
            IMap map = new MapClass();

            map.Name = "Map";
            m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty;
            //更新新建地图实例的共享地图文档
            m_controlsSynchronizer.ReplaceMap(map);
        }