Example #1
0
        private void btnPrjPath_Click(object sender, EventArgs e)
        {
            //选择prj文件
            OpenFileDialog filedialog = new OpenFileDialog();

            filedialog.Multiselect = false;
            filedialog.Title       = "选择prj文件";
            filedialog.Filter      = "*.prj|*.prj";
            if (filedialog.ShowDialog() == DialogResult.OK)
            {
                string str = filedialog.FileName;
                this.txtPrjPath.Text = str;

                ESRI.ArcGIS.Geometry.ISpatialReferenceFactory pPrjFac = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
                pSR = pPrjFac.CreateESRISpatialReferenceFromPRJFile(txtPrjPath.Text);
                if (pSR == null)
                {
                    return;
                }
                if (pSR.Name == txtName.Text)
                {
                    return;
                }
                txtName.Text = pSR.Name;
                fillRtxt();
            }
        }
Example #2
0
        private void btnPrjFile_Click(object sender, EventArgs e)
        {
            string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime");

            if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改
            {
                sInstall = ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime");
            }
            if (sInstall == "")
            {
                sInstall = ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime");
            }   //added by chulili 2012-11-13  end
            sInstall = sInstall + "\\Coordinate Systems";

            OpenFileDialog filedialog = new OpenFileDialog();

            filedialog.Multiselect      = false;
            filedialog.InitialDirectory = sInstall;
            filedialog.Filter           = "*.prj|*.prj";
            filedialog.Title            = "选择prj文件";
            if (filedialog.ShowDialog() == DialogResult.OK)
            {
                string str = filedialog.FileName;
                this.txtPrjFile.Text = str;

                //直接读取坐标系统
                try
                {
                    ESRI.ArcGIS.Geometry.ISpatialReferenceFactory pPrjFac = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
                    ESRI.ArcGIS.Geometry.ISpatialReference        pSpa    = pPrjFac.CreateESRISpatialReferenceFromPRJFile(str);

                    m_strOutPrj = ExportToESRISpatialReference(pSpa);
                }
                catch
                {
                }
            }
        }