// BUTTON - opens display tweet window
        private void btnTweet_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            DisplayTweet displayTweet = new DisplayTweet();

            displayTweet.ShowDialog();
            this.Close();
        }
Пример #2
0
        // SUBMIT BUTTON - reads the file from the file path and processes the message stored inside
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            ReadFile file = new ReadFile(filePath);
            Message  msg  = new Message();

            // Try-Catch loop - catches argument error and displays it
            try
            {
                // Checks that a file can be read
                if (file != null)
                {
                    // Message id and body is set
                    msg.messageID   = file.id.ToUpper();
                    msg.messageBody = file.body;

                    // Determines whether a message is a SMS, Email or Tweet, creates a new instane, displays it to screen
                    // If a message id start with 'S' == SMS, 'E' == Email, 'T' == Tweet
                    if (msg.messageID.StartsWith("S"))
                    {
                        SMS sms = msg.newSMS();

                        this.Hide();
                        DisplaySMS displayEmail = new DisplaySMS(sms);
                        displayEmail.ShowDialog();
                        this.Close();
                    }
                    else if (msg.messageID.StartsWith("E"))
                    {
                        Email email = msg.newEmail();

                        this.Hide();
                        DisplayEmail displayEmail = new DisplayEmail(email);
                        displayEmail.ShowDialog();
                        this.Close();
                    }
                    else if (msg.messageID.StartsWith("T"))
                    {
                        Tweet tweet = msg.newTweet();

                        this.Hide();
                        DisplayTweet displayTweet = new DisplayTweet(tweet);
                        displayTweet.ShowDialog();
                        this.Close();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        // SUBMIT BUTTON - process message entered in fields and display it to the screen
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            Message msg = new Message();

            // Try-Catch loop that detects argument exception
            try
            {
                // checks if the header and body are not empty
                if (txtID.Text != "" || txtBody.Text != "")
                {
                    msg.messageID   = txtID.Text;
                    msg.messageBody = txtBody.Text;

                    // Checks the id to identify the type of message that is generated
                    if (msg.messageID.StartsWith("S"))
                    {
                        SMS sms = msg.newSMS();

                        this.Hide();
                        displaySMS = new DisplaySMS(sms);
                        displaySMS.ShowDialog();
                        this.Close();
                    }
                    else if (msg.messageID.StartsWith("E"))
                    {
                        Email email = msg.newEmail();

                        this.Hide();
                        displayEmail = new DisplayEmail(email);
                        displayEmail.ShowDialog();
                        this.Close();
                    }
                    else if (msg.messageID.StartsWith("T"))
                    {
                        Tweet tweet = msg.newTweet();

                        this.Hide();
                        displayTweet = new DisplayTweet(tweet);
                        displayTweet.ShowDialog();
                        this.Close();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }