private void button5_Click(object sender, EventArgs e) { string fname = textBox2.Text; fname = "defend-" + fname; StreamReader readfile; try { readfile = new StreamReader(new FileStream(fname, FileMode.Open), Encoding.UTF8); if (readfile == null) return; } catch { MessageBox.Show("couldn't open file {0} for reading", fname); return; } string line; int count; line = readfile.ReadLine(); try { count = Convert.ToInt32(line); } catch { count = 0; } listView1.Items.Clear(); for (int i = 0; i < count; i++) { try { line = readfile.ReadLine(); string[] items = line.Split(','); DefenseSkills askill = new DefenseSkills(); askill.skillid = Convert.ToUInt32(items[0]); askill.condition = Convert.ToInt32(items[1]); askill.comparison = Convert.ToInt32(items[2]); askill.value = Convert.ToInt32(items[3]); askill.skillname = gs.skills[askill.skillid]; askill.effect = Convert.ToUInt32(items[4]); askill.MP = Convert.ToUInt32(items[5]); ListViewItem item = new ListViewItem(askill.skillname); item.SubItems.Add(condition.Items[askill.condition].ToString()); item.SubItems.Add(compare.Items[askill.comparison].ToString()); item.SubItems.Add(askill.value.ToString()); item.SubItems.Add(askill.MP.ToString()); foreach (object o in eff.Items) { Effects neweffect = (Effects)o; if (neweffect.id == askill.effect) { //found it item.SubItems.Add(neweffect.name); } } item.Tag = askill; listView1.Items.Add(item); } catch { } } }
private void button1_Click(object sender, EventArgs e) { //add to listview Effects thisEffect = new Effects(); DefenseSkills askill = new DefenseSkills(); askill.comparison = compare.SelectedIndex; askill.condition = condition.SelectedIndex; askill.skillname = sl.Items[sl.SelectedIndex].ToString(); askill.skillid = ((skill)sl.Items[sl.SelectedIndex]).id; try { askill.value = Convert.ToInt32(value.Text); } catch { askill.value = 0; } thisEffect = ((Effects)eff.SelectedItem); askill.effect = thisEffect.id; try { askill.MP = Convert.ToUInt32(tb_mp.Text); } catch { askill.MP = 1500; } ListViewItem item = new ListViewItem(askill.skillname); item.SubItems.Add(condition.Items[askill.condition].ToString()); item.SubItems.Add(compare.Items[askill.comparison].ToString()); item.SubItems.Add(askill.value.ToString()); item.SubItems.Add(thisEffect.name); item.SubItems.Add(askill.MP.ToString()); item.Tag = askill; listView1.Items.Add(item); }