private string OnFormatting(string message) { FormattingHandler Formatting = new FormattingHandler(NoFormatting); switch ((FormattingOptions)formattingOptionsComboBox.SelectedIndex) { case FormattingOptions.None: Formatting = new FormattingHandler(NoFormatting); break; case FormattingOptions.StartWithDateTime: Formatting = new FormattingHandler(StartWithDateTimeFormat); break; case FormattingOptions.EndWithDateTime: Formatting = new FormattingHandler(EndWithDateTimeFormat); break; case FormattingOptions.LowerCase: Formatting = new FormattingHandler(LowerCaseFormat); break; case FormattingOptions.UpperCase: Formatting = new FormattingHandler(UpperCaseFormat); break; case FormattingOptions.EndWithMessageLength: Formatting = new FormattingHandler(EndWithMessageLengthFormat); break; } return(Formatting(message)); }
private void OnSMSRecieved(string message) { if (messagesRichTextBox.InvokeRequired) { var SMSReceivedEventHandler = new SMSReceivedHandler(OnSMSRecieved); this.BeginInvoke(SMSReceivedEventHandler, message); } else { var FormattingEventHandler = new FormattingHandler(OnFormatting); string formattedMessage = FormattingEventHandler?.Invoke(message); this.messagesRichTextBox.AppendText($"{formattedMessage}{Environment.NewLine}"); } }
private void OnMessageIsAdded(Message message) { if (messagesListView.InvokeRequired) { var AddingMessageEventHandler = new AddingMessageEventHandler(OnMessageIsAdded); this.BeginInvoke(AddingMessageEventHandler, message); } else { var FormattingEventHandler = new FormattingHandler(OnFormatting); message.Text = FormattingEventHandler?.Invoke(message); messages.Add(message); } }
private List <Message> FormatFilteredMessages() { var FormattingEventHandler = new FormattingHandler(OnFormatting); List <Message> formattedMessages = new List <Message>(); for (int i = 0; i < filteredMessageIds.Count; i++) { Message messageToFormat = messages.Single(m => m.MessageId == filteredMessageIds[i]); formattedMessages.Add(new Course.Message(messageToFormat.MessageId, messageToFormat.PhoneNumber, messageToFormat.Text, messageToFormat.RecievingTime)); formattedMessages[i].Text = FormattingEventHandler?.Invoke(formattedMessages[i]); } return(formattedMessages); }
private void OnMessageIsAdded(Message message) { if (messagesListView.InvokeRequired) { var AddingMessageEventHandler = new AddingMessageEventHandler(OnMessageIsAdded); this.BeginInvoke(AddingMessageEventHandler, message); } else { var FormattingEventHandler = new FormattingHandler(OnFormatting); message.Text = FormattingEventHandler?.Invoke(message); messages.Add(message); filteredMessageIds.Add(message.MessageId); PutUniqueSendersToComboBox(message.PhoneNumber); Action <Message> AddNewMessageToView = m => messagesListView.Items.Add(new ListViewItem(new[] { m.PhoneNumber, m.Text })); messagesListView.Invoke(AddNewMessageToView, message); } }
private string InvokeFromatting(FormattingHandler formattingHandler, Message message) { return(formattingHandler?.Invoke(message)); }