static private string ChatTemplateSelector(TableRow_Messages msg, ChatTypeEnum chatType, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor) { switch (chatType) { case ChatTypeEnum.normalChat: return(FormatNormalChat(msg, isChatHeader, isKeyFromMe, chatOwnerColor)); case ChatTypeEnum.normalChatReply: return(FormatNormalChatReply(msg, isChatHeader, isKeyFromMe, chatOwnerColor)); case ChatTypeEnum.image: return(FormatImage(msg, isChatHeader, isKeyFromMe, chatOwnerColor)); case ChatTypeEnum.imageReply: return(FormatImageReply(msg, isChatHeader, isKeyFromMe, chatOwnerColor)); case ChatTypeEnum.video: return(FormatVideo(msg, isChatHeader, isKeyFromMe, chatOwnerColor)); case ChatTypeEnum.videoReply: return(@"<li>video reply | temporarily do nothing</li>"); case ChatTypeEnum.audio: return(@"<li>audio | temporarily do nothing</li>"); case ChatTypeEnum.audioReply: return(@"<li>audio reply | temporarily do nothing</li>"); default: return(@"<li style='color:red'> CHAT TYPE NOT CAUGHT!</li>"); //throw new InvalidOperationException("ChatTemplate must have a valid value as listed in ChatTypeEnum"); //to be logged } }
static private string FormatImageReply(TableRow_Messages msg, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor) { string liClass; string divClass1; string divClass2; string chatOwner; string chatNameColor; string replyNameColor; chatOwnerColor.OwnerColorListing.TryGetValue(msg.remote_resource, out chatNameColor); chatOwnerColor.OwnerColorListing.TryGetValue(msg.Table_Messsages_Quotes.remote_resource, out replyNameColor); //msg reply will always be in header mode, dont need to check for isChatHeader if (isKeyFromMe) { liClass = "self-header"; divClass1 = "msg-bubble msg-self"; divClass2 = "msg-reply-image-bubble-self quoted"; } else { liClass = "others-header"; divClass1 = "msg-bubble msg-others"; divClass2 = "msg-reply-image-bubble-others quoted"; } if (!isKeyFromMe) { chatOwner = $@"<strong class='author{chatNameColor}'>{msg.remote_resource}</strong><br/>"; } else { chatOwner = ""; } var htmlTemplate = $@"<li class='{liClass}'> <div class='{divClass1}'> {chatOwner} <div class='{divClass2}{replyNameColor}'> <div> <strong class='author{replyNameColor}'>{msg.Table_Messsages_Quotes.remote_resource}</strong><br/> {msg.Table_Messsages_Quotes.media_caption} </div> <div class='image-reply-container'> <img src='../Content/IMG/image1.jpg' class='image-reply' /> </div> </div> {msg.Data} <time><br/>{FormatTimeStamp(msg.timestamp)}</time> </div> </li>"; return(htmlTemplate); }
static private string FormatImage(TableRow_Messages msg, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor) { string liClass; string divClass; string chatOwner; string chatNameColor; chatOwnerColor.OwnerColorListing.TryGetValue(msg.remote_resource, out chatNameColor); if (isChatHeader && isKeyFromMe) { liClass = "self-header"; divClass = "img-container msg-self"; } else if (isChatHeader && !isKeyFromMe) { liClass = "others-header"; divClass = "img-container msg-others"; } else if (!isChatHeader && isKeyFromMe) { liClass = "self"; divClass = "img-container msg-self"; } else { liClass = "others"; divClass = "img-container msg-others"; } if (isChatHeader && !isKeyFromMe) { chatOwner = $@"<strong class='author{chatNameColor}'>{msg.remote_resource}</strong><br/>"; } else { chatOwner = ""; } var htmlTemplate = $@"<li class='{liClass}'> <div class='{divClass}'> {chatOwner} <img src='../Content/IMG/image1.jpg' /> {msg.media_caption} <time><br/>{FormatTimeStamp(msg.timestamp)}</time> </div> </li>"; return(htmlTemplate); }
static private string FormatNormalChat(TableRow_Messages msg, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor) { string liClass; string divClass; string chatOwner; string chatNameColor; chatOwnerColor.OwnerColorListing.TryGetValue(msg.remote_resource, out chatNameColor); if (isChatHeader && isKeyFromMe) { liClass = "self-header"; divClass = "msg-bubble msg-self"; } else if (isChatHeader && !isKeyFromMe) { liClass = "others-header"; divClass = "msg-bubble msg-others"; } else if (!isChatHeader && isKeyFromMe) { liClass = "self"; divClass = "msg-bubble msg-self"; } else { liClass = "others"; divClass = "msg-bubble msg-others"; } if (isChatHeader && !isKeyFromMe) { chatOwner = $@"<strong class='author{chatNameColor}'>{msg.remote_resource}</strong><br/>"; } else { chatOwner = ""; } var htmlTemplate = $@"<li class='{liClass}'> <div class='{divClass}'> {chatOwner} {msg.Data} <time><br/>{FormatTimeStamp(msg.timestamp)}</time> </div> </li>"; return(htmlTemplate); }
static private string FormatVideo(TableRow_Messages msg, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor) { string liClass; string divClass; string chatOwner; string chatNameColor; chatOwnerColor.OwnerColorListing.TryGetValue(msg.remote_resource, out chatNameColor); //video chat is always in header mode if (isKeyFromMe) { liClass = "self-header"; divClass = "video-container msg-self"; } else { liClass = "others-header"; divClass = "video-container msg-others"; } if (!isKeyFromMe) { chatOwner = $@"<strong class='author{chatNameColor}'>{msg.remote_resource}</strong><br/>"; } else { chatOwner = ""; } var htmlTemplate = $@"<li class='{liClass}'> <div class='{divClass}'> {chatOwner} <video controls><source src='../Content/Videos/video1.mp4' type='video/mp4' />Video format not supported</video> {msg.media_caption} <time><br/>{FormatTimeStamp(msg.timestamp)}</time> </div> </li>"; return(htmlTemplate); }