//***********************
        //*                     *
        //*  MessageCopy_Click  *
        //*                     *
        //***********************
        // Copy selected queue message.

        private void MessageCopy_Click(object sender, RoutedEventArgs e)
        {
            NewAction();

            // Validate a single message has been selected.

            if (MessageListView.SelectedItems.Count != 1)
            {
                MessageBox.Show("In order to copy a message, please select one message then click the Copy toolbar button", "Single Selection Requireed");
                return;
            }

            MessageItem selectedMessage = MessageListView.SelectedItems[0] as MessageItem;
            if (selectedMessage == null) return;

            // Display the copy message dialog.

            NewMessageDialog dlg = new NewMessageDialog();
            dlg.Title = "Copy Queue Message";
            dlg.MessageText.Text = selectedMessage.StringValue;

            if (dlg.ShowDialog().Value)
            {
                String messageText = dlg.MessageText.Text;

                try
                {
                    Cursor = Cursors.Wait;

                    if (queueClient == null)
                    {
                        CloudStorageAccount account = OpenStorageAccount();
                        queueClient = account.CreateCloudQueueClient();
                    }

                    CloudQueue container = queueClient.GetQueueReference(SelectedQueueContainer);

                    // Create queue message.

                    CloudQueueMessage message = new CloudQueueMessage(messageText);
                    container.AddMessage(message);

                    ShowQueueContainer(SelectedQueueContainer);

                }
                catch (Exception ex)
                {
                    ShowError("Error creating message for queue " + SelectedQueueContainer + ": " + ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Arrow;
                }
            }

        }
        //**********************
        //*                    *
        //*  MessageNew_Click  *
        //*                    *
        //**********************
        // Create a new queue message.

        private void MessageNew_Click(object sender, RoutedEventArgs e)
        {
            NewAction();

            NewMessageDialog dlg = new NewMessageDialog();
            if (dlg.ShowDialog().Value)
            {
                String messageText = dlg.MessageText.Text;

                try
                {
                    Cursor = Cursors.Wait;

                    if (queueClient == null)
                    {
                        CloudStorageAccount account = OpenStorageAccount();
                        queueClient = account.CreateCloudQueueClient();
                    }

                    CloudQueue container = queueClient.GetQueueReference(SelectedQueueContainer);

                    // Create queue message.

                    CloudQueueMessage message = new CloudQueueMessage(messageText);
                    container.AddMessage(message);

                    ShowQueueContainer(SelectedQueueContainer);

                }
                catch (Exception ex)
                {
                    ShowError("Error creating message for queue " + SelectedQueueContainer + ": " + ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Arrow;
                }
            }
        }