private void AddCharBtn_Click(object sender, EventArgs e) { var c = new dnd_stuff.Controls.CharacterLine(); c.CharLbl.Click += new System.EventHandler(this.HeroSwap); c.CharLbl.Text = "New Character"; bool hasNew = false; foreach (var con in CharactersPnl.Controls) { var cl = (dnd_stuff.Controls.CharacterLine)con; var s = cl.CharLbl.Text; if (s.Equals("New Character")) { hasNew = true; } } if (!hasNew) { this.CharactersPnl.Controls.Add(c); } }
private void LoadSavedCharacters() { string AppdataRoaming = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string path = AppdataRoaming + @"\ProcrastN8\Heros\"; try { foreach (var file in Directory.GetFiles(path)) { if (file.Contains(".xml")) { var c = new dnd_stuff.Controls.CharacterLine(); c.CharLbl.Text = file.Replace(path, "").Replace(".xml", ""); c.CharLbl.Click += new System.EventHandler(this.HeroSwap); this.CharactersPnl.Controls.Add(c); } } } catch { Directory.CreateDirectory(path); } }