示例#1
0
        public async Task <YHtmlString> RenderAsync(MessagesEditComponent.MessageData model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            string     notSeen    = YetaWFManager.HtmlAttributeEncode(this.__ResStr("seen", "This message has not been seen"));
            SkinImages skinImages = new SkinImages();
            string     notSeenUrl = YetaWFManager.HtmlAttributeEncode(await skinImages.FindIcon_PackageAsync("NotSeen.png", Package));


            hb.Append($@"
<div class='yt_messenger_messages t_display' id='{DivId}' style='display:none'>
    <div class='t_messagearea'>");

            foreach (Message msg in model.Messages)
            {
                if (msg.FromUser == Manager.UserId)
                {
                    hb.Append($@"
        <div class='t_thisuser  t_notseen' data-key='{msg.Key}'>
            <div class='t_sent'>
                <img alt='{notSeen}' title='{notSeen}' src='{notSeenUrl}'>
                {YetaWFManager.HtmlEncode(Formatting.FormatDateTime(msg.Sent))}
            </div>
            <div class='t_text'>{YetaWFManager.HtmlEncode(msg.MessageText)}</div>
        </div>");
                }
                else
                {
                    hb.Append($@"
        <div class='t_otheruser {(msg.Seen ? "t_seen" : "t_notseen")}' data-key='{msg.Key}'>
            <div class='t_sent'>{YetaWFManager.HtmlEncode(Formatting.FormatDateTime(msg.Sent))}</div>
            <div class='t_text'>{YetaWFManager.HtmlEncode(msg.MessageText)}</div>
        </div>");
                }
            }
            hb.Append($@"
        <div class='t_last' style='clear:both'></div>
    </div>
</div>
<div class='yt_messenger_messages t_display' id='{DivId}_none' style='display:none'>
    {YetaWFManager.HtmlEncode(this.__ResStr("none", "(None)"))}
</div>
<script>
    var out = document.getElementById('{DivId}');
    out.style.display = '{(model.Messages.Count == 0 ? "none": "")}';
    out.scrollTop = out.scrollHeight - out.clientHeight;
    out = document.getElementById('{DivId}_none');
    out.style.display = '{(model.Messages.Count == 0 ? "": "none")}';
    new YetaWF_Messenger.MessagesTemplate('{DivId}', '{YetaWFManager.JserEncode(model.FromUser)}', '{YetaWFManager.JserEncode(model.ToUser)}');
</script>
");
            return(hb.ToYHtmlString());
        }