public static void Load() { Cache.Clear(); var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM spells"); while (reader.Read()) { var spell = new SpellModel() { ID = reader.GetInt32("id"), Name = reader.GetString("nom"), SpriteID = reader.GetInt32("sprite"), SpriteInfos = reader.GetString("spriteInfos"), Level1 = reader.GetString("lvl1"), Level2 = reader.GetString("lvl2"), Level3 = reader.GetString("lvl3"), Level4 = reader.GetString("lvl4"), Level5 = reader.GetString("lvl5"), Level6 = reader.GetString("lvl6"), EffectTargets = reader.GetString("effectTarget"), }; spell.Initialize(); Cache.Add(spell.ID, spell); } reader.Close(); Logger.Info("Loaded @'" + Cache.Count + "'@ Spells"); }
private void OnSpellListBoxSelectedIndexChanged(object sender, EventArgs e) { if (DataChangeWarning() == false) { return; } AllowChangeEvents = false; Model = new SpellModel(); DetailModel.Clear(); if (SpellListBox.SelectedIndex != -1) { Model.Initialize(SpellListBox.SelectedItem.ToString()); DetailModel = SpellDetailsModel.GetAll(Model.Id); } PopulateFields(Model.SpellName); AllowChangeEvents = true; }
private void PopulateFields(string recordName) { bool bitFlag; Model = new SpellModel(); DetailModel = new List <SpellDetailsModel>(); if (recordName != string.Empty) { Model.Initialize(recordName); DetailModel = SpellDetailsModel.GetAll(Model.Id); } //basic fields SpellNameInputBox.Text = Model.SpellName; SpellSchoolComboBox.SelectedItem = SpellSchoolModel.GetNameFromId(Model.SpellSchoolId); SpellIconInputBox.Text = Model.IconFilename; DescriptionPreview.Navigate("about:blank"); DescriptionPreview.Document.OpenNew(false); DescriptionPreview.Document.Write(Model.Description); DescriptionPreview.Refresh(); RangeInputComboBox.SelectedItem = Model.SpellRange; for (int i = 0; i < ComponentCheckListBox.Items.Count; i++) { bitFlag = ((Model.SpellComponents & (1 << i)) > 0); ComponentCheckListBox.SetItemChecked(i, bitFlag); } for (int i = 0; i < MetamagicFeatCheckListBox.Items.Count; i++) { bitFlag = ((Model.MetamagicFeats & (1 << i)) > 0); MetamagicFeatCheckListBox.SetItemChecked(i, bitFlag); } for (int i = 0; i < TargetCheckListBox.Items.Count; i++) { bitFlag = ((Model.Targets & (1 << i)) > 0); TargetCheckListBox.SetItemChecked(i, bitFlag); } DurationInputTextBox.Text = Model.Duration; SavingThrowComboBox.SelectedItem = Model.SavingThrow; if (Model.SpellResistance == true) { SpellResistanceComboBox.SelectedItem = "Yes"; } else { SpellResistanceComboBox.SelectedItem = "No"; } ModDateLabel.Text = Model.LastUpdatedDate.ToString(); ModVersionLabel.Text = Model.LastUpdatedVersion; RecordGUIDLabel.Text = Model.Id.ToString(); //the icon SpellIcon = new IconClass("Spells\\" + Model.IconFilename); SpellIcon.SetLocation(this.Width, this.Height, IconLocation); //the spell detail panel //Delete/Remove Current Controls for (int i = 0; i < SpellDetailSubPanel.Controls.Count; i++) { SpellDetailSubPanel.Controls[i].Dispose(); } SpellDetailSubPanel.Controls.Clear(); SpellDetailClassComboBox.Clear(); SpellDetailLevelComboBox.Clear(); SpellDetailCoolDownTextBox.Clear(); SpellDetailSPCostUpDownBox.Clear(); SpellDetailDeleteButton.Clear(); //reload the panel SpellDetailRecordCount = 0; foreach (SpellDetailsModel detail in DetailModel) { AddSpellDetailRecordUI(detail); } DatabaseName = Model.SpellName; //invalidate the screen to make sure everything gets updated (icon, etc). Invalidate(); }