Exemple #1
0
        private void editSmtpItem()
        {
            tabControl.SelectTab("tabPageSMTP");

            ListView.SelectedIndexCollection selectedItems = this.listViewSMTP.SelectedIndices;
            if (selectedItems != null && selectedItems.Count > 0)
            {
                HostConfigObject currentSmtpObj = SettingsObject.ListSMTP[selectedItems[0]];
                SMTPWindow window = new SMTPWindow(currentSmtpObj);
                DialogResult result = window.ShowDialog();
                if (result == DialogResult.OK)
                {
                    HostConfigObject newSmtpObj = window.getHostConfigObject();
                    if (newSmtpObj != null)
                    {
                        // Remove old object from collection
                        SettingsObject.ListSMTP.Remove(currentSmtpObj);

                        // Add new object to collection
                        SettingsObject.ListSMTP.Add(newSmtpObj);

                        // Remove old listview entry
                        this.listViewSMTP.Items.RemoveAt(selectedItems[0]);

                        // Add new listview entry
                        ListViewItem item = new ListViewItem(new string[] { "", newSmtpObj.Description, newSmtpObj.Host, newSmtpObj.Username });
                        item.Checked = newSmtpObj.Active;
                        this.listViewSMTP.Items.Add(item);
                        this.listViewSMTP.Sort();
                    }
                }
            }
        }
Exemple #2
0
        private void addSmtpItem()
        {
            tabControl.SelectTab("tabPageSMTP");
            SMTPWindow window = new SMTPWindow();
            DialogResult result = window.ShowDialog();
            if (result == DialogResult.OK)
            {
                HostConfigObject hostObj = window.getHostConfigObject();
                if (hostObj != null)
                {
                    // Add to local collection
                    SettingsObject.ListSMTP.Add(hostObj);

                    // Add to listview
                    ListViewItem item = new ListViewItem(new string[] { "", hostObj.Description, hostObj.Host, hostObj.Username });
                    item.Checked = true;
                    this.listViewSMTP.Items.Add(item);
                    this.listViewSMTP.Sort();
                }
            }
        }