private void ComboBoxChange(object sender, InputType Type) { string newValueString; DestinySphereModel modelofDestinyType; switch (Type) { case InputType.DestinySphere: { //grab the selection's guid newValueString = StartingDestinySphereComboBox.SelectedItem.ToString(); modelofDestinyType = new DestinySphereModel(); modelofDestinyType.Initialize(newValueString); Model.StartingDestinySphereId = modelofDestinyType.Id; DataHasChanged = true; break; } case InputType.MaxSpellLevel: { newValueString = MaxSpellLevelComboBox.SelectedItem.ToString(); Model.MaxSpellLevel = Int32.Parse(newValueString); DataHasChanged = true; break; } default: { Debug.WriteLine("Error: Unknown Type in Combo Box Change"); break; } } }
/// <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) { string controlName; ComboBox bonusFeatComboBox; FeatTypeModel featType; List <string> destinyName; DestinySphereModel currentDestiny; Model.Initialize(recordName); //cache the name and abbreviation strings for later comparisons DatabaseName = Model.Name; DatabaseAbbreviation = Model.Abbreviation; ClassNameInputBox.Text = Model.Name; DescriptionPreview.Navigate("about:blank"); DescriptionPreview.Document.OpenNew(false); DescriptionPreview.Document.Write(Model.Description); DescriptionPreview.Refresh(); HitDieInputBox.Text = Model.HitDie.ToString(); ClassNameAbbreviationInputBox.Text = Model.Abbreviation; SkillPointsInputBox.Text = Model.SkillPoints.ToString(); IconNameInputBox.Text = Model.ImageFilename; ClassIcon = new IconClass(Model.ImageFilename); ClassIcon.SetLocation(this.Width, this.Height, IconLocation); for (int i = 1; i <= Constant.NumHeroicLevels; i++) { controlName = "FortSaveInputBox" + i; Controls[controlName].Text = Model.LevelDetails[i - 1].FortitudeSave.ToString(); controlName = "ReflexSaveInputBox" + i; Controls[controlName].Text = Model.LevelDetails[i - 1].ReflexSave.ToString(); controlName = "WillSaveInputBox" + i; Controls[controlName].Text = Model.LevelDetails[i - 1].WillSave.ToString(); controlName = "BABInputBox" + i; Controls[controlName].Text = Model.LevelDetails[i - 1].BaseAttackBonus.ToString(); controlName = "BonusFeatComboBox" + i; bonusFeatComboBox = Controls[controlName] as ComboBox; if (Model.LevelDetails[i - 1].FeatTypeId == Guid.Empty) { bonusFeatComboBox.SelectedIndex = 0; } else { featType = new FeatTypeModel(); featType.Initialize(Model.LevelDetails[i - 1].FeatTypeId); bonusFeatComboBox.SelectedIndex = bonusFeatComboBox.FindStringExact(featType.Name); } } AlignmentsAllowedListBox.Items.Clear(); if (Model.AllowedAlignments != null) { foreach (AlignmentModel alignment in Model.AllowedAlignments) { AlignmentsAllowedListBox.Items.Add(alignment.Name); } } ClassSkillsListBox.Items.Clear(); if (Model.ClassSkills != null) { foreach (SkillModel skill in Model.ClassSkills) { ClassSkillsListBox.Items.Add(skill.Name); } } RecordGUIDLabel.Text = Model.Id.ToString(); ModDateLabel.Text = Model.LastUpdatedDate.ToString(); ModVersionLabel.Text = Model.LastUpdatedVersion; destinyName = DestinySphereModel.GetNames(); StartingDestinySphereComboBox.Items.Clear(); foreach (string name in destinyName) { StartingDestinySphereComboBox.Items.Add(name); } MaxSpellLevelComboBox.Items.Clear(); for (int i = 0; i <= 9; i++) { MaxSpellLevelComboBox.Items.Add(i.ToString()); } MaxSpellLevelComboBox.SelectedIndex = Model.MaxSpellLevel; currentDestiny = new DestinySphereModel(); currentDestiny.Initialize(Model.StartingDestinySphereId); StartingDestinySphereComboBox.SelectedIndex = StartingDestinySphereComboBox.FindStringExact(currentDestiny.Name); //make sure we haven't changed the data (Populating data from the database doesn't count as a change!) DataHasChanged = false; }