/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the form based on a style being selected. /// </summary> /// <param name="styleInfo">The style info.</param> /// ------------------------------------------------------------------------------------ public void UpdateForStyle(StyleInfo styleInfo) { CheckDisposed(); #if __MonoCS__ // On Mono, the sequence of events when changing styles can cause this to be // called even when switching to a character style. See FWNX-870. if (!styleInfo.IsParagraphStyle) { return; } #endif m_dontUpdateInheritance = true; bool fDifferentStyle = m_StyleInfo == null ? true : (styleInfo.Name != m_StyleInfo.Name); // Don't use a 0 size bullet. Fixes FWNX-575. if (styleInfo != null && styleInfo.IBullet != null) { if (styleInfo.IBullet.Value.FontInfo.FontSize.Value == 0) { styleInfo.IBullet.Value.FontInfo.m_fontSize = new InheritableStyleProp <int>(FontInfo.kDefaultFontSize); } } m_StyleInfo = styleInfo; m_preview.IsRightToLeft = m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triNotSet ? m_DefaultTextDirectionRtoL : m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue; m_preview.WritingSystemFactory = m_StyleInfo.Cache.WritingSystemFactory; m_preview.WritingSystemCode = m_StyleInfo.Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle; VwBulNum bulletType; // Note: don't assign m_currentStyleBulletInfo until the end of this method // since setting some of the values change m_currentStyleBulletInfo before we have set // everything. BulletInfo bulletInfo = new BulletInfo(styleInfo.IBullet.Value); bulletType = bulletInfo.m_numberScheme; // If we have a different style, we have to reload the font info. If it is the same // style we were here before so we keep the font info that we already have. if (fDifferentStyle) { if ((int)bulletType >= (int)VwBulNum.kvbnBulletBase) { // use font from style for bullets m_BulletsFontInfo = bulletInfo.FontInfo; // create a number font based on the font for bullets m_NumberFontInfo = new FontInfo(m_BulletsFontInfo); m_NumberFontInfo.m_fontName.ResetToInherited(FontInfo.GetUIFontName( styleInfo.FontInfoForWs(-1).m_fontName.Value)); } else { // use font from style for numbers m_NumberFontInfo = bulletInfo.FontInfo; if (bulletType == VwBulNum.kvbnNone) { m_NumberFontInfo.m_fontName.ResetToInherited(FontInfo.GetUIFontName( styleInfo.FontInfoForWs(-1).m_fontName.Value)); } // create a bullets font based on the font for numbers m_BulletsFontInfo = new FontInfo(m_NumberFontInfo); // The font for bullets is hard-coded in the views code, so there is no point // in letting the user select any other font for bullets. m_BulletsFontInfo.m_fontName.ResetToInherited("Quivira"); m_BulletsFontInfo.m_fontName.SetDefaultValue("Quivira"); } } m_nudStartAt.Value = bulletInfo.m_start; m_chkStartAt.Checked = (bulletInfo.m_start != 1); m_tbTextBefore.Text = bulletInfo.m_textBefore; m_tbTextAfter.Text = bulletInfo.m_textAfter; m_rbUnspecified.Enabled = styleInfo.Inherits; if (styleInfo.IBullet.IsInherited && styleInfo.Inherits) { m_rbUnspecified.Checked = true; } else if (bulletType == VwBulNum.kvbnNone) { m_rbNone.Checked = true; } else if ((int)bulletType >= (int)VwBulNum.kvbnBulletBase) { m_rbBullet.Checked = true; } else // NumberBase { m_rbNumber.Checked = true; } m_cboBulletScheme.SelectedIndex = GetBulletIndexForType(bulletType); m_cboNumberScheme.SelectedIndex = GetNumberSchemeIndexForType(bulletType); m_currentStyleBulletInfo = bulletInfo; UpdateBulletSchemeComboBox(); m_dontUpdateInheritance = false; }