Пример #1
0
        /// <summary>
        /// Applies the standard format.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public static string ApplyStandardFormat(BaseClass field, string text, bool bInHtmlFormat, string strFollowedBy, bool bTextPurify)
        {
            if (field.Prefix.Length > 0)
                text = field.Prefix + text;

            string _suffix = string.Empty;

            if(field.Suffix.Length > 0)
            {
                string temp = field.Suffix;
                if(Regex.Match(text, @"[\?|!]$").Success)
                    temp = Regex.Replace(temp, @"\.", "");
                if(strFollowedBy.Length > 0)
                    _suffix = temp;
                else
                    text = text + temp;
            }

            if (bTextPurify)
            {
                text = text.Replace("<", "&lt;").Replace(">", "&gt;");
            }

            if(bInHtmlFormat)
            {
                if (field.Bold || field.Italic || field.Underline)
                {
                    if (field.Bold)
                        text = GetHtmlFormatString(text, TextFormat.Bold);
                    if (field.Italic)
                        text = GetHtmlFormatString(text, TextFormat.Italic);
                    if (field.Underline)
                        text = GetHtmlFormatString(text, TextFormat.Underline);
                }
                else
                    text = GetHtmlFormatString(text, TextFormat.None);
            }
            else
            {
                if (field.Bold || field.Italic || field.Underline)
                {
                    if (field.Bold)
                        text = GetWordMLFormatString(text, TextFormat.Bold);
                    if (field.Italic)
                        text = GetWordMLFormatString(text, TextFormat.Italic);
                    if (field.Underline)
                        text = GetWordMLFormatString(text, TextFormat.Underline);
                    if (strFollowedBy.Length > 0)
                    {
                        text += strFollowedBy;
                        if (field.Bold)
                            _suffix = GetWordMLFormatString(_suffix, TextFormat.Bold);
                        if (field.Italic)
                            _suffix = GetWordMLFormatString(_suffix, TextFormat.Italic);
                        if (field.Underline)
                            _suffix = GetWordMLFormatString(_suffix, TextFormat.Underline);
                        text += _suffix;
                    }
                }
                else
                {
                    text = GetWordMLFormatString(text, TextFormat.None);
                    if(strFollowedBy.Length > 0)
                    {
                        text += strFollowedBy + GetWordMLFormatString(_suffix, TextFormat.None);
                    }
                }
            }
            text = purifyWordString(text);
            return text;
        }
Пример #2
0
 public static string ApplyStandardFormat(BaseClass field, string text, bool bInHtmlFormat)
 {
     return ApplyStandardFormat(field, text, bInHtmlFormat, string.Empty, true);
 }