示例#1
0
        private void AddEmailButton_Click(object sender, RoutedEventArgs e)
        {
            EmailOptionsWindow emailOptionsWindow = new EmailOptionsWindow()
            {
                Owner = this
            };

            emailOptionsWindow.ShowDialog();

            if (emailOptionsWindow.EmailBox != null)
            {
                if (!this.User.EmailBoxes.Contains(emailOptionsWindow.EmailBox))
                {
                    this.User.EmailBoxes.Add(emailOptionsWindow.EmailBox);
                    this.User.SelectedEmailBoxIndex = this.User.EmailBoxes.Count > 0 ?
                                                      this.User.SelectedEmailBoxIndex : -1;
                    this.emailAccountsListBox.Items.Add(emailOptionsWindow.EmailBox.EmailAddress);
                }
                else
                {
                    MessageBox.Show("Почтовый ящик с таким адресом уже существует.", "Ошибка",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
示例#2
0
 private void ChangeEmailButton_Click(object sender, RoutedEventArgs e)
 {
     if (this.emailAccountsListBox.SelectedIndex != -1)
     {
         EmailOptionsWindow emailOptionsWindow = new EmailOptionsWindow(
             this.User.EmailBoxes[this.emailAccountsListBox.SelectedIndex])
         {
             Owner = this
         };
         emailOptionsWindow.ShowDialog();
         this.User.EmailBoxes[this.emailAccountsListBox.SelectedIndex]            = emailOptionsWindow.EmailBox;
         this.emailAccountsListBox.Items[this.emailAccountsListBox.SelectedIndex] =
             emailOptionsWindow.EmailBox.EmailAddress;
         //((MainWindow)this.Owner).emailAccountsComboBox.Items[emailAccountsListBox.SelectedIndex] =
         //    emailOptionsWindow.EmailBox.EmailAddress;
     }
     else
     {
         MessageBox.Show("Для изменения требуется выбрать почтовый ящик.", "Ошибка",
                         MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }