Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the styles combo boxes on the formatting toolbar, with the correct style name.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void UpdateStyleComboBoxValue(IRootSite rootsite)
        {
            // If we don't have a paraStyleListHelper, we can't update the paragraph or
            // character style combo.
            if (ParaStyleListHelper == null || rootsite == null || rootsite.EditingHelper == null)
            {
                return;
            }

            FwEditingHelper fwEditingHelper = rootsite.EditingHelper as FwEditingHelper;

            if (fwEditingHelper != null && fwEditingHelper.IsPictureReallySelected)
            {
                return;
            }

            string paraStyleName = rootsite.EditingHelper.GetParaStyleNameFromSelection();
            var    style         = (paraStyleName == string.Empty) ? null :
                                   ParaStyleListHelper.StyleFromName(paraStyleName);

            RefreshParaStyleComboBoxList(style, rootsite);
            if (ParaStyleListHelper.SelectedStyleName != paraStyleName)
            {
                ParaStyleListHelper.SelectedStyleName = paraStyleName;
            }

            ContextValues currentContext = (style != null) ? style.Context :
                                           (fwEditingHelper != null) ? fwEditingHelper.InternalContext : ContextValues.General;

            if (CharStyleListHelper != null)
            {
                string charStyleName = rootsite.EditingHelper.GetCharStyleNameFromSelection();
                if (CharStyleListHelper.ActiveView != rootsite as Control ||
                    m_prevParaStyleContext != currentContext ||
                    (charStyleName != null && !CharStyleListHelper.Contains(charStyleName)) ||
                    (charStyleName == null && m_prevParaStyleContext == ContextValues.Note) ||
                    (fwEditingHelper != null && fwEditingHelper.ForceCharStyleComboRefresh))
                {
                    RefreshCharStyleComboBoxList(currentContext, rootsite);
                }
                if (charStyleName == string.Empty)
                {
                    charStyleName = StyleUtils.DefaultParaCharsStyleName;
                }
                if (charStyleName == null)
                {
                    charStyleName = string.Empty;
                }
                if (CharStyleListHelper.SelectedStyleName != charStyleName)
                {
                    CharStyleListHelper.SelectedStyleName = charStyleName;
                }
            }
            m_prevParaStyleContext = currentContext;
        }