using Autodesk.Revit.UI; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using KDCS.Utils; namespace KMBIM { public partial class Form_SanitaryPipe : Form { public Form_SanitaryPipe() { InitializeComponent(); } string Tmp, m_strpath; private void Form_SanitaryPipe_Load(object sender, EventArgs e) { this.KeyPreview = true; string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location; //m_strpath = Tmp.Replace("\\KMBIM2019.dll", ""); m_strpath = Util.GetKMBIMLibraryFolder("\\Libraries\\CalPad\\MST"); listBox1.ItemHeight = 30; string[] strList = { "위생기구 일람표" ,"동시사용률","균등표","급수급탕지관의 관경선정표" ,"급수급탕 횡주관 및 입상관경표","오배수관의 입상 관경선정표","오배수관의 횡주관경선정표","오배수관의 횡지관경선정표"}; for (int i = 0; i < strList.Count(); i++) { listBox1.Items.Add(strList[i]); } } //확인버튼 private void button1_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; } //취소버튼 private void button2_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; } //저장버튼 private void button3_Click(object sender, EventArgs e) { } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { List str_lst = new List(); str_lst.Add("plb_위생기구일람표.csv"); str_lst.Add("plb_동시사용률.csv"); str_lst.Add("plb_균등표.csv"); str_lst.Add("plb_급수급탕지관의관경선정표.csv"); str_lst.Add("plb_급수급탕횡주관및입상관경표.csv"); str_lst.Add("plb_오배수관의입상관경선정표.csv"); str_lst.Add("plb_오배수관의횡주관경선정표.csv"); str_lst.Add("plb_오배수관의횡지관경선정표.csv"); str_lst.Add("plb_환탕지관의관경선정표.csv"); int selidx = listBox1.SelectedIndex; listView1.View = View.Details; //listView1.GridLines = true; string strCSV = string.Format("\\{0}", str_lst[selidx]); TaskDialog.Show("1", "" + strCSV); strCSV = m_strpath + strCSV; //ReadCSV(strCSV); listView1.Clear(); try { using (FileStream fs = new FileStream(strCSV, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, Encoding.Default, false)) { string lines = null; string[] keys = null; string[] values = null; string[] str = null; int cnt = 0; while ((lines = sr.ReadLine()) != null) { if (string.IsNullOrEmpty(lines)) return; if (cnt == 0) //첫번째 줄 { keys = lines.Split(','); // 콤마로 분리 //keys[0] = keys[0].Replace("#", ""); // "#"을 ""로 교체 for (int i = 0; i < keys.Length; i++) { //aa += keys[i]; listView1.Columns.Add(keys[i]); //if (i != keys.Length - 1) //aa += ", "; } //aa += "\n"; cnt++; continue; } else { values = lines.Split(','); // 콤마로 분리 ListViewItem lvi = new ListViewItem(keys); for (int i = 0; i < keys.Length; i++) { for (int j = 0; j < values.Length; j++) { lvi.SubItems.Add(values[j]); } } } cnt++; } //TaskDialog.Show("1", "" + aa); } } } catch (Exception) { Console.WriteLine(e.ToString()); } } private void Form_SanitaryPipe_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.DialogResult = DialogResult.Cancel; } else if (e.KeyCode == Keys.Enter) { this.DialogResult = DialogResult.OK; } } static void ReadCSV(string path) { try { using (FileStream fs = new FileStream(path, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, Encoding.Default, false)) { string lines = null; string[] keys = null; string[] values = null; string aa = null; int cnt = 0; while ((lines = sr.ReadLine()) != null) { if (string.IsNullOrEmpty(lines)) return; if (cnt == 0) //첫번째 줄 { keys = lines.Split(','); // 콤마로 분리 //keys[0] = keys[0].Replace("#", ""); // "#"을 ""로 교체 for (int i = 0; i < keys.Length; i++) { //aa += keys[i]; if (i != keys.Length - 1) aa += ", "; } aa += "\n"; continue; } values = lines.Split(','); // 콤마로 분리 for (int i = 0; i < values.Length; i++) { //Console.Write(values[i]); aa += values[i]; if (i != values.Length - 1) aa += ", "; } aa += "\n"; cnt++; } TaskDialog.Show("1", "" + aa); } } } catch (Exception e) { Console.WriteLine(e.ToString()); } } } }