コード例 #1
0
        /// <summary>
        /// 加载网络数据集
        /// </summary>
        public void LoadNetWorkDataSet()
        {
            Core.Generic.myXML xml = new Core.Generic.myXML(System.Windows.Forms.Application.StartupPath + "\\Setting.xml");
            pMapDcument = new MapDocumentClass();
            try
            {
                string NetWorkData = xml.GetElement("MapDocument", "RoadNetData");
                //将数据载入pMapDocument并与map控件联系起来
                NetWorkData = System.Windows.Forms.Application.StartupPath + NetWorkData;
                pMapDcument.Open(NetWorkData, "");

                int i;
                for (i = 0; i <= pMapDcument.MapCount - 1; i++)
                {
                    //一个IMapDocument对象中可能有多个Map对象,遍历每个map对象
                    mapControl.Map = pMapDcument.get_Map(i);
                }
                mapControl.Refresh();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                xml = null;
            }
        }
コード例 #2
0
 private void cmdReset_Click(object sender, System.EventArgs e)
 {
     //Get rid of the line and points collection
     m_Polyline        = null;
     m_PointCollection = null;
     //Refresh the foreground thereby removing any text annotation
     axMapControl1.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing, Type.Missing);
 }
コード例 #3
0
        private void cmdLoad_Click(object sender, System.EventArgs e)
        {
            //Open a file dialog for selecting map documents
            openFileDialog1.Title  = "Browse Map Document";
            openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";
            openFileDialog1.ShowDialog();

            //Exit if no map document is selected
            string filePath = openFileDialog1.FileName;

            if (filePath == "")
            {
                return;
            }

            //If valid map document
            if (axPageLayoutControl1.CheckMxFile(filePath))
            {
                //Set mouse pointers
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                axMapControl1.MousePointer        = esriControlsMousePointer.esriPointerHourglass;
                //Reset controls
                axMapControl1.ActiveView.Clear();
                axMapControl1.ActiveView.GraphicsContainer.DeleteAllElements();
                axMapControl1.Refresh();
                cboMaps.Items.Clear();
                txbPath.Text = filePath;
                //Load map document
                axPageLayoutControl1.LoadMxFile(filePath, Type.Missing);
                //Set mouse pointers
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
                axMapControl1.MousePointer        = esriControlsMousePointer.esriPointerDefault;
            }
            else
            {
                MessageBox.Show(filePath + " is not a valid ArcMap document");
                return;
            }
        }