private void button1_Click(object sender, EventArgs e) { var CNavigating = new CNavigating(); var CSV = new CSV(); var Color = new Color(); string path = CNavigating.openFile("CSVファイルを開く", "CSVファイル (*.CSV)|*.CSV"); if (path == null) return; try { if (CNavigating.judgeEncode(path) == Encode.ShiftJIS) { var parser = new TextFieldParser(path, Encoding.GetEncoding("shift_jis")); foreach (Color item in Color.addColor(CSV.Open(parser), path)) { switch (item.number) { case 1: checkColorBox1.BackColor = item.checkcolor; printColorBox1.BackColor = item.printcolor; textBox1.Text = item.label; break; case 2: checkColorBox2.BackColor = item.checkcolor; printColorBox2.BackColor = item.printcolor; textBox2.Text = item.label; break; case 3: checkColorBox3.BackColor = item.checkcolor; printColorBox3.BackColor = item.printcolor; textBox3.Text = item.label; break; case 4: checkColorBox4.BackColor = item.checkcolor; printColorBox4.BackColor = item.printcolor; textBox4.Text = item.label; break; case 5: checkColorBox5.BackColor = item.checkcolor; printColorBox5.BackColor = item.printcolor; textBox5.Text = item.label; break; case 6: checkColorBox6.BackColor = item.checkcolor; printColorBox6.BackColor = item.printcolor; textBox6.Text = item.label; break; case 7: checkColorBox7.BackColor = item.checkcolor; printColorBox7.BackColor = item.printcolor; textBox7.Text = item.label; break; case 8: checkColorBox8.BackColor = item.checkcolor; printColorBox8.BackColor = item.printcolor; textBox8.Text = item.label; break; case 9: checkColorBox9.BackColor = item.checkcolor; printColorBox9.BackColor = item.printcolor; textBox9.Text = item.label; break; } } } else if (CNavigating.judgeEncode(path) == Encode.UTF8) { var parser = new TextFieldParser(path); foreach (Color item in Color.addColor(CSV.Open(parser), path)) { switch (item.number) { case 1: checkColorBox1.BackColor = item.checkcolor; printColorBox1.BackColor = item.printcolor; textBox1.Text = item.label; break; case 2: checkColorBox2.BackColor = item.checkcolor; printColorBox2.BackColor = item.printcolor; textBox2.Text = item.label; break; case 3: checkColorBox3.BackColor = item.checkcolor; printColorBox3.BackColor = item.printcolor; textBox3.Text = item.label; break; case 4: checkColorBox4.BackColor = item.checkcolor; printColorBox4.BackColor = item.printcolor; textBox4.Text = item.label; break; case 5: checkColorBox5.BackColor = item.checkcolor; printColorBox5.BackColor = item.printcolor; textBox5.Text = item.label; break; case 6: checkColorBox6.BackColor = item.checkcolor; printColorBox6.BackColor = item.printcolor; textBox6.Text = item.label; break; case 7: checkColorBox7.BackColor = item.checkcolor; printColorBox7.BackColor = item.printcolor; textBox7.Text = item.label; break; case 8: checkColorBox8.BackColor = item.checkcolor; printColorBox8.BackColor = item.printcolor; textBox8.Text = item.label; break; case 9: checkColorBox9.BackColor = item.checkcolor; printColorBox9.BackColor = item.printcolor; textBox9.Text = item.label; break; } } } } catch (Exception) { var title = new CNavigating(); MessageBox.Show("カラー情報を読み込めませんでした。", title.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { var CSV = new CSV(); string path = openFile("CSVファイルを開く", "CSVファイル (*.CSV)|*.CSV"); if (path == null) return; try { if (judgeEncode(path) == Encode.ShiftJIS) { TextFieldParser parser = new TextFieldParser(path, Encoding.GetEncoding(932)); addMember(CSV.Open(parser), path); } else if (judgeEncode(path) == Encode.EUCJP) { TextFieldParser parser = new TextFieldParser(path, Encoding.GetEncoding(51932)); addMember(CSV.Open(parser), path); } else if (judgeEncode(path) == Encode.ISO2022JP) { TextFieldParser parser = new TextFieldParser(path, Encoding.GetEncoding(50220)); addMember(CSV.Open(parser), path); } else if (judgeEncode(path) == Encode.UTF8) { TextFieldParser parser = new TextFieldParser(path); addMember(CSV.Open(parser), path); } } catch (Exception) { var title = new CNavigating(); MessageBox.Show(Path.GetFileName(path) + " を開くことができませんでした。", title.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }