示例#1
0
        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));
        }
示例#2
0
        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}");
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
 private string InvokeFromatting(FormattingHandler formattingHandler, Message message)
 {
     return(formattingHandler?.Invoke(message));
 }