private void Form1_Load(object sender, EventArgs e) { formController = new FormController(this); currentState = State.Viewing; ShowFileControls(false); ToggleAllControls(false); }
private bool TryInitializingTraitsDataGridViews(FormController formController) { if (formController?.LoadedBackstoryFile?.SelectedBackstory is Backstory backstory) { dataGridViewTraitsDisallowed.DataSource = backstory.disallowedTraits; dataGridViewTraitsForced.DataSource = backstory.forcedTraits; return(true); } return(false); }
private void UpdateListBox(FormController formController) { BindingList <string> defNames = new BindingList <string>(); foreach (var def in formController.LoadedBackstoryFile.Backstories) { defNames.Add(def.defName); } listBox1.DataSource = defNames; }
private bool TryInitializingTraitsComboboxes(FormController formController) { if (formController?.LoadedTraitEntryFile?.entries is List <TraitEntry> entries) { comboBoxTraitsForced.DataSource = new List <TraitEntry>(entries); comboBoxTraitsForced.DisplayMember = "label"; comboBoxTraitsDisabled.DataSource = new List <TraitEntry>(entries); comboBoxTraitsDisabled.DisplayMember = "label"; return(true); } return(false); }
private void UpdateComboboxesAndDataViews(FormController formController) { var currentIndex = listBox1.SelectedIndex; //var realIndex = currentIndex % defNames.ToArray().Length; if (listBox1.SelectedIndex >= 0) { TryUpdatingBackstoryListBoxIndex(listBox1.SelectedIndex); if (!TryInitializingTraitsComboboxes(formController)) { throw new Exception("Failed to initialize trait comboboxes."); } if (!TryInitializingTraitsDataGridViews(formController)) { MessageBox.Show("Failed to initialize trait data grid views." + "\n\n" + Environment.StackTrace.ToString()); } } currentState = State.Viewing; }