Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the character style list of the combo box
        /// </summary>
        /// <param name="styleContext">the current Paragraph style context, usually based on
        /// the selection</param>
        /// <param name="view">The currently active view</param>
        /// ------------------------------------------------------------------------------------
        private void RefreshCharStyleComboBoxList(ContextValues styleContext, IRootSite view)
        {
            CharStyleListHelper.IncludeStylesWithContext.Clear();

            FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper;

            if (editingHelper != null && editingHelper.ApplicableStyleContexts != null)
            {
                CharStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts);
            }
            else
            {
                CharStyleListHelper.IncludeStylesWithContext.Add(styleContext);
                if (!CharStyleListHelper.IncludeStylesWithContext.Contains(ContextValues.General))
                {
                    CharStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General);
                }
                if (editingHelper != null &&
                    !CharStyleListHelper.IncludeStylesWithContext.Contains(editingHelper.InternalContext))
                {
                    CharStyleListHelper.IncludeStylesWithContext.Add(editingHelper.InternalContext);
                }
            }
            CharStyleListHelper.Refresh();
            CharStyleListHelper.ActiveView = view as Control;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Reload the styles combo box and update it's current value.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void InitStyleComboBox()
        {
            if (Cache == null)
            {
                return;
            }

            if (ParaStyleListHelper != null)
            {
                ParaStyleListHelper.ShowOnlyStylesOfType = StyleType.kstParagraph;
                ParaStyleListHelper.AddStyles(StyleSheet);
            }

            if (CharStyleListHelper != null)
            {
                CharStyleListHelper.ShowOnlyStylesOfType = StyleType.kstCharacter;
                CharStyleListHelper.AddStyles(StyleSheet);
            }

            UpdateStyleComboBoxValue(ActiveView);
        }