Exemple #1
0
        /// <summary>
        /// This click event method deals with how the message is saved
        /// </summary>
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            // Sets the path as a string
            string path = @".\EustonLeisureMessages.json";

            // If the message is a Tweet, then the method SearchForHashTagsAndMentions() is called
            if (validation.Header.StartsWith("T"))
            {
                processing.SearchForHashTagsAndMentions(processedText);
            }

            // If the message is an Email, then the method SearchForSIR() is called
            if (validation.Header.StartsWith("E") && validation.Subject.StartsWith("SIR"))
            {
                processing.SearchForSIR(processedText);
            }

            // Adds the message to a list
            validation.AddMessageToList(processedText);

            // Converts the whole list of messages into JSON and stores it
            json.Serialize(validation.listOfMessages, path);

            // Sets the save button to IsEnabled = false
            saveButton.IsEnabled = false;

            validation.EndOfCycle();

            // Clears the textboxes
            convertedMessageHeaderTxt.Text  = string.Empty;
            convertedMessageSenderTxt.Text  = string.Empty;
            convertedMessageSubjectTxt.Text = string.Empty;
            convertedMessageBodyTxt.Text    = string.Empty;
            messageHeaderTxt.Text           = string.Empty;
            messageBodyTxt.Text             = string.Empty;
        }