Exemple #1
0
        /// <summary>
        /// Deletes the selected message.
        /// </summary>
        private void DeleteSelectedMessage()
        {
            // Lock to prevent rapid clicking issues
            lock (this.deleteLockObject)
            {
                Array messages = new MessageEntry[this.messagesList.SelectedItems.Count];
                this.messagesList.SelectedItems.CopyTo(messages, 0);

                // Capture index position first
                int index = this.messagesList.SelectedIndex;

                foreach (MessageEntry entry in messages)
                {
                    // Delete the file and remove the entry
                    if (File.Exists(entry.File))
                    {
                        File.Delete(entry.File);
                    }

                    this.messagesList.Items.Remove(entry);
                }

                this.UpdateSelectedMessage(index);
            }
        }
Exemple #2
0
        /// <summary>
        ///     Add a newly received message and show the balloon notification
        /// </summary>
        /// <param name="entry">
        ///     The entry.
        /// </param>
        private void AddNewMessage(MessageEntry entry)
        {
            // Add it to the list box
            this.messagesList.Items.Add(entry);

            // Show the notification
            this.notification.ShowBalloonTip(5000, string.Empty, "New message received!", ToolTipIcon.Info);
        }
        /// <summary>
        /// The delete button_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender. 
        /// </param>
        /// <param name="e">
        /// The e. 
        /// </param>
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            // Lock to prevent rapid clicking issues
            lock (this.deleteLockObject)
            {
                Array messages = new MessageEntry[this.messagesList.SelectedItems.Count];
                this.messagesList.SelectedItems.CopyTo(messages, 0);

                // Capture index position first
                int index = this.messagesList.SelectedIndex;

                foreach (MessageEntry entry in messages)
                {
                    // Delete the file and remove the entry
                    if (File.Exists(entry.File))
                    {
                        File.Delete(entry.File);
                    }

                    this.messagesList.Items.Remove(entry);
                }

                // If there are more than the index location, keep the same position in the list
                if (this.messagesList.Items.Count > index)
                {
                    this.messagesList.SelectedIndex = index;
                }
                else if (this.messagesList.Items.Count > 0)
                {
                    // If there are fewer, move to the last one
                    this.messagesList.SelectedIndex = this.messagesList.Items.Count - 1;
                }
                else if (this.messagesList.Items.Count == 0)
                {
                    this.tabControl.IsEnabled = false;
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageEventArgs"/> class.
 /// </summary>
 /// <param name="entry">
 /// The entry. 
 /// </param>
 public MessageEventArgs(MessageEntry entry)
 {
     this.Entry = entry;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageEventArgs"/> class.
 /// </summary>
 /// <param name="entry">
 /// The entry.
 /// </param>
 public MessageEventArgs(MessageEntry entry)
 {
     this.Entry = entry;
 }