private void buttonChangeSection_Click(object sender, EventArgs e) { SectionComboBoxItem item = (SectionComboBoxItem) comboBoxSection.Items[comboBoxSection.SelectedIndex]; if (item != null) { buttonChangeSection.Enabled = false; buttonChangeSection.Update(); foreach (FableMod.TNG.Thing thing in mySelectedThings) { if (thing.Section != item.mySection) { thing.Detach(); item.mySection.AddThing(thing); } } buttonChangeSection.Enabled = true; } }
private void UpdateComboBoxes(FableMod.TNG.Thing[] things) { comboBoxSection.Items.Clear(); if (things == null) { comboBoxMap.Enabled = false; comboBoxSection.Enabled = false; buttonChangeMap.Enabled = false; buttonChangeSection.Enabled = false; } else { comboBoxMap.Enabled = true; comboBoxSection.Enabled = true; buttonChangeMap.Enabled = myMaps.Count > 1; buttonChangeSection.Enabled = true; FableMod.TNG.TNGFile tngFile = null; FableMod.TNG.TNGFile tng = things[0].Section.TNGFile; for (int i = 1; i < things.Length; ++i) { if (tng != things[i].Section.TNGFile) { tng = null; } } comboBoxMap.SelectedIndex = -1; for (int i = 0; i < comboBoxMap.Items.Count; ++i) { MapComboBoxItem item = (MapComboBoxItem)comboBoxMap.Items[i]; if (item.myMap.TNG == tng) { tngFile = tng; comboBoxMap.SelectedIndex = i; break; } } comboBoxSection.Items.Clear(); if (tng != null) { FableMod.TNG.Section section = things[0].Section; for (int i = 1; i < things.Length; ++i) { if (section != things[i].Section) { section = null; } } for (int i = 0; i < tng.SectionCount; ++i) { SectionComboBoxItem item = new SectionComboBoxItem( tng.get_Sections(i)); int index = comboBoxSection.Items.Add(item); if (item.mySection == section) { comboBoxSection.SelectedIndex = index; } } } } }