/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOS != null) { // Cache items to add, which prevents prop changed being called for each add. (Fixes FWR-3083) List <HvoTssComboItem> itemsToAdd = new List <HvoTssComboItem>(); foreach (var slot in GetSlots()) { string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slot.Hvo, m_tsf.MakeString(name, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle)); itemsToAdd.Add(newItem); if (m_selectedSlot != null && m_selectedSlot.Hvo == newItem.Hvo) { matchIdx = itemsToAdd.Count - 1; } } } m_fwcbSlots.Items.AddRange(itemsToAdd.ToArray()); } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlot = null; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }
/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOSHvo > 0) { Set <int> hvoSlots = GetHvoSlots(); foreach (int slotID in hvoSlots) { IMoInflAffixSlot slot = MoInflAffixSlot.CreateFromDBObject(m_cache, slotID); string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slotID, m_tsf.MakeString(name, m_cache.LangProject.DefaultAnalysisWritingSystem)); int idx = m_fwcbSlots.Items.Add(newItem); if (newItem.Hvo == m_selectedSlotHvo) { matchIdx = idx; } } } } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlotHvo = 0; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }