Пример #1
0
        private void _bAdd_Click(object sender, System.EventArgs e)
        {
            SmtpServerForm smtpServerForm = new SmtpServerForm();
            DialogResult   res            = smtpServerForm.ShowDialog();

            if (res == DialogResult.OK)
            {
                AddElement(smtpServerForm);
            }
        }
Пример #2
0
        private void _lvItem_DoubleClick(object sender, System.EventArgs e)
        {
            if (_lvItem.SelectedItems.Count > 0)
            {
                int index = IndexElement(_lvItem.SelectedItems[0].Text, Int32.Parse(_lvItem.SelectedItems[0].SubItems[1].Text));

                if (index != -1)
                {
                    SmtpServer oldSmtpServer = (SmtpServer)_listServers[index];

                    SmtpServerForm smtpServerForm = new SmtpServerForm(oldSmtpServer);
                    DialogResult   res            = smtpServerForm.ShowDialog();

                    if (res == DialogResult.OK)
                    {
                        bool exist = false;

                        for (int i = 0; i < _listServers.Count; i++)
                        {
                            if (i != index)
                            {
                                if (((SmtpServer)_listServers[i]).Host.ToUpper() == smtpServerForm.Host.ToUpper() &&
                                    ((SmtpServer)_listServers[i]).Port.ToString() == smtpServerForm.Port.ToString())
                                {
                                    exist = true;
                                    break;
                                }
                            }
                        }

                        if (exist == true)
                        {
                            MessageBox.Show(string.Format("Unable to modify '{0}:{1}' to '{2}:{3}' because already exist", oldSmtpServer.Host, oldSmtpServer.Port, smtpServerForm.Host, smtpServerForm.Port), "ActiveQConfiguration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else
                        {
                            ((SmtpServer)_listServers[index]).Host     = smtpServerForm.Host;
                            ((SmtpServer)_listServers[index]).Port     = smtpServerForm.Port;
                            ((SmtpServer)_listServers[index]).Username = smtpServerForm.Username;
                            ((SmtpServer)_listServers[index]).Password = smtpServerForm.Password;

                            _lvItem.SelectedItems[0].Text             = smtpServerForm.Host;
                            _lvItem.SelectedItems[0].SubItems[1].Text = smtpServerForm.Port.ToString();
                        }
                    }
                }
            }
        }
Пример #3
0
        private void AddElement(SmtpServerForm smtpServerForm)
        {
            if (ExistItem(smtpServerForm.Host, smtpServerForm.Port) == true)
            {
                MessageBox.Show(string.Format("Unable to add '{0}:{1}' because already exist", smtpServerForm.Host, smtpServerForm.Port), "ActiveQConfiguration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                _listServers.Add(new SmtpServer(smtpServerForm.Host, smtpServerForm.Port, smtpServerForm.Username, smtpServerForm.Password));

                ListViewItem lvi = _lvItem.Items.Add(smtpServerForm.Host);
                lvi.ImageIndex = 0;
                lvi.SubItems.Add(smtpServerForm.Port.ToString());
            }

            EnableDisableArrow();
        }
Пример #4
0
		private void _lvItem_DoubleClick(object sender, System.EventArgs e)
		{
			if (_lvItem.SelectedItems.Count > 0)
			{
				int index = IndexElement(_lvItem.SelectedItems[0].Text,Int32.Parse(_lvItem.SelectedItems[0].SubItems[1].Text));

				if (index != -1)
				{
					SmtpServer oldSmtpServer = (SmtpServer)_listServers[index];

					SmtpServerForm smtpServerForm = new SmtpServerForm(oldSmtpServer);
					DialogResult res = smtpServerForm.ShowDialog();

					if (res == DialogResult.OK)
					{
						bool exist = false;

						for(int i = 0 ; i < _listServers.Count ; i++)
						{
							if (i != index)
							{
								if (((SmtpServer)_listServers[i]).Host.ToUpper() == smtpServerForm.Host.ToUpper() &&
									((SmtpServer)_listServers[i]).Port.ToString() == smtpServerForm.Port.ToString())
								{
									exist = true;
									break;
								}
							}
						}

						if (exist == true)
						{
							MessageBox.Show(string.Format("Unable to modify '{0}:{1}' to '{2}:{3}' because already exist",oldSmtpServer.Host,oldSmtpServer.Port,smtpServerForm.Host,smtpServerForm.Port),"ActiveQConfiguration",MessageBoxButtons.OK,MessageBoxIcon.Error);
						}

						else
						{
							((SmtpServer)_listServers[index]).Host = smtpServerForm.Host;
							((SmtpServer)_listServers[index]).Port = smtpServerForm.Port;
							((SmtpServer)_listServers[index]).Username = smtpServerForm.Username;
							((SmtpServer)_listServers[index]).Password = smtpServerForm.Password;

							_lvItem.SelectedItems[0].Text = smtpServerForm.Host;
							_lvItem.SelectedItems[0].SubItems[1].Text = smtpServerForm.Port.ToString();
						}
					}
				}
			}
		}
Пример #5
0
		private void AddElement(SmtpServerForm smtpServerForm)
		{
			if (ExistItem(smtpServerForm.Host,smtpServerForm.Port) == true)
			{
				MessageBox.Show(string.Format("Unable to add '{0}:{1}' because already exist",smtpServerForm.Host,smtpServerForm.Port),"ActiveQConfiguration",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}

			else
			{
				_listServers.Add(new SmtpServer(smtpServerForm.Host,smtpServerForm.Port,smtpServerForm.Username,smtpServerForm.Password));

				ListViewItem.ListViewSubItem subItem = null;
				ListViewItem lvi =_lvItem.Items.Add(smtpServerForm.Host);
				lvi.ImageIndex = 0;
				subItem = lvi.SubItems.Add(smtpServerForm.Port.ToString());
			}

			EnableDisableArrow();
		}
Пример #6
0
		private void _bAdd_Click(object sender, System.EventArgs e)
		{
			SmtpServerForm smtpServerForm = new SmtpServerForm();
			DialogResult res = smtpServerForm.ShowDialog();

			if (res == DialogResult.OK)
			{
				AddElement(smtpServerForm);
			}
		}