using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Autodesk.Revit.UI; using System.IO; using System.Collections; using System.Text.RegularExpressions; using Autodesk; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Plumbing; using KDCS.Utils; namespace KMBIM.Revit.Tools.Cmd.Calculation_pad { public partial class Form_Calpad : System.Windows.Forms.Form { public Autodesk.Revit.UI.UIApplication app; List m_ids = new List(); List m_cvalues = new List(); //위생기구 List m_strArrayName = new List(); // 위생기구명 List m_intName1 = new List(); // 위생기구 색인 List m_strArrayClass = new List(); // 구분 List m_strArrayCode = new List(); // 단축명 List m_dblArrayBore1 = new List(); // 기구접속관경(급수) List m_dblArrayBore2 = new List(); // 기구접속관경(급탕) List m_dblArrayBore3 = new List(); // 기구접속관경(오배수) List m_dblArrayUse1 = new List(); // 동시사용률(15파이관 상당수) List m_dblArrayUse2 = new List(); // 동시사용률 List m_dblArrayEql1 = new List(); // 균등표(관경) List m_dblArrayEql2 = new List(); // 균등표(15파이관 상당수) List m_dblArraySyncHall = new List(); // 동시개구수(극장,체육관,집회장) List m_dblArraySyncOffice = new List(); // 동시개구수(사무실,일반건물) List m_dblArraySyncBore = new List(); // 상당수 List m_dblArrayHWReturn = new List(); // 환탕지관경 List m_dblArrayHWSupply = new List(); // 급탕지관경 List m_dblArrayFU = new List(); // 환탕지관경 List m_dblArrayFUD = new List(); // 급탕지관경 //급수급탕횡주관 및 입상관경표 List m_dblArrayColBore = new List(); // 관경 List m_dblArrayColCWSupply = new List(); // 급수관경 List m_dblArrayColHWSupply = new List(); // 급탕관경 // 오배수관의 횡지관경 선정표 List m_dblArrayRowBore1 = new List(); // 관경 List m_dblArrayRowfuD1 = new List(); // 기구배수부하단위 // 오배수관의 횡주관경 선정표 List m_dblArrayRowBore2 = new List(); // 관경 List m_dblArrayRowfuD2 = new List(); // 기구배수부하단위 // 오배수관의 입상관경 선정표 List m_dblArrayRowBore3 = new List(); // 관경 List m_dblArrayRowfuD3 = new List(); // 기구배수부하단위 // 급수지관 List m_strArrayOfficeBore1 = new List(); // 사무실 관경 List m_strArrayHallBore1 = new List(); // 극장 관경 // 급탕지관 List m_strArrayOfficeBore2 = new List(); // 사무실 관경 List m_strArrayHallBore2 = new List(); // 극장 관경 // 환탕지관의 관경선정표 List m_strArrayOfficeBore3 = new List(); // 사무실 관경 List m_strArrayHallBore3 = new List(); // 극장 관경 // 급수,급탕 횡주관 및 입상관경 List m_strArrayColCWSupply = new List(); // 사무실 관경 List m_strArrayColHWSupply = new List(); // 사무실 관경 // 오배수관의 횡지관경 선정표 List m_strArrayRowfuD1 = new List(); // 기구배수부하단위 // 오배수관의 횡주관경 선정표 List m_strArrayRowfuD2 = new List(); // 기구배수부하단위 // 오배수관의 입상관경 선정표 List m_strArrayRowfuD3 = new List(); // 기구배수부하단위 // 급수 double m_dblEqlNo1; // 균등수 double m_dblSyncUseRate1; // 동시사용률 double m_dblSyncOpenNo1; // 동시개구수 // 급탕 double m_dblEqlNo2; // 균등수 double m_dblSyncUseRate2; // 동시사용률 double m_dblSyncOpenNo2; // 동시개구수 // 오배수 double m_dblEqlNo3; // 균등수 double m_dblSyncUseRate3; // 동시사용률 double m_dblSyncOpenNo3; // 동시개구수 double m_dblFUCS; // 급수부하단위 double m_dblFUHS; // 급탕부하단위 double m_dblFUD; // 배수부하단위 int m_iCnt1; // 급수기구 갯수 int m_iCnt2; // 급탕기구 갯수 int m_iCnt3; // 오배수기구 갯수 int m_setDataInx; int m_iBldType; int m_iPipeType; string m_strpath; public int m_iCalmethoid = 0; // 계산 방법 1 이면 등속법 2이면 정압법 int m_inx1; int m_inx2; int inxKind; public double DuctDia { get; set; } public Form_Calpad() { InitializeComponent(); string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location; m_strpath = Util.GetKMBIMLibraryFolder("\\Libraries\\CalPad\\MST"); //m_strpath = Tmp.Replace("\\KMBIM2019.dll", ""); m_inx1 = m_inx2 = inxKind = 0; //덕트초기화 txt_aspect.Text = "1.5"; txt_width.Text = "0.0"; txt_height.Text = "0.0"; txt_vol.Text = "700"; txt_limit.Text = "500"; m_iCalmethoid = 2; label3.Text = "풍속 :"; label4.Text = "m/sec"; tabControl1_SelectedIndexChanged(null, null); btn_Continuous_velocity_Click(null, null); // 파이프 초기화 txt_c.Text = "100"; txt_d.Text = "0.0"; txt_dd.Text = "0.0"; txt_i.Text = "20.0"; txt_q.Text = "100.0"; txt_s.Text = ""; SetPipeKind(); // 소방 초기화 txt_up.Text = "0"; txt_down.Text = "0"; txt_updown.Text = "0"; // 위생 초기화 //CreatePlbExcel(); GetExlData(); m_iBldType = 0; m_iPipeType = 0; cmb_bldtype.SelectedIndex = 0; cmb_pipetype.SelectedIndex = 0; m_setDataInx = 0; m_iCnt1 = 0; m_iCnt2 = 0; m_iCnt3 = 0; m_dblFUCS = 0; m_dblFUHS = 0; m_dblFUD = 0; } public void GetExlData() { //CDatabase database; string strQuery; string strFld, strPlbName, strClass, strCode; string sDriver; string sDsn; // CDBVariant vVal; listBox_name.Items.Clear(); m_strArrayName.Clear(); // 위생기구명 m_strArrayClass.Clear(); // 구분 m_strArrayCode.Clear(); // 단축명 m_dblArrayBore1.Clear(); // 기구접속관경(급수) m_dblArrayBore2.Clear(); // 기구접속관경(급탕) m_dblArrayBore3.Clear(); // 기구접속관경(오배수) m_dblArrayUse1.Clear(); // 동시사용률(15파이관 상당수) m_dblArrayUse2.Clear(); // 동시사용률 m_dblArrayEql1.Clear(); // 균등표(관경) m_dblArrayEql2.Clear(); // 균등표(15파이관 상당수) m_dblArraySyncHall.Clear(); // 동시개구수(극장,체육관,집회장) m_dblArraySyncOffice.Clear(); // 동시개구수(사무실,일반건물) m_dblArraySyncBore.Clear(); // 상당수 m_dblArrayHWReturn.Clear(); // 환탕지관경 m_dblArrayHWSupply.Clear(); // 급탕지관경 m_dblArrayFU.Clear(); // 기구급수부하단위 m_dblArrayFUD.Clear(); // 기구배수부하단위 //급수급탕횡주관 및 입상관경표 m_dblArrayColBore.Clear(); // 관경 m_dblArrayColCWSupply.Clear(); // 급수관경 m_dblArrayColHWSupply.Clear(); // 급탕관경 string strCSV; string strCSVFile; string s; double dblVal; //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "위생기구일람표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 위생기구명 구분 단축명 급수 급탕 오배수 상당관수 fu fuD int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "위생기구명") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "구분") == 0) nInx[1] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "단축명") == 0) nInx[2] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "급수") == 0) nInx[3] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "급탕") == 0) nInx[4] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "오배수") == 0) nInx[5] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "상당관수") == 0) nInx[6] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "fu") == 0) nInx[7] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "fuD") == 0) nInx[8] = j; } continue; } i++; // 각 해당 필드 데이타 출력 //0, 위생기구명 strPlbName = arr[0]; m_strArrayName.Add(strPlbName); //1, 구분 strClass = arr[1]; iCnt += 1; s = System.String.Format("{0},{1}({2})", iCnt, strPlbName, strClass); listBox_name.Items.Add(s); //2, 단축명 strCode = arr[2]; if (strCode == "-") strCode = ""; m_strArrayCode.Add(strCode); //3, 급수 s = arr[3]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayBore1.Add(dblVal); //4, 급탕 s = arr[4]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayBore2.Add(dblVal); //5, 오배수 s = arr[5]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayBore3.Add(dblVal); //6, 상당관수 //s=csaFields[4]; //if(s==_T("-")) dblVal=0.0; //else dblVal=_wtof(s); //7, fu s = arr[7]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayFU.Add(dblVal); //8, fuD s = arr[8]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayFUD.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { //pEx->ReportError(); MessageBox.Show(ex.Message); } // 동시사용률 //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "동시사용률"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 상당수, 동시사용률 int[] nInx = new int[9]; while (sr.Peek() > -1) { //ArxUtils::SeparateString(csRecord, csaFields, _T(",\t\n")); string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "상당수") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "동시사용률") == 0) nInx[1] = j; } continue; } i++; //0, 상당수 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayUse1.Add(dblVal); //1, 동시사용률 s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayUse2.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } // 균등표 //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "균등표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 관경, 상당수 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "상당수") == 0) nInx[1] = j; } continue; } i++; //0, 관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayEql1.Add(dblVal); //1, 상당수 s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayEql2.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* // 급수급탕지관의관경선정표 //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "급수급탕지관의관경선정표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 상당수, 사무실, 극장 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "상당수") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "사무실") == 0) nInx[1] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "극장") == 0) nInx[2] = j; } continue; } i++; //0, 상당수 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArraySyncBore.Add(dblVal); //1, 사무실 s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArraySyncOffice.Add(dblVal); //2, 극장 s = arr[2]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArraySyncHall.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* // 환탕지관의 관경 선정표 //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "환탕지관의관경선정표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 환탕지관경, 급탕지관경, 극장 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "환탕지관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "급탕지관경") == 0) nInx[1] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "극장") == 0) nInx[2] = j; } continue; } i++; //0, 환탕지관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayHWReturn.Add(dblVal); //1, 급탕지관경 s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayHWSupply.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* // 급수급탕횡주관및입상관경표 //([관경],[부하급수],[부하급탕],[유량급수],[유량급탕],[유속급수],[유속급탕]) //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "급수급탕횡주관및입상관경표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 관경, 부하급수, 부하급탕, 유량급수, 유량급탕, 유속급수, 유속급탕 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "부하급수") == 0) nInx[1] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "부하급탕") == 0) nInx[2] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "유량급수") == 0) nInx[3] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "유량급탕") == 0) nInx[4] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "유속급수") == 0) nInx[5] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "유속급탕") == 0) nInx[6] = j; } continue; } i++; //0, 관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayColBore.Add(dblVal); //1, 부하급수 s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayColCWSupply.Add(dblVal); //1, 부하급탕 s = arr[2]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayColHWSupply.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* //strSheetName=_T("오배수관의횡지관경선정표"); //([관경],[fuD]) //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "오배수관의횡지관경선정표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 관경, 부하급수, 부하급탕, 유량급수, 유량급탕, 유속급수, 유속급탕 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "fuD") == 0) nInx[1] = j; } continue; } i++; //0, 관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowBore1.Add(dblVal); //1, fuD s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowfuD1.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* //strSheetName=_T("오배수관의횡주관경선정표"); //([관경],[fuD]) //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "오배수관의횡주관경선정표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 관경, 부하급수, 부하급탕, 유량급수, 유량급탕, 유속급수, 유속급탕 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "fuD") == 0) nInx[1] = j; } continue; } i++; //0, 관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowBore2.Add(dblVal); //1, fuD s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowfuD2.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } //************************************************************* //strSheetName=_T("오배수관의입상관경선정표"); //([관경],[fuD]) //------------------------------------------------------------------------------- strCSV = System.String.Format("\\plb_{0}.csv", "오배수관의입상관경선정표"); strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; int iCnt = 0; ArrayList csaFieldNames = new ArrayList(); // 관경, 부하급수, 부하급탕, 유량급수, 유량급탕, 유속급수, 유속급탕 int[] nInx = new int[9]; while (sr.Peek() > -1) { string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "관경") == 0) nInx[0] = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "fuD") == 0) nInx[1] = j; } continue; } i++; //0, 관경 s = arr[0]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowBore3.Add(dblVal); //1, fuD s = arr[1]; if (s == "-") dblVal = 0.0; else dblVal = Convert.ToDouble(s); m_dblArrayRowfuD3.Add(dblVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { MessageBox.Show(ex.Message); } } //전체 탭 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { if (tabControl1.SelectedIndex == 0) { radioButton1.Checked = true; } } //////////////////////////////덕트/////////////////////////////////////// //덕트사이즈 private void DuctSize() { // UpdateData(TRUE); double t, width, height, area, dia, aspect; t = width = height = area = dia = aspect = 0.0; bool flg = false; aspect = txt_aspect.Text == "" ? 0 : Convert.ToDouble(txt_aspect.Text); double loss = cmb_loss.Text == "" ? 0 : Convert.ToDouble(cmb_loss.Text); double vol = txt_vol.Text == "" ? 0 : Convert.ToDouble(txt_vol.Text); if (aspect <= 0 || loss <= 0 || vol <= 0) return; // 원형덕트의 직경을 구한다. if (m_iCalmethoid == 1) { // 등속법 dia = System.Math.Sqrt(vol / (3600.0 * loss * 3.14159)) * 2.0; // 풍속 dia = dia * 1000; } else if (m_iCalmethoid == 2) { // 정압법 dia = dia4rduct(vol, loss); }//end-else DuctDia = Math.Round(dia,0); textBoxDe.Text = string.Format("{0}", DuctDia); double m_dblWidth = 0.0; double m_dblHeight = 0.0; if (radioButton2.Checked == true) { m_dblWidth = normal(dia); m_dblHeight = 0; txt_width.Text = m_dblWidth.ToString(); txt_height.Text = m_dblHeight.ToString(); return; }//end-if // ******************************************************************** // 각형덕트의 폭과 높이를 구한다. // ******************************************************************** do { t = System.Math.Pow(System.Math.Pow(aspect, 5.0) / System.Math.Pow(1.0 + aspect, 2.0), 1.0 / 8.0); // 상당직경 height = dia / (1.3 * t); width = height * aspect; area = height * width; width = normal(width); height = normal(area / width); if (height > Convert.ToDouble(txt_limit.Text)) { aspect += 0.1; flg = true; } // Overflow limit(height) else flg = false; } while (flg); m_dblWidth = width; // WIDTH m_dblHeight = height; // HEIGHT // 덕트높이가 폭보가 클 경우 교환 if (m_dblHeight > m_dblWidth) { width = m_dblWidth; m_dblWidth = m_dblHeight; m_dblHeight = width; }//end-if txt_width.Text = m_dblWidth.ToString(); txt_height.Text = m_dblHeight.ToString(); //OnCheckSetsize(); } private double dia4rduct(double vol, double loss) { double a, b, dia; //**************************************************************** // << Get a Dimeater of ROUND DUCT >> // diameter unit : m // vol (CMH) / 3,600 -> CMS */ // 1996. 2. 19 Modified & Fixed by Kwang-Sik Lee //**************************************************************** a = 0.0019 * System.Math.Pow(vol / 3600.0, 1.90) / loss; b = System.Math.Log10(a) / 5.03; dia = System.Math.Pow(10.0, b) * 1000.0; // Unit: mm return (dia); } private double normal(double val) { double add, quot, rem; quot = System.Math.Floor(val / 100.0); rem = val - quot * 100.0; if (val > 100.0 && val < 150.0) val = 125.0; else { if (rem >= 20 && rem < 70) add = 50; else if (rem >= 70) add = 100; else add = 0; val = quot * 100 + add; }//end-if-else return val; } private void PipeSize() { double insDia = 0.0, dia = 0.0; if (m_ids.Count() <= 0) return; //UpdateData(TRUE); double c, i, t, d, q; q = txt_q.Text == "" ? 0 : Convert.ToDouble(txt_q.Text); // 유량(l/min) i = txt_i.Text == "" ? 0 : Convert.ToDouble(txt_i.Text) / 1000; // 관장 1m당 마찰손실(mmAq/m) / 1000 -> mAq/m c = txt_c.Text == "" ? 0 : Convert.ToDouble(txt_c.Text); // 유속계수 t = q / (1.67 * c * System.Math.Pow(i, 0.54) * 10000.0); d = System.Math.Pow(10.0, System.Math.Log10(t) / 2.63); // 관의 안지름(m) // 유속 double v, r, a; r = d * 0.5; a = (3.141592 * d * d) / 4.0; // 면적 m2 //a=3.141592*r*r; // 면적 m2 v = (q * 0.001 / a) / 60.0; // 1m3 --> 1000L d = d * 1000.0; // m->mm txt_s.Text = txt_c.Text == "0" ? "0" : System.String.Format("{0:F2}", v); txt_pipedia.Text = txt_c.Text == "0" ? "1" : System.String.Format("{0:F0}", d); string strCSV; strCSV = System.String.Format("\\pipe_{0:D2}.csv", m_ids[inxKind]); string strCSVFile = m_strpath + strCSV; try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = strCSVFile; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int ic = 0; ArrayList csaFieldNames = new ArrayList(); int iInside = 0, iPipeName = 0; while (sr.Peek() > -1) { ArrayList csaFields = new ArrayList(); //ArxUtils::SeparateString(csRecord, csaFields, _T(",\t\n")); string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (ic == 0) { // 필드레코드 ic++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "INSIDE") == 0) iInside = j; if (System.StringComparer.OrdinalIgnoreCase.Compare(arr[j], "PIPENAME") == 0) iPipeName = j; } continue; } ic++; // 각 해당 필드 데이타 출력 insDia = Convert.ToDouble(arr[iInside]); // 내경 if (d <= insDia) { //AfxMessageBox(csaFields[iPipeName]); dia = Convert.ToDouble(arr[iPipeName]); // 호칭경 break; }; }//end-while fs.Close(); } catch (FieldAccessException ex) { //pEx->ReportError(); } txt_d.Text = insDia.ToString(); txt_dd.Text = dia.ToString(); } private void SetPipeKind() { cmb_pipekind.Items.Clear(); try { long id; FileStream fs = null; string csFileName, csRecord; string strPath; bool res = false; csFileName = m_strpath + "\\PipeCValue.csv"; FileInfo _finfo = new FileInfo(csFileName); bool sw = _finfo.Exists; if (sw == false) { // 파일 존재 유무 조사 string strMsg; strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); if (fs == null) { string strMsg; strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName); MessageBox.Show(strMsg); return; } int i = 0; ArrayList csaFieldNames = new ArrayList(); int iName = 0, iId = 0, iCValue = 0; while (sr.Peek() > -1) { ArrayList csaFields = new ArrayList(); //SeparateString(csRecord, ref csaFields, ",\t\n"); string str = sr.ReadLine(); string[] arr = Regex.Split(str, ",\t"); if (arr.Length <= 0) break; // 이 문 없으면 죽는다. if (i == 0) { // 필드레코드 i++; for (int j = 0; j < arr.Length; j++) { csaFieldNames.Add(arr[j]); if (arr[j].CompareTo("NAME") == 0) iName = j; if (arr[j].CompareTo("ID") == 0) iId = j; if (arr[j].CompareTo("CVALUE") == 0) iCValue = j; } continue; } i++; // 각 해당 필드 데이타 출력 cmb_pipekind.Items.Add(arr[iName]); id = Convert.ToInt64(arr[iId].ToString()); m_ids.Add(id); double dVal = Convert.ToDouble(arr[iCValue]); m_cvalues.Add(dVal); }//end-while fs.Close(); } catch (FieldAccessException ex) { //ex.ReportError(); } inxKind = 0; cmb_pipekind.SelectedIndex = inxKind; } //등속법 private void btn_Continuous_velocity_Click(object sender, EventArgs e) { btn_Continuous_velocity.BackColor = System.Drawing.Color.Aqua; btn_2.BackColor = System.Drawing.Color.White; m_iCalmethoid = 1; cmb_loss.Items.Clear(); cmb_loss.Items.Add("4"); cmb_loss.Items.Add("5"); cmb_loss.Items.Add("15"); cmb_loss.Items.Add("20"); cmb_loss.Items.Add("25"); cmb_loss.SelectedIndex = m_inx1; label3.Text = "풍속:"; label4.Text = "m/sec"; DuctSize(); } //정압법 private void btn_2_Click(object sender, EventArgs e) { btn_Continuous_velocity.BackColor = System.Drawing.Color.White; btn_2.BackColor = System.Drawing.Color.Aqua; m_iCalmethoid = 2; cmb_loss.Items.Clear(); cmb_loss.Items.Add("0.07"); cmb_loss.Items.Add("0.1"); cmb_loss.Items.Add("0.15"); cmb_loss.SelectedIndex = m_inx2; label3.Text = "마찰손실"; label4.Text = "mmAq/m"; DuctSize(); } //각형 private void radioButton1_CheckedChanged(object sender, EventArgs e) { DuctSize(); } //원형 private void radioButton2_CheckedChanged(object sender, EventArgs e) { DuctSize(); } //풍량 private void txt_vol_TextChanged(object sender, EventArgs e) { if (txt_vol.Text == "") txt_vol.Text = "0"; DuctSize(); } private void txt_vol_KeyPress(object sender, KeyPressEventArgs e) { if (!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back) || (e.KeyChar == '.'))) { e.Handled = true; } } //마찰손실 private void cmb_loss_SelectedIndexChanged(object sender, EventArgs e) { if (m_iCalmethoid == 0) { m_inx1 = cmb_loss.SelectedIndex; } else m_inx2 = cmb_loss.SelectedIndex; DuctSize(); } private void cmb_loss_TextChanged(object sender, EventArgs e) { if (cmb_loss.Text == "") cmb_loss.Text = "0"; DuctSize(); } //종횡비 private void txt_aspect_TextChanged(object sender, EventArgs e) { if (txt_aspect.Text == "") txt_aspect.Text = "0"; DuctSize(); } //최대 높이 private void txt_limit_TextChanged(object sender, EventArgs e) { if (txt_limit.Text == "") txt_limit.Text = "0"; DuctSize(); } //////////////////////////////파이프/////////////////////////////////////// //관종 private void cmb_pipekind_SelectedIndexChanged(object sender, EventArgs e) { inxKind = cmb_pipekind.SelectedIndex; txt_c.Text = m_cvalues[inxKind].ToString(); // 조도계수 PipeSize(); } //유량 private void txt_q_TextChanged(object sender, EventArgs e) { if (txt_q.Text == "") txt_q.Text = "0"; PipeSize(); } //마찰손실 private void txt_i_TextChanged(object sender, EventArgs e) { if (txt_i.Text == "") txt_i.Text = "0"; PipeSize(); } //유속계수 private void txt_c_TextChanged(object sender, EventArgs e) { if (txt_c.Text == "") txt_c.Text = "0"; PipeSize(); } //////////////////////////////소방/////////////////////////////////////// private void CalBore() { int up, dn, ud, hd_num; up = txt_up.Text == "" ? 0 : Convert.ToInt32(txt_up.Text); dn = txt_down.Text == "" ? 0 : Convert.ToInt32(txt_down.Text); ud = txt_updown.Text == "" ? 0 : Convert.ToInt32(txt_updown.Text); hd_num = up + dn + ud; txt_bore.Text = "0"; if ((up > 0 && dn == 0 && ud == 0) || (dn > 0 && up == 0 && ud == 0)) { // A if (hd_num <= 2) txt_bore.Text = "25"; else if (hd_num <= 3) txt_bore.Text = "32"; else if (hd_num <= 5) txt_bore.Text = "40"; else if (hd_num <= 10) txt_bore.Text = "50"; else if (hd_num <= 30) txt_bore.Text = "65"; else if (hd_num <= 60) txt_bore.Text = "80"; else if (hd_num <= 80) txt_bore.Text = "90"; else if (hd_num <= 100) txt_bore.Text = "100"; else if (hd_num <= 160) txt_bore.Text = "125"; else txt_bore.Text = "150"; } else if (ud > 0 || (ud > 0 && (up > 0 || dn > 0))) { // B if (hd_num <= 2) txt_bore.Text = "25"; else if (hd_num <= 4) txt_bore.Text = "32"; else if (hd_num <= 7) txt_bore.Text = "40"; else if (hd_num <= 15) txt_bore.Text = "50"; else if (hd_num <= 30) txt_bore.Text = "65"; else if (hd_num <= 60) txt_bore.Text = "80"; else if (hd_num <= 65) txt_bore.Text = "90"; else if (hd_num <= 100) txt_bore.Text = "100"; else if (hd_num <= 160) txt_bore.Text = "125"; else txt_bore.Text = "150"; } } //상향 private void txt_up_TextChanged(object sender, EventArgs e) { if (txt_up.Text == "") txt_up.Text = "0"; CalBore(); } //하향 private void txt_down_TextChanged(object sender, EventArgs e) { if (txt_updown.Text == "") txt_updown.Text = "0"; CalBore(); } private void txt_updown_TextChanged(object sender, EventArgs e) { if (txt_updown.Text == "") txt_updown.Text = "0"; CalBore(); } //////////////////////////////위생/////////////////////////////////////// // 선형보간법 private double Interpolation(double nCnt1, double syncUseRate1, double nCnt2, double syncUseRate2, double nCnt) { double dVal = syncUseRate1 + (syncUseRate2 - syncUseRate1) / (nCnt2 - nCnt1) * (nCnt - nCnt1); return dVal; } private void AddPlbName(int inx) { string strName = System.String.Empty; string s = String.Empty; strName = System.String.Format("{0}", inx + 1); m_intName1.Add(inx); listBox_name1.Items.Add(strName); //*************************************** // 급수관경 계산 //*************************************** // 배관용 탄소관 강관의 균등표 int iDur = 0; int iInx = -1; int iSize = m_dblArrayEql1.Count(); double dblBore = m_dblArrayBore1[inx]; if (dblBore > 0) { m_iCnt1 += 1; m_dblFUCS += m_dblArrayFU[inx]; //급수용(fu) int l; l = m_dblArrayColCWSupply.Count(); for (int j = 0; j < l; j++) { if (m_dblFUCS < m_dblArrayColCWSupply[j]) { s = String.Format("{0}", m_dblArrayColBore[j]); m_strArrayColCWSupply.Add(s); break; }//end-if }//end-for } else { s = ""; m_strArrayColCWSupply.Add(s); }//end-if for (iDur = 0; iDur < iSize; iDur++) { if (dblBore <= m_dblArrayEql1[iDur]) { iInx = iDur; break; }//end-if }//end-for if (iInx > -1) m_dblEqlNo1 += m_dblArrayEql2[iInx]; //균등수 // 동시사용률 iInx = -1; iSize = m_dblArrayUse1.Count(); for (iDur = 0; iDur < iSize; iDur++) { if (m_iCnt1 <= m_dblArrayUse1[iDur]) { iInx = iDur; break; }//end-if }//end-for if (iInx > -1) { double n1, n2; // 상당수 m_dblSyncUseRate1 = m_dblArrayUse2[iInx]; if (iInx > 0) { n1 = m_dblArrayUse1[iInx - 1]; n2 = m_dblArrayUse1[iInx]; if (Math.Abs(n2 - n1) > 1) { m_dblSyncUseRate1 = Interpolation(n1, m_dblArrayUse2[iInx - 1], n2, m_dblArrayUse2[iInx], m_iCnt1); }//end-if }//end-if }//end-if // 동시개구수 = 균등수*동시사용률 m_dblSyncOpenNo1 = m_dblEqlNo1 * m_dblSyncUseRate1 / 100.0; //ads_printf(_T("급수관 접속관경:%g, 균등수(%g)*동시사용률(%g)=동시개구수:%g\n"),dblBore,m_dblEqlNo1,m_dblSyncUseRate1,m_dblSyncOpenNo1); // 관경 산정 string strBore = String.Empty; string strBore1 = String.Empty; iSize = m_dblArraySyncBore.Count(); for (iDur = 0; iDur < iSize; iDur++) { if (m_dblSyncOpenNo1 <= m_dblArraySyncOffice[iDur]) { if (dblBore > 0) strBore = String.Format("{0}", m_dblArraySyncBore[iDur]); else strBore = ""; m_strArrayOfficeBore1.Add(strBore); break; }//end-if }//end-for if (m_iBldType == 0) listBox_bore1.Items.Add(strBore); // 체육관 극장 for (iDur = 0; iDur < iSize; iDur++) { if (m_dblSyncOpenNo1 <= m_dblArraySyncHall[iDur]) { if (dblBore > 0) strBore = System.String.Format("{0}", m_dblArraySyncBore[iDur]); else strBore = ""; m_strArrayHallBore1.Add(strBore); break; }//end-if }//end-for if (m_iBldType == 1) listBox_bore1.Items.Add(strBore); //*************************************** // 급탕 관경 계산 //*************************************** // 배관용 탄소관 강관의 균등표 iDur = 0; iInx = -1; iSize = m_dblArrayEql1.Count(); dblBore = m_dblArrayBore2[inx]; if (dblBore > 0) { m_iCnt2 += 1; m_dblFUCS += m_dblArrayFU[inx]; // 급탕용(fu) for (iDur = 0; iDur < iSize; iDur++) { if (dblBore <= m_dblArrayEql1[iDur]) { iInx = iDur; break; }//end-if }//end-for int l; l = m_dblArrayColHWSupply.Count(); for (int j = 0; j < l; j++) { if (m_dblFUCS < m_dblArrayColHWSupply[j]) { s = String.Format("{0}", m_dblArrayColBore[j]); m_strArrayColHWSupply.Add(s); break; }//end-if }//end-for } else { s = ""; m_strArrayColHWSupply.Add(s); }//end-if-else if (iInx > -1) m_dblEqlNo2 += m_dblArrayEql2[iInx]; //균등수 // 동시사용률 iInx = -1; iSize = m_dblArrayUse1.Count(); for (iDur = 0; iDur < iSize; iDur++) { if (m_iCnt1 <= m_dblArrayUse1[iDur]) { iInx = iDur; break; }//end-if }//end-for if (iInx > -1) m_dblSyncUseRate2 = m_dblArrayUse2[iInx]; // 동시개구수 = 균등수*동시사용률 m_dblSyncOpenNo2 = m_dblEqlNo2 * m_dblSyncUseRate2 / 100.0; //ads_printf(_T("급탕관 접속관경:%g, 균등수(%g)*동시사용률(%g)=동시개구수:%g\n"),dblBore, m_dblEqlNo2,m_dblSyncUseRate2,m_dblSyncOpenNo2); // 관경 산정 int iSize1; iSize = m_dblArraySyncBore.Count(); //사무실 및 일반건물 for (iDur = 0; iDur < iSize; iDur++) { if (m_dblSyncOpenNo2 <= m_dblArraySyncOffice[iDur]) { if (m_dblSyncOpenNo2 > 0 && dblBore > 0) { strBore = String.Format("{0}", m_dblArraySyncBore[iDur]); // 환탕지관경 iSize1 = m_dblArrayHWSupply.Count(); for (int j = 0; j < iSize1; j++) { if (m_dblArraySyncBore[iDur] <= m_dblArrayHWSupply[j]) { strBore1 = String.Format("{0}", m_dblArrayHWReturn[j]); break; }//end-if }//end-for } else { strBore = ""; strBore1 = ""; }//end-if-else m_strArrayOfficeBore2.Add(strBore); m_strArrayOfficeBore3.Add(strBore1); break; }//end-if }//end-for if (m_iBldType == 0) listBox_bore2.Items.Add(strBore); // 체육관,극장 iSize = m_dblArraySyncBore.Count(); for (iDur = 0; iDur < iSize; iDur++) { if (m_dblSyncOpenNo2 <= m_dblArraySyncHall[iDur]) { if (m_dblSyncOpenNo2 > 0 && dblBore > 0) { strBore = String.Format("{0}", m_dblArraySyncBore[iDur]); // 환탕지관경 iSize1 = m_dblArrayHWSupply.Count(); for (int j = 0; j < iSize1; j++) { if (m_dblArraySyncBore[iDur] <= m_dblArrayHWSupply[j]) { strBore1 = String.Format("{0}", m_dblArrayHWReturn[j]); break; }//end-if }//end-for } else { strBore = ""; strBore1 = ""; }//end-if-else m_strArrayHallBore2.Add(strBore); m_strArrayHallBore3.Add(strBore1); break; }//end-if }//end-for if (m_iBldType == 1) listBox_bore2.Items.Add(strBore); //*************************************** // 오배수관 관경 계산 //*************************************** iDur = 0; iInx = -1; //iSize=m_dblArrayEql1.GetSize(); dblBore = m_dblArrayBore3[inx]; int i; if (dblBore > 0) { m_dblFUD += m_dblArrayFUD[inx]; // 배수용(fuD) iSize = m_dblArrayRowfuD1.Count(); for (i = 0; i < iSize; i++) { if (m_dblFUD <= m_dblArrayRowfuD1[i]) { strBore = String.Format("{0}", m_dblArrayRowBore1[i]); m_strArrayRowfuD1.Add(strBore); break; }//end-if }//end-for iSize = m_dblArrayRowfuD2.Count(); for (i = 0; i < iSize; i++) { if (m_dblFUD <= m_dblArrayRowfuD2[i]) { strBore = String.Format("{0}", m_dblArrayRowBore2[i]); m_strArrayRowfuD2.Add(strBore); break; }//end-if }//end-for iSize = m_dblArrayRowfuD3.Count(); for (i = 0; i < iSize; i++) { if (m_dblFUD <= m_dblArrayRowfuD3[i]) { strBore = String.Format("{0}", m_dblArrayRowBore3[i]); m_strArrayRowfuD3.Add(strBore); break; }//end-if }//end-for } else { strBore = ""; m_strArrayRowfuD1.Add(strBore); m_strArrayRowfuD2.Add(strBore); m_strArrayRowfuD3.Add(strBore); }//end-if } private void button2_Click(object sender, EventArgs e) { string[] strList = { "위생기구일람표", "동시사용률", "균등표", "급수급탕지관의관경선정표", "환탕지관의관경선정표", "급수급탕횡주관및입상관경표", "오배수관의입상관경선정표", "오배수관의횡주관경선정표", "오배수관의횡지관경선정표" }; string strCSV = System.String.Format("\\plb_{0}.csv", "위생기구일람표"); string strCSVFile = m_strpath + strCSV; Form_SanitaryPipe dlg = new Form_SanitaryPipe(); dlg.ShowDialog(); } private void listBox_name_MouseDoubleClick(object sender, MouseEventArgs e) { int inx = listBox_name.SelectedIndex; AddPlbName(inx); } //콤보박스1 private void cmb_bldtype_SelectedIndexChanged(object sender, EventArgs e) { m_iBldType = cmb_bldtype.SelectedIndex; OnSelchangeComboPipetype(null, null); } //콤보박스2 private void OnSelchangeComboPipetype(object sender, EventArgs e) { m_iPipeType = cmb_pipetype.SelectedIndex; /* 급수,급탕지관 환탕지관 급수,급탕 횡주관/입상관 오배수관의 횡지관 오배수관의 횡주관 오배수관의 입상관 */ listBox_bore1.Items.Clear(); listBox_bore2.Items.Clear(); int iSize, i; switch (m_iPipeType) { case 0: listBox_bore2.Show(); if (m_iBldType == 0) { // 사무실 및 일반건물 iSize = m_strArrayOfficeBore1.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayOfficeBore1[i]); }//end-for iSize = m_strArrayOfficeBore2.Count(); for (i = 0; i < iSize; i++) { listBox_bore2.Items.Add(m_strArrayOfficeBore2[i]); }//end-for } else { //체육관,극장,집회장 iSize = m_strArrayHallBore1.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayHallBore1[i]); }//end-for iSize = m_strArrayHallBore2.Count(); for (i = 0; i < iSize; i++) { listBox_bore2.Items.Add(m_strArrayHallBore2[i]); }//end-for } break; case 1: listBox_bore2.Hide(); if (m_iBldType == 0) { iSize = m_strArrayOfficeBore3.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayOfficeBore3[i]); }//end-for } else { iSize = m_strArrayHallBore3.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayHallBore3[i]); }//end-for }//end-if-else break; case 2: listBox_bore2.Show(); iSize = m_strArrayColCWSupply.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayColCWSupply[i]); listBox_bore2.Items.Add(m_strArrayColHWSupply[i]); }//end-for break; case 3: listBox_bore2.Hide(); iSize = m_strArrayRowfuD1.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayRowfuD1[i]); }//end-for break; case 4: listBox_bore2.Hide(); iSize = m_strArrayRowfuD2.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayRowfuD2[i]); }//end-for break; case 5: listBox_bore2.Hide(); iSize = m_strArrayRowfuD3.Count(); for (i = 0; i < iSize; i++) { listBox_bore1.Items.Add(m_strArrayRowfuD3[i]); }//end-for break; }//end-switch } //Del 버튼 private void button3_Click(object sender, EventArgs e) { int inx = listBox_name1.SelectedIndex; if (inx < 0) return; m_intName1.RemoveAt(inx); int len = m_intName1.Count(); string s; List Tmp = new List(); for (int i = 0; i < len; i++) { Tmp.Add(m_intName1[i]); }//end-for OnButtonReset(); for (int i = 0; i < len; i++) { AddPlbName(Tmp[i]); }//end-for } //Reset 버튼 private void button4_Click(object sender, EventArgs e) { OnButtonReset(); } private void OnButtonReset() { // TODO: Add your control notification handler code here listBox_name1.Items.Clear(); m_intName1.Clear(); // m_intName1. listBox_bore1.Items.Clear(); listBox_bore2.Items.Clear(); // 급수 m_dblEqlNo1 = 0; m_dblSyncUseRate1 = 0; m_dblSyncOpenNo1 = 0; m_iCnt1 = 0; // 급탕 m_dblEqlNo2 = 0; m_dblSyncUseRate2 = 0; m_dblSyncOpenNo2 = 0; m_iCnt2 = 0; // 오배수 m_dblEqlNo2 = 0; m_dblSyncUseRate3 = 0; m_dblSyncOpenNo3 = 0; m_iCnt3 = 0; m_dblFUCS = 0; // 기구급수부하단위 m_dblFUHS = 0; // 기구급탕부하단위 m_dblFUD = 0; // 기구배수부하단위 // 급수지관 m_strArrayOfficeBore1.Clear(); // 사무실 관경 m_strArrayHallBore1.Clear(); // 극장 관경 // 급탕지관 m_strArrayOfficeBore2.Clear(); // 사무실 관경 m_strArrayHallBore2.Clear(); // 극장 관경 // 환탕지관 m_strArrayOfficeBore3.Clear(); // 사무실 관경 m_strArrayHallBore3.Clear(); // 극장 관경 // 급수,급탕 횡주관 및 입상관경 m_strArrayColCWSupply.Clear(); // 급수 관경 m_strArrayColHWSupply.Clear(); // 급탕 관경 //openDwg(); } private void cmb_loss_DrawItem(object sender, DrawItemEventArgs e) { System.Windows.Forms.ComboBox cbx = sender as System.Windows.Forms.ComboBox; if (cbx != null) { e.DrawBackground(); if (e.Index >= 0) { StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Near; Brush brush = new SolidBrush(cbx.ForeColor); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) brush = SystemBrushes.HighlightText; e.Graphics.DrawString(cbx.Items[e.Index].ToString(), cbx.Font, brush, e.Bounds, sf); } } } private void cmb_loss_DrawItem_1(object sender, DrawItemEventArgs e) { System.Windows.Forms.ComboBox cbx = sender as System.Windows.Forms.ComboBox; if (cbx != null) { // Always draw the background e.DrawBackground(); // Drawing one of the items? if (e.Index >= 0) { // Set the string alignment. Choices are Center, Near and Far StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Far; // Set the Brush to ComboBox ForeColor to maintain any ComboBox color settings // Assumes Brush is solid Brush brush = new SolidBrush(cbx.ForeColor); // If drawing highlighted selection, change brush if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) brush = SystemBrushes.HighlightText; // Draw the string e.Graphics.DrawString(cbx.Items[e.Index].ToString(), cbx.Font, brush, e.Bounds, sf); } } } private void txt_width_TextChanged(object sender, EventArgs e) { double w = 0d; double h = 0d; double dia = 0d; if (CalSize(ref w, ref h, ref dia)) { DuctDia = Math.Round(dia, 0); textBoxDe.Text = string.Format("{0}", Math.Round(dia, 0)); } } private void txt_height_TextChanged(object sender, EventArgs e) { double w = 0d; double h = 0d; double dia = 0d; if (CalSize(ref w, ref h, ref dia)) { DuctDia = Math.Round(dia, 0); textBoxDe.Text = string.Format("{0}", Math.Round(dia, 0)); } } private bool CalSize(ref double w, ref double h, ref double dia) { bool bRC = false; if (double.TryParse(txt_width.Text, out w) && double.TryParse(txt_height.Text, out h)) { dia = 1.3 * (Math.Pow(w * h, 0.625) / Math.Pow(w + h, 0.25)); bRC = true; } return bRC; } private void textBoxDe_TextChanged(object sender, EventArgs e) { double dia = 0d; if (double.TryParse(textBoxDe.Text, out dia)) { DuctDia = Math.Round(dia,0); } } private void label26_Click(object sender, EventArgs e) { } private void txt_width1_TextChanged(object sender, EventArgs e) { double w = 0d; double h = 0d; double dia = 0d; double dd = 0d; double dia1 = 0d; double minVal = double.MaxValue; double dia_prev = 0d; if (double.TryParse(txt_width1.Text, out w)) { this.txt_height1.TextChanged -= txt_height1_TextChanged; for (double h1 = 50d; h1 < 2050d; h1 += 50d) { dia = Math.Round(1.3 * (Math.Pow(w * h1, 0.625) / Math.Pow(w + h1, 0.25)), 0); if (DuctDia >= dia_prev && DuctDia <= dia) { h = h1; break; } dia_prev = dia + 1d; } this.txt_height1.Text = string.Format("{0}", h); //textBoxAspectRatio1.Text = string.Format("{0}", Math.Round(w / h, 1)); this.txt_height1.TextChanged += txt_height1_TextChanged; } } private void txt_height1_TextChanged(object sender, EventArgs e) { double w = 0d; double h = 0d; double dia = 0d; double dd = 0d; double dia1 = 0d; double minVal = double.MaxValue; double dia_prev = 0d; if (double.TryParse(txt_height1.Text, out h)) { this.txt_width1.TextChanged -= txt_width1_TextChanged; for (double w1 = 50d; w1 < 2050d; w1 += 50d) { dia = Math.Round(1.3 * (Math.Pow(w1 * h, 0.625) / Math.Pow(w1 + h, 0.25)), 0); if (DuctDia >= dia_prev && DuctDia <= dia) { w = w1; break; } dia_prev = dia + 1d; } this.txt_width1.Text = string.Format("{0}", w); //textBoxAspectRatio1.Text = string.Format("{0}", Math.Round(w / h, 1)); this.txt_width1.TextChanged += txt_width1_TextChanged; } } private void Form_Calpad_Load(object sender, EventArgs e) { this.KeyPreview = true; } private void Form_Calpad_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.DialogResult = DialogResult.Cancel; } else if (e.KeyCode == Keys.Enter) { this.DialogResult = DialogResult.OK; } } } }