Esempio n. 1
0
        private void FinalParsing(CommandResult commandResult)
        {
            foreach (var displayItem in commandResult.Display)
            {
                if (_currentUser != null && !_currentUser.Sound)
                {
                    displayItem.DisplayMode |= DisplayMode.Mute;
                }

                if ((displayItem.DisplayMode & DisplayMode.DontWrap) == 0)
                {
                    displayItem.Text = displayItem.Text.WrapOnSpace(AppSettings.MaxLineLength);
                }

                if (ParseAsHtml)
                {
                    displayItem.Text = HttpUtility.HtmlEncode(displayItem.Text);
                    if ((displayItem.DisplayMode & DisplayMode.Parse) != 0)
                    {
                        displayItem.Text = BBCodeUtility.ConvertTagsToHtml(displayItem.Text);
                    }
                    displayItem.Text = displayItem.Text
                                       .Replace("\n", "<br />")
                                       .Replace("\r", "")
                                       .Replace("  ", " &nbsp;");

                    string cssClass = null;
                    if ((displayItem.DisplayMode & DisplayMode.Inverted) != 0)
                    {
                        cssClass        += "inverted ";
                        displayItem.Text = string.Format("&nbsp;{0}&nbsp;", displayItem.Text);
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Dim) != 0)
                    {
                        cssClass += "dim ";
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Italics) != 0)
                    {
                        cssClass += "italics ";
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Bold) != 0)
                    {
                        cssClass += "bold ";
                    }
                    displayItem.Text = string.Format("<span class='{0}'>{1}</span>", cssClass, displayItem.Text);
                }
            }
        }
Esempio n. 2
0
        private void FinalParsing(CommandResult commandResult)
        {
            foreach (var displayItem in commandResult.DisplayItems)
            {
                if (_currentUser != null && !_currentUser.Sound)
                {
                    displayItem.DisplayMode |= DisplayMode.Mute;
                }

                if (ParseAsHtml)
                {
                    if ((displayItem.DisplayMode & DisplayMode.Parse) != 0)
                    {
                        displayItem.Text = BBCodeUtility.ConvertTagsToHtml(displayItem.Text);
                    }
                    else
                    {
                        displayItem.Text = HttpUtility.HtmlEncode(displayItem.Text);
                    }

                    var masterParser = new BBCodeParser(new[]
                    {
                        new BBTag("transmit", "<span class='transmit' transmit='${transmit}'>", "</span>", new BBAttribute("transmit", "")),
                        new BBTag("topicboardid", "<span id='topicboardid'>", "</span>"),
                        new BBTag("topicstatus", "<span id='topicstatus'>", "</span>"),
                        new BBTag("topictitle", "<span id='topictitle'>", "</span>"),
                        new BBTag("topicreplycount", "<span id='topicreplycount'>", "</span>"),
                        new BBTag("topicbody", "<div id='topicbody'>", "</div>"),
                        new BBTag("topicmaxpages", "<span id='topicmaxpages'>", "</span>"),
                        new BBTag("topiceditedby", "<span id='topiceditedby'>", "</span>"),
                        new BBTag("replyeditedby", "<span id='replyeditedby'>", "</span>")
                    });

                    displayItem.Text = masterParser.ToHtml(displayItem.Text, false);

                    displayItem.Text = displayItem.Text
                                       .Replace("\n", "<br />")
                                       .Replace("\r", "")
                                       .Replace("  ", " &nbsp;");

                    string cssClass = null;
                    if ((displayItem.DisplayMode & DisplayMode.Inverted) != 0)
                    {
                        cssClass        += "inverted ";
                        displayItem.Text = string.Format("&nbsp;{0}&nbsp;", displayItem.Text);
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Dim) != 0)
                    {
                        cssClass += "dim ";
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Italics) != 0)
                    {
                        cssClass += "italics ";
                    }
                    if ((displayItem.DisplayMode & DisplayMode.Bold) != 0)
                    {
                        cssClass += "bold ";
                    }
                    displayItem.Text = string.Format("<span class='{0}'>{1}</span>", cssClass, displayItem.Text);
                }
                else
                {
                    var masterParser = new BBCodeParser(new[]
                    {
                        new BBTag("transmit", "", ""),
                        new BBTag("topicboardid", "", ""),
                        new BBTag("topicstatus", "", ""),
                        new BBTag("topictitle", "", ""),
                        new BBTag("topicreplycount", "", ""),
                        new BBTag("topicbody", "", ""),
                        new BBTag("topicmaxpages", "", ""),
                        new BBTag("topiceditedby", "", ""),
                        new BBTag("replyeditedby", "", "")
                    });

                    displayItem.Text = masterParser.ToHtml(displayItem.Text, false);

                    if ((displayItem.DisplayMode & DisplayMode.DontWrap) == 0)
                    {
                        displayItem.Text = displayItem.Text.WrapOnSpace(AppSettings.MaxLineLength);
                    }
                }
            }
        }