SIL.FieldWorks.LexText.Controls.MSAGroupBox.ResetSlotCombo C# (CSharp) Method

ResetSlotCombo() private method

Reset the slot combo box.
private ResetSlotCombo ( ) : void
return void
		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();
		}