Пример #1
0
        /// <summary>
        ///   Adds a cell value to the HTML and Text
        /// </summary>
        /// <param name="cell">The cell.</param>
        /// <param name="buffer">The buffer.</param>
        /// <param name="sbHtml">The StringBuilder for HTML.</param>
        /// <param name="appendTab">if set to <c>true</c> [append tab].</param>
        /// <param name="addErrorInfo">if set to <c>true</c> [add error info].</param>
        /// <param name="cutLength">Maximum length of the resulting text</param>
        private static void AddCell(DataGridViewCell cell, StringBuilder buffer, StringBuilder sbHtml, bool appendTab,
                                    bool addErrorInfo, bool cutLength)
        {
            Contract.Requires(cell != null);
            Contract.Requires(buffer != null);
            Contract.Requires(sbHtml != null);

            if (cell == null)
            {
                return;
            }
            var cellValue = cell.FormattedValue?.ToString() ?? string.Empty;

            if (cellValue.Length > 500 && cutLength)
            {
                cellValue = cellValue.Substring(0, 80) + " [...] " + cellValue.Substring(cellValue.Length - 20, 20);
            }

            if (appendTab)
            {
                buffer.Append('\t');
            }
            buffer.Append(EscapeTab(cellValue));

            HTMLStyle.AddHtmlCell(sbHtml, cell.ValueType == typeof(string) ? m_HtmlStyle.TD : m_HtmlStyle.TDNonText,
                                  cellValue, cell.ErrorText, addErrorInfo);
        }
Пример #2
0
        /// <summary>
        ///   Adds a cell value to the HTML and Text
        /// </summary>
        /// <param name="cell">The cell.</param>
        /// <param name="stringBuilder">The buffer.</param>
        /// <param name="sbHtml">The StringBuilder for HTML.</param>
        /// <param name="appendTab">if set to <c>true</c> [append tab].</param>
        /// <param name="addErrorInfo">if set to <c>true</c> [add error info].</param>
        /// <param name="cutLength">Maximum length of the resulting text</param>
        private void AddCell(
            [NotNull] DataGridViewCell cell,
            [NotNull] StringBuilder stringBuilder,
            [NotNull] StringBuilder sbHtml,
            bool appendTab,
            bool addErrorInfo,
            bool cutLength, HTMLStyle style)
        {
            var cellValue = cell.FormattedValue?.ToString() ?? string.Empty;

            if (cellValue.Length > 500 && cutLength)
            {
                cellValue = cellValue.Substring(0, 80) + " […] " + cellValue.Substring(cellValue.Length - 20, 20);
            }

            if (appendTab)
            {
                stringBuilder.Append('\t');
            }
            stringBuilder.Append(EscapeTab(cellValue));
            style.AddHtmlCell(
                sbHtml,
                cell.ValueType == typeof(string) ? m_HtmlStyle.TD : m_HtmlStyle.TDNonText,
                cellValue,
                cell.ErrorText,
                addErrorInfo);
        }
Пример #3
0
 /// <summary>
 ///   Appends a row error to the HTML Buffer
 /// </summary>
 /// <param name="stringBuilder">The buffer.</param>
 /// <param name="sbHtml">The StringBuilder for HTML.</param>
 /// <param name="errorText">The error Text</param>
 /// <param name="addErrorInfo">if set to <c>true</c> [add error info].</param>
 private void AppendRowError([NotNull] StringBuilder stringBuilder, [NotNull] StringBuilder sbHtml, [CanBeNull] string errorText, bool addErrorInfo, HTMLStyle style)
 {
     if (!addErrorInfo)
     {
         return;
     }
     if (string.IsNullOrEmpty(errorText))
     {
         sbHtml.Append(m_HtmlStyle.TDEmpty);
     }
     else
     {
         style.AddHtmlCell(sbHtml, m_HtmlStyle.TD, string.Empty, errorText, true);
     }
     stringBuilder.Append('\t');
     stringBuilder.Append(EscapeTab(errorText));
 }
Пример #4
0
 /// <summary>
 ///   Appends a row error to the HTML Buffer
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="sbHtml">The StringBuilder for HTML.</param>
 /// <param name="errorText">The error Text</param>
 /// <param name="addErrorInfo">if set to <c>true</c> [add error info].</param>
 private static void AppendRowError(StringBuilder buffer, StringBuilder sbHtml, string errorText, bool addErrorInfo)
 {
     Contract.Requires(buffer != null);
     Contract.Requires(sbHtml != null);
     if (!addErrorInfo)
     {
         return;
     }
     if (string.IsNullOrEmpty(errorText))
     {
         sbHtml.Append(m_HtmlStyle.TDEmpty);
     }
     else
     {
         HTMLStyle.AddHtmlCell(sbHtml, m_HtmlStyle.TD, string.Empty, errorText, true);
     }
     buffer.Append('\t');
     buffer.Append(EscapeTab(errorText));
 }