コード例 #1
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void OnEditAddress()
        {
            if (listBoxAddresses.SelectedIndices.Count > 0)
            {
                EmailForm form = new EmailForm();
                string    old  = listBoxAddresses.SelectedItems[0].ToString();
                form.SetAddress(old);
                DialogResult r = form.ShowDialog();
                if (r == DialogResult.OK)
                {
                    string newAddress = form.GetAddress();

                    if (!IsEmailAddress(newAddress) && (newAddress != old))
                    {
                        QMessageBox.ShowWarning("invalid email address!");
                    }
                    else if (listBoxAddresses.Items.Contains(newAddress))
                    {
                        QMessageBox.ShowWarning("email address existed!");
                    }
                    else if (newAddress == old)
                    {
                        //Do Nothing
                    }
                    else
                    {
                        listBoxAddresses.Items.RemoveAt(listBoxAddresses.SelectedIndices[0]);
                        listBoxAddresses.Items.Add(newAddress);
                    }
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void OnEditAccount()
        {
            if (listViewAccounts.SelectedItems.Count > 0)
            {
                ListViewItem item = listViewAccounts.SelectedItems[0];
                EmailAccount a    = (EmailAccount)item.Tag;

                AccountForm f = new AccountForm(a);

                while (f.ShowDialog() == DialogResult.OK)
                {
                    string username = f.GetUsername();

                    if (string.IsNullOrEmpty(username))
                    {
                        QMessageBox.ShowWarning("username can't be empty!");
                    }
                    else if (!IsEmailAddress(username))
                    {
                        QMessageBox.ShowWarning("email address is not valid!");
                    }
                    else if (string.IsNullOrEmpty(f.GetPassword()))
                    {
                        QMessageBox.ShowWarning("password can't be empty!");
                    }
                    else if (string.IsNullOrEmpty(f.GetNickname()))
                    {
                        QMessageBox.ShowWarning("nickname can't be empty!");
                    }
                    else if (string.IsNullOrEmpty(f.GetServer()))
                    {
                        QMessageBox.ShowWarning("server can't be empty!");
                    }
                    else
                    {
                        a.Username  = f.GetUsername();
                        a.Password  = f.GetPassword();
                        a.Nickname  = f.GetNickname();
                        a.Server    = f.GetServer();
                        a.Port      = f.GetPort();
                        a.EnableSsl = f.EnabledSsl();

                        ShowAccount(item);
                        listViewAccounts.Update();
                        BuildAccountsList();
                        break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult r = QMessageBox.ShowQuestion("Are you sure to exit?");

            if (r == DialogResult.No)
            {
                e.Cancel = true;
                return;
            }

            Settings.Default.Subject = textBoxSubject.Text;
            Settings.Default.Body    = richTextBoxBody.Text;
            Settings.Default.Save();

            DataCenter.Instance.SaveAccounts();
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void OnDone()
        {
            Text               = m_formText;
            buttonSend.Text    = m_buttonText;
            buttonQuit.Enabled = true;

            StringBuilder sum = new StringBuilder();

            sum.AppendFormat("send mail finished, total = {0}, done = {1}, fail = {2}\n", job.m_addresses.Length, job.m_done, job.m_fail);
            sum.AppendFormat("begin at {0}\n", job.m_begin.ToString("yyyy-MM-dd HH:mm:ss"));
            sum.AppendFormat("end   at {0}\n", job.m_end.ToString("yyyy-MM-dd HH:mm:ss"));

            if (job.m_done > 0)
            {
                TimeSpan span    = job.m_end.Subtract(job.m_begin);
                int      seconds = (int)(span.TotalSeconds + 0.5);
                sum.AppendFormat("average {0}/{1} = {2} seconds\n", seconds, job.m_done, seconds / job.m_done);
            }

            QMessageBox.ShowInfomation(sum.ToString());
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void addAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AccountForm f = new AccountForm();

            while (f.ShowDialog() == DialogResult.OK)
            {
                string username = f.GetUsername();

                if (string.IsNullOrEmpty(username))
                {
                    QMessageBox.ShowWarning("username can't be empty!");
                }
                else if (!IsEmailAddress(username))
                {
                    QMessageBox.ShowWarning("email address is not valid!");
                }
                else if (string.IsNullOrEmpty(f.GetPassword()))
                {
                    QMessageBox.ShowWarning("password can't be empty!");
                }
                else if (string.IsNullOrEmpty(f.GetNickname()))
                {
                    QMessageBox.ShowWarning("nickname can't be empty!");
                }
                else if (string.IsNullOrEmpty(f.GetServer()))
                {
                    QMessageBox.ShowWarning("server can't be empty!");
                }
                else
                {
                    EmailAccount a = f.GetAccount();
                    listViewAccounts.Items.Add(BuildListViewItem(a));
                    DataCenter.Instance.Add(a);
                    BuildAccountsList();
                    break;
                }
            }
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EmailForm    form = new EmailForm();
            DialogResult r    = form.ShowDialog();

            if (r == DialogResult.OK)
            {
                string address = form.GetAddress();

                if (!IsEmailAddress(address))
                {
                    QMessageBox.ShowWarning("invalid email address!");
                }
                else if (listBoxAddresses.Items.Contains(address))
                {
                    QMessageBox.ShowWarning("email address existed!");
                }
                else
                {
                    listBoxAddresses.Items.Add(form.GetAddress());
                }
            }
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: zzilla/phoebemail
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (m_timer.Enabled)//表示timer正在工作
            {
                m_timer.Stop();
                m_timer.Enabled = false;
                OnDone();
                return;
            }
            else if (backgroundWorkerMailSender.IsBusy)
            {
                backgroundWorkerMailSender.CancelAsync();
                OnDone();
                return;
            }

            if (comboBoxAccounts.Items.Count < 1)
            {
                QMessageBox.ShowWarning("account can not be empty!");
                return;
            }
            else if (comboBoxAccounts.SelectedIndex < 0)
            {
                QMessageBox.ShowWarning("you must select an account!");
                return;
            }
            else if (String.IsNullOrEmpty(textBoxSubject.Text))
            {
                QMessageBox.ShowWarning("email subject can not be empty!");
                return;
            }
            else if (String.IsNullOrEmpty(richTextBoxBody.Text))
            {
                QMessageBox.ShowWarning("email body can not be empty!");
                return;
            }
            else if (listBoxAddresses.Items.Count <= 0)
            {
                QMessageBox.ShowWarning("recipients can not be empty!");
                return;
            }
            else
            {
                if (checkBoxTimedSend.Checked)
                {
                    if (dateTimePickerTimedSend.Value <= DateTime.Now)
                    {
                        QMessageBox.ShowError("the time is in the past!");
                        return;
                    }
                    m_timer.Interval = dateTimePickerTimedSend.Value.Subtract(DateTime.Now).TotalSeconds * 1000;
                }
                else
                {
                    m_timer.Interval = 1;
                }
            }

            WrappedItem  item = (WrappedItem)comboBoxAccounts.SelectedItem;
            EmailAccount a    = item.Account;

            a.Init(textBoxSubject.Text, richTextBoxBody.Text);
            object[] addresses = new object[listBoxAddresses.Items.Count];
            listBoxAddresses.Items.CopyTo(addresses, 0);
            job = new MailJob(a, addresses);
            m_timer.Start();
            buttonSend.Text    = "Cancel";
            buttonQuit.Enabled = false;

            this.Text = String.Format("{0} - waiting to send...", m_formText);
        }