/// <summary>Returns the <see cref="P:System.Windows.Controls.DataGridRowClipboardEventArgs.ClipboardRowContent" /> values as a string in the specified format. </summary>
        /// <param name="format">The data format in which to serialize the cell values. </param>
        /// <returns>The formatted string.</returns>
        // Token: 0x06004986 RID: 18822 RVA: 0x0014CF90 File Offset: 0x0014B190
        public string FormatClipboardCellValues(string format)
        {
            StringBuilder stringBuilder = new StringBuilder();
            int           count         = this.ClipboardRowContent.Count;

            for (int i = 0; i < count; i++)
            {
                DataGridClipboardHelper.FormatCell(this.ClipboardRowContent[i].Content, i == 0, i == count - 1, stringBuilder, format);
            }
            return(stringBuilder.ToString());
        }
        /// <summary>
        /// This method serialize ClipboardRowContent list into string using the specified format.
        /// </summary>
        /// <param name="format"></param>
        /// <returns></returns>
        public string FormatClipboardCellValues(string format)
        {
            StringBuilder sb    = new StringBuilder();
            int           count = ClipboardRowContent.Count;

            for (int i = 0; i < count; i++)
            {
                DataGridClipboardHelper.FormatCell(ClipboardRowContent[i].Content, i == 0 /* firstCell */, i == count - 1 /* lastCell */, sb, format);
            }

            return(sb.ToString());
        }
예제 #3
0
        // Token: 0x06004795 RID: 18325 RVA: 0x00144FD0 File Offset: 0x001431D0
        internal static void FormatCell(object cellValue, bool firstCell, bool lastCell, StringBuilder sb, string format)
        {
            bool flag = string.Equals(format, DataFormats.CommaSeparatedValue, StringComparison.OrdinalIgnoreCase);

            if (!flag && !string.Equals(format, DataFormats.Text, StringComparison.OrdinalIgnoreCase) && !string.Equals(format, DataFormats.UnicodeText, StringComparison.OrdinalIgnoreCase))
            {
                if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase))
                {
                    if (firstCell)
                    {
                        sb.Append("<TR>");
                    }
                    sb.Append("<TD>");
                    if (cellValue != null)
                    {
                        DataGridClipboardHelper.FormatPlainTextAsHtml(cellValue.ToString(), new StringWriter(sb, CultureInfo.CurrentCulture));
                    }
                    else
                    {
                        sb.Append("&nbsp;");
                    }
                    sb.Append("</TD>");
                    if (lastCell)
                    {
                        sb.Append("</TR>");
                    }
                }
                return;
            }
            if (cellValue != null)
            {
                bool flag2  = false;
                int  length = sb.Length;
                DataGridClipboardHelper.FormatPlainText(cellValue.ToString(), flag, new StringWriter(sb, CultureInfo.CurrentCulture), ref flag2);
                if (flag2)
                {
                    sb.Insert(length, '"');
                }
            }
            if (lastCell)
            {
                sb.Append('\r');
                sb.Append('\n');
                return;
            }
            sb.Append(flag ? ',' : '\t');
        }