private void InitializeStylesComboBox()
{
// ====================================================================
// Set the Style combo box. This one can have a style that isn't defined
// yet. If so, it will show in a different color.
// (This list only shows the Character styles.)
cbStyle.Items.Clear();
cbStyle.Items.Add(NoChange);
cbStyle.SelectedItem = NoChange;
cbStyle.Text = NoChange;
var oc = m_cache.LanguageProject.StylesOC;
if (oc == null || oc.Count < 1)
System.Diagnostics.Debug.WriteLine("No style info retrieved from the cache.");
foreach (var style in oc)
{
if (StyleType.kstCharacter == style.Type)
{
int pos = cbStyle.Items.Add(style.Name);
if (style.Name == m_inlineMarker.Style)
{
cbStyle.SelectedIndex = pos;
cbStyle.SelectedItem = style.Name;
}
}
}
// if there's a Style in the Marker - select it or set it as unique, otherwise select noChange
if (!m_inlineMarker.HasStyle)
{
cbStyle.SelectedItem = NoChange;
}
else
{
int foundPos = cbStyle.FindStringExact(m_inlineMarker.Style);
if (foundPos >= 0)
{
// select the item in the combo that matches
cbStyle.SelectedItem = m_inlineMarker.Style;
}
else
{
// just put it in the text box and set the color
cbStyle.Text = m_inlineMarker.Style;
cbStyle.ForeColor = System.Drawing.Color.Blue;
}
if (cbStyle.Text.Trim().Length == 0)
{
cbStyle.SelectedItem = NoChange;
cbStyle.Text = NoChange;
}
}
}