public static void AssignPRJDialog() { string value = MSCPrj.ReadWKT(AfaDocData.ActiveDocData.Document); if (!string.IsNullOrEmpty(value) && AfaDocData.ActiveDocData.DocDataset.FeatureServices.Count > 0) { AfaDocData.ActiveDocData.Document.Editor.WriteMessage(AfaStrings.ChangeCoordSysErrorFeatureServicesPresent + "\n"); return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = AfaStrings.OpenCoordinateSystemSource; openFileDialog.Filter = "PRJ|*.prj|DWG|*.dwg|DXF|*.dxf"; openFileDialog.InitialDirectory = MSCPrj.LocatePRJDirectory(); openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; bool flag = false; string text = ""; do { if (openFileDialog.ShowDialog() == true) { string a = Path.GetExtension(openFileDialog.FileName).ToLower(); try { if (a == ".dwg" || a == ".dxf") { Database database = new Database(false, true); database.ReadDwgFile(openFileDialog.FileName, (FileOpenMode)3, true, ""); text = MSCPrj.ReadWKT(database); if (string.IsNullOrEmpty(text)) { ErrorReport.ShowErrorMessage(AfaStrings.NoValidCoordinateSystemFoundIn + openFileDialog.FileName); } } else if (a == ".prj") { text = File.ReadAllText(openFileDialog.FileName); } } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorReadingWKTStringFrom + openFileDialog.FileName); } if (!string.IsNullOrEmpty(text)) { flag = true; MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, text); } } else { flag = true; } }while (!flag); }