// ----------------------------------------------------------------------------------------- private void ClientShowMessage(string message, MessageModifier modifier) { rTextBoxClientMessage.Select(rTextBoxClientMessage.Text.Length, 0); switch (modifier) { case MessageModifier.INCOMING: rTextBoxClientMessage.SelectionBackColor = Color.White; rTextBoxClientMessage.SelectionColor = Color.Black; rTextBoxClientMessage.SelectionAlignment = HorizontalAlignment.Left; break; case MessageModifier.INFORMATION: rTextBoxClientMessage.SelectionBackColor = Color.LawnGreen; rTextBoxClientMessage.SelectionColor = Color.Black; rTextBoxClientMessage.SelectionAlignment = HorizontalAlignment.Left; break; case MessageModifier.OUTGOING: rTextBoxClientMessage.SelectionBackColor = Color.DodgerBlue; rTextBoxClientMessage.SelectionColor = Color.White; rTextBoxClientMessage.SelectionAlignment = HorizontalAlignment.Right; break; case MessageModifier.SERVER: rTextBoxClientMessage.SelectionBackColor = Color.Pink; rTextBoxClientMessage.SelectionColor = Color.Red; rTextBoxClientMessage.SelectionAlignment = HorizontalAlignment.Left; break; } rTextBoxClientMessage.AppendText(message + Environment.NewLine); rTextBoxClientMessage.SelectionBackColor = SystemColors.Control; rTextBoxClientMessage.SelectionColor = Color.Black; }
private Message() { Receivers = new string[] { "Null" }; Sender = string.Empty; Body = string.Empty; Subject = string.Empty; MessageModifier = MessageModifier.IsHtml; }
KeyValuePair <bool, CharacterResponse> GeneralCompare(Comment comment) { //Remove any ! and . string compareComment = GeneralString(comment.Body); if (string.IsNullOrEmpty(compareComment)) { return(new KeyValuePair <bool, CharacterResponse>(false, null)); } List <CharacterResponse> matchingResponses = new List <CharacterResponse>(); foreach (CharacterResponse response in ResponsesDatabase.Responses) { string compareResponse = GeneralString(response.Response); //If last char is punctuation in user comment, remove it and see if match if (MessageModifier.IsLastCharPunctuation(compareComment)) { string corrected = compareComment.Remove(compareComment.Length - 1); if (corrected == compareResponse) { if (ValidateIfDuplicateOrExcluded(comment, compareComment, response)) { matchingResponses.Add(response); } } } //Check if comment has response. Reply if comment is solely for response else if (compareComment == compareResponse) { if (ValidateIfDuplicateOrExcluded(comment, compareComment, response)) { matchingResponses.Add(response); } } } //Determine which is best to use from many matched if (matchingResponses.Count > 0) { return(new KeyValuePair <bool, CharacterResponse>(true, matchingResponses.First())); } return(new KeyValuePair <bool, CharacterResponse>(false, null)); }
/// <summary> /// Tries to remove as many unwanted characters as possible for a good compaison. Allows for markdown, char faces, emojis, punctuation /// </summary> /// <param name="comment"></param> /// <returns></returns> string GeneralString(string comment) { string originalString = comment; //Allow comparison with certain markdown formatting comment = MessageModifier.RemoveMarkdownCharacters(comment); if (string.IsNullOrEmpty(comment)) { return(comment); } string[] specificChars = new string[] { ";)", ";(", ";)", ":(", ":D", ";D" }; for (int i = 0; i < specificChars.Length; i++) { comment = comment.Replace(specificChars[i], ""); } //Allow comparison with other symbols comment = comment.Replace("!", ""); comment = comment.Replace("?", ""); comment = comment.Replace("'", ""); comment = comment.Replace("?", ""); comment = comment.Replace("\"", ""); comment = comment.Replace(",", ""); comment = MessageModifier.RemoveUnicodeCharacters(comment); if (string.IsNullOrEmpty(comment)) { return(comment); } //Remove white space last comment = MessageModifier.RemoveWhiteSpaceAtStartAndEnd(comment); if (string.IsNullOrEmpty(comment)) { return(comment); } return(comment.ToLower()); }
/// <summary> /// Method for an accurate comparison. Ie: The comment was wrote with the intention of a reply /// </summary> /// <param name="comment"></param> /// <returns></returns> string AccurateString(string comment) { comment = MessageModifier.RemoveWhiteSpaceAtStartAndEnd(comment); return(comment.ToLower()); }
public Message(MessageCarrier type, MessageModifier modifier) : this() { MessageType = type; MessageModifier = modifier; }
//Nice constructor scaffolding public Message(string[] to, string from, string body, string subject, MessageCarrier type, MessageModifier modifier) : this(type, modifier) { Receivers = to; Sender = from; Body = body; Subject = subject; }
// ########################################################################################## /// <summary> Funkcja aktualizująca podgląd wiadomości w interfejsie aplikacji. </summary> /// <param name="message"> Wiadomość która ma zostać wyświetlona. </param> private void UpdateUI(string message, MessageModifier modifier) { CliOutput.Invoke(new InvokeInterface(() => { FuncShowMessage(message, modifier); })); }