//从外部TXT文件导入范围 private void RadioBtnInputRange_CheckedChanged(object sender, EventArgs e) { Exception outError = null; if (RadioBtnInputRange.Checked) { OpenFileDialog OpenFile = new OpenFileDialog(); OpenFile.CheckFileExists = true; OpenFile.CheckPathExists = true; OpenFile.Title = "选择图形范围坐标txt"; OpenFile.Filter = "图形范围坐标文本(*.txt)|*.txt"; if (OpenFile.ShowDialog() == DialogResult.OK) { StringBuilder sb = new StringBuilder(); try { StreamReader sr = new StreamReader(OpenFile.FileName); while (sr.Peek() >= 0) { string[] strTemp = sr.ReadLine().Split(','); //cyf 20110621 add:根据文本文件获取几何范围 for (int i = 0; i < strTemp.Length - 1; i = i + 2) { if (sb.Length != 0) { sb.Append(","); } sb.Append(strTemp[i] + "@" + strTemp[i + 1]); } //end } } catch (Exception er) { //******************************************************************* //guozheng added if (ModData.SysLog != null) { ModData.SysLog.Write(er, null, DateTime.Now); } else { ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog(); ModData.SysLog.Write(er, null, DateTime.Now); } //******************************************************************** SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "图形范围坐标txt格式不正确!\n文本每行为点坐标且以','分割"); return; } if (sb.Length == 0) { return; } m_Geometry = ModDBOperator.GetPolygonByCol(sb.ToString()) as IGeometry; //获得几何范围的空间参考 //if (ModData.TempWks != null) //{ // IFeatureWorkspace pFeaWs = ModData.TempWks as IFeatureWorkspace; // if (pFeaWs == null) // { // //获取系统维护库连接信息失败 // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取系统维护库连接信息失败!"); // return; // } //} //m_Geometry.SpatialReference= //cyf 20110621 在临时工作库中创建一个范围图层 //CreateMapFrameLayerInWorkSpace(m_Geometry, out outError); //if(outError!=null) //{ // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "创建临时的范围图层失败!\n原因:"+outError.Message); // return; //} //end } } }