private void cmdLoadMxFile_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 sFilePath = openFileDialog1.FileName;

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

            //Validate and load the Mx document
            if (axPageLayoutControl1.CheckMxFile(sFilePath))
            {
                txbMxPath.Text = sFilePath;
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                axPageLayoutControl1.LoadMxFile(sFilePath, Type.Missing);
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
            else
            {
                MessageBox.Show(sFilePath + " is not a valid ArcMap document");
            }
        }
        private void button1_Click(object sender, System.EventArgs e)
        {
            //Open a file dialog for selecting map documents
            openFileDialog1.Title  = "Select Map Document";
            openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";
            openFileDialog1.ShowDialog();

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

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

            // Load the specified mxd
            if (axPageLayoutControl1.CheckMxFile(sFilePath) == false)
            {
                System.Windows.Forms.MessageBox.Show("This document cannot be loaded!");
                return;
            }
            axPageLayoutControl1.LoadMxFile(sFilePath, "");

            //Set the current directory to the that of the executable
            Directory.SetCurrentDirectory(m_tempDir);
        }
Exemple #3
0
        private void cmdLoadMxFile_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 sFilePath = openFileDialog1.FileName;

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

            //Validate and load the Mx document
            if (axPageLayoutControl1.CheckMxFile(sFilePath) == true)
            {
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                axPageLayoutControl1.LoadMxFile(sFilePath, "");
                axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
                txbMxFilePath.Text = sFilePath;
            }
            else
            {
                MessageBox.Show(sFilePath + " is not a valid ArcMap document");
            }

            //Update page display
            cboPageSize.SelectedIndex             = (int)axPageLayoutControl1.Page.FormID;
            cboPageToPrinterMapping.SelectedIndex = (int)axPageLayoutControl1.Page.PageToPrinterMapping;
            if (axPageLayoutControl1.Page.Orientation == 1)
            {
                optPortrait.Checked = true;
            }
            else
            {
                optLandscape.Checked = true;
            }

            //Zoom to whole page
            axPageLayoutControl1.ZoomToWholePage();

            //Update printer page display
            UpdatePrintPageDisplay();
        }
        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;
            }
        }