Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves border info into a StyleInfo
        /// </summary>
        /// <param name="styleInfo">styleInfo to save into</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToInfo(StyleInfo styleInfo)
        {
            CheckDisposed();

            if (styleInfo.IsCharacterStyle)
            {
                Debug.Assert(false, "Somehow, the Border tab has been asked to write its data to a character-based style [" + styleInfo.Name + "].");
                return;
            }

            // Save the border widths
            bool newInherit = m_cboWidth.IsInherited;
            BorderThicknesses newThickness = new BorderThicknesses();
            int width = s_borderSizes[m_cboWidth.AdjustedSelectedIndex];

            newThickness.Bottom   = (m_chkBottom.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Top      = (m_chkTop.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Leading  = (m_chkLeft.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Trailing = (m_chkRight.CheckState == CheckState.Checked) ? width : 0;
            if (styleInfo.BorderThickness.Save(newInherit, newThickness))
            {
                styleInfo.Dirty = true;
            }

            // save the border color
            if (styleInfo.IBorderColor.Save(IsInherited(m_cboColor), m_cboColor.ColorValue))
            {
                styleInfo.Dirty = true;
            }
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get a string representing the border settings. These settings are optional
        /// and require an additional tag based on the values given
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static string BorderAsString(IParaStyleInfo paraStyleInfo)
        {
            // Assume that there is no border unless proven otherwise
            string borderString = string.Empty;
            var    border       = new BorderThicknesses(0, 0, 0, 0);

            if (paraStyleInfo.BorderLeading != null)
            {
                border.Leading = paraStyleInfo.BorderLeading.Value;
            }
            if (paraStyleInfo.BorderTrailing != null)
            {
                border.Trailing = paraStyleInfo.BorderTrailing.Value;
            }
            if (paraStyleInfo.BorderTop != null)
            {
                border.Top = paraStyleInfo.BorderTop.Value;
            }
            if (paraStyleInfo.BorderBottom != null)
            {
                border.Bottom = paraStyleInfo.BorderBottom.Value;
            }

            string borderColorString = ((paraStyleInfo.BorderColor == null || paraStyleInfo.BorderColor.Value == Color.Empty)
                                                                                        ? string.Empty
                                                                                        : @"\brdrcf" + paraStyleInfo.BorderColor.Value.ToKnownColor());

            if (border.Top > 0)
            {
                borderString += @"\brdrt\brdrs\brdrw" + ConvertMillipointsToTwips(border.Top)
                                + @"\brsp20" + borderColorString;
            }
            if (border.Bottom > 0)
            {
                borderString += @"\brdrb\brdrs\brdrw" + ConvertMillipointsToTwips(border.Bottom)
                                + @"\brsp20" + borderColorString;
            }
            if (border.Leading > 0)
            {
                borderString += @"\brdrl\brdrs\brdrw" + ConvertMillipointsToTwips(border.Leading)
                                + @"\brsp80" + borderColorString;
            }
            if (border.Trailing > 0)
            {
                borderString += @"\brdrr\brdrs\brdrw" + ConvertMillipointsToTwips(border.Trailing)
                                + @"\brsp80" + borderColorString;
            }
            return(borderString);
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves border info into a StyleInfo
        /// </summary>
        /// <param name="styleInfo">styleInfo to save into</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToInfo(StyleInfo styleInfo)
        {
            CheckDisposed();

            // Save the border widths
            bool newInherit = m_cboWidth.IsInherited;
            BorderThicknesses newThickness = new BorderThicknesses();
            int width = s_borderSizes[m_cboWidth.AdjustedSelectedIndex];

            newThickness.Bottom   = (m_chkBottom.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Top      = (m_chkTop.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Leading  = (m_chkLeft.CheckState == CheckState.Checked) ? width : 0;
            newThickness.Trailing = (m_chkRight.CheckState == CheckState.Checked) ? width : 0;
            if (styleInfo.BorderThickness.Save(newInherit, newThickness))
            {
                styleInfo.Dirty = true;
            }

            // save the border color
            if (styleInfo.IBorderColor.Save(IsInherited(m_cboColor), m_cboColor.ColorValue))
            {
                styleInfo.Dirty = true;
            }
        }