private void OnClassSkillEditButtonClick(object sender, EventArgs e) { List <SkillModel> skills; //set up the window SkillEditWindow = new CheckedListBoxEditWindow(); SkillEditWindow.SetSaveEvent(OnSkillEditSaveButtonClick); SkillEditWindow.SetCancelEvent(OnSkillEditCancelButtonClick); skills = SkillModel.GetAll(); foreach (SkillModel skill in skills) { SkillEditWindow.AddCheckbox(skill.Name, ClassSkillsListBox.Items.Contains(skill.Name)); } SkillEditWindow.Show(); SkillEditWindow.Left = this.Left + ChildWindowLocation.X; SkillEditWindow.Top = this.Top + ChildWindowLocation.Y; }
private void OnSkillEditSaveButtonClick(object sender, EventArgs e) { List <SkillModel> skills; skills = SkillModel.GetAll(); Model.ClassSkills = new List <SkillModel>(); for (int i = 0; i < skills.Count; i++) { if (SkillEditWindow.GetCheckboxStatus(i) == true) { Model.ClassSkills.Add(skills[i]); } } //update the class skills list box ClassSkillsListBox.Items.Clear(); foreach (SkillModel skill in Model.ClassSkills) { ClassSkillsListBox.Items.Add(skill.Name); } DataHasChanged = true; SkillEditWindow.Close(); }