/// ------------------------------------------------------------------------------------ /// <summary> /// Fills the style table and populates the list based on it. /// </summary> /// ------------------------------------------------------------------------------------ private void FillStyleList() { m_styleTable.Clear(); for (int i = 0; i < m_styleSheet.CStyles; i++) { var style = m_styleSheet.get_NthStyleObject(i); if (m_applicableStyleContexts == null || m_applicableStyleContexts.Contains(style.Context)) { m_styleTable.Add(style.Name, new StyleInfo(style)); } } if (m_fCanApplyCharacterStyle && !m_fCanApplyParagraphStyle) { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstCharacter; } else if (m_fCanApplyParagraphStyle && !m_fCanApplyCharacterStyle) { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstParagraph; } else if (!m_fCanApplyCharacterStyle && !m_fCanApplyParagraphStyle) { throw new InvalidOperationException("Can't show the Apply Style dialog box if neither character nor paragraph styles can be applied."); } else { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstLim; } m_styleListHelper.AddStyles(m_styleTable, null); m_styleListHelper.Refresh(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This event handles a change for any of the radio buttons that specify the domain /// of the marker (scripture, footnotes, or consultant notes). When a change /// is made, refill the styles list based on what is valid for the domain. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void DomainChanged(object sender, System.EventArgs e) { RadioButton rbtn = sender as RadioButton; chkBackTranslation.Enabled = !rbtnNotes.Checked && !m_fBackTransDomainLocked; if (!chkBackTranslation.Enabled) { chkBackTranslation.Checked = false; } if (rbtn == null || rbtn.Checked) { using (new WaitCursor(this)) { // Decide on what to include or exclude. We will either allow everything // except annotation and internal styles, or only allow annotation and // general styles. List <ContextValues> contextList = new List <ContextValues>(); string[] pseudoStyles = null; m_styleListHelper.ExcludeStylesWithFunction.Clear(); if (rbtnScripture.Checked) { contextList.Add(ContextValues.Annotation); contextList.Add(ContextValues.Internal); contextList.Add(ContextValues.Note); if (chkBackTranslation.Checked) { pseudoStyles = BtPseudoStyles; } else { contextList.Add(ContextValues.BackTranslation); m_styleListHelper.ExcludeStylesWithFunction.Add(FunctionValues.Verse); pseudoStyles = AllPseudoStyles; } m_styleListHelper.ExcludeStylesWithContext = contextList; m_styleListHelper.ExcludeStylesWithFunction.Add(FunctionValues.Footnote); m_styleListHelper.ExcludeStylesWithFunction.Add(FunctionValues.Chapter); } else { contextList.Add(ContextValues.General); if (rbtnFootnotes.Checked) { contextList.Add(ContextValues.Note); contextList.Add(ContextValues.InternalMappable); if (chkBackTranslation.Checked) { contextList.Add(ContextValues.BackTranslation); } } else { contextList.Add(ContextValues.Annotation); } m_styleListHelper.IncludeStylesWithContext = contextList; } // Build the list of styles for the control string styleName = m_styleListHelper.SelectedStyleName; m_styleListHelper.AddStyles(m_StyleSheet as FwStyleSheet, pseudoStyles); m_styleListHelper.SelectedStyleName = styleName; if (ValidStateChanged != null) { ValidStateChanged(this, m_styleListHelper.SelectedStyleName != null && m_styleListHelper.SelectedStyleName != string.Empty); } } } }