private void OnTomeListBoxSelectedIndexChanged(object sender, EventArgs e) { if (DataChangeWarning() == false) { return; } Model = new TomeModel(); if (TomeListBox.SelectedIndex != -1) { Model.Initialize(TomeListBox.SelectedItem.ToString()); } PopulateFields(Model.TomeLongName); }
/// <summary> /// for a given selected record, show its data in the appropriate fields /// </summary> /// <param name="recordName">The name of the record to show</param> private void PopulateFields(string recordName) { int index; if (recordName == string.Empty) { ClearScreen(); DataHasChanged = false; return; } Model.Initialize(recordName); TomeNameInputBox.Text = Model.TomeName; TomeBonusInput.Value = Model.TomeBonus; MinimumLevelInputUpDown.Value = Model.MinLevel; TomeNameLabel.Text = Model.TomeLongName; if (Model.TomeType == "Ability") { TomeTypeAbilityRadioButton.Checked = true; index = AbilityNames.IndexOf(AbilityModel.GetNameFromId(Model.ModifiedID)); ModifierListBox.SetSelected(index, true); } else { TomeTypeSkillRadioButton.Checked = true; index = SkillNames.IndexOf(SkillModel.GetNameFromId(Model.ModifiedID)); ModifierListBox.SetSelected(index, true); } ModVersionLabel.Text = Model.LastUpdatedVersion; ModDateLabel.Text = Model.LastUpdatedDate.ToString(); RecordGUIDLabel.Text = Model.Id.ToString(); //make sure we haven't changed the data (Populating data from the database doesn't count as a change!) DataHasChanged = false; }