private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("need a name"); return; } if (string.IsNullOrEmpty(txtOwnIP.Text)) { MessageBox.Show("need an IP"); return; } var config = Configuration.Proxies.FirstOrDefault(x => x.Name.Equals(txtName.Text)); if (config != null) { config.OwnIP = txtOwnIP.Text; config.Proxy = txtProxy.Text; config.BypassLocal = chkBypassLocal.Checked; config.AdditionalExceptions = txtAdditionalExceptions.Text; config.DefaultPrinter = cmbDefaultPrinter.SelectedItem.Equals(NO_PRINTER) ? null : cmbDefaultPrinter.SelectedItem.ToString(); } else { config = new ProxyConfig { Name = txtName.Text, OwnIP = txtOwnIP.Text, Proxy = txtProxy.Text, BypassLocal = chkBypassLocal.Checked, AdditionalExceptions = txtAdditionalExceptions.Text, DefaultPrinter = cmbDefaultPrinter.SelectedItem.Equals(NO_PRINTER) ? null : cmbDefaultPrinter.SelectedItem.ToString() }; Configuration.Proxies.Add(config); UpdateDialog(); } }
public ProxyConfigWrapper(ProxyConfig content, Func <ProxyConfig> currentProxyConfig) { Content = content; this.currentProxyConfig = currentProxyConfig; }