private void btnOK_Click(object sender, EventArgs e) { if(String.IsNullOrWhiteSpace(textBoxHost.Text)) { MessageBox.Show(this, CANAPE.Properties.Resources.EditFilterForm_MustProvideHost, CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Filter = new IpProxyFilterFactory(); Filter.Address = textBoxHost.Text; Filter.Port = (int)numFilterPort.Value; Filter.ClientType = Net.Tokens.IpProxyToken.IpClientType.Tcp; Filter.Block = checkBoxBlock.Checked; Filter.IsRegex = checkBoxRegex.Checked; Filter.Disabled = !checkBoxEnabled.Checked; if (Filter.IsRegex) { try { new Regex(Filter.Address, RegexOptions.IgnoreCase); } catch(ArgumentException) { MessageBox.Show(this, CANAPE.Properties.Resources.EditFilterForm_InvalidRegex, CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Filter.Layers = layerEditorControl.Layers; if (comboBoxNetgraph.SelectedItem != null) { NetGraphDocument doc = comboBoxNetgraph.SelectedItem as NetGraphDocument; Filter.Graph = doc; } if (checkBoxRedirect.Checked) { Filter.RedirectAddress = textBoxRedirectHost.Text; Filter.RedirectPort = (int)numRedirectPort.Value; } else { Filter.RedirectAddress = String.Empty; Filter.RedirectPort = 0; } if (checkBoxClient.Checked) { Filter.Client = proxyClientControl.Client; } DialogResult = DialogResult.OK; Close(); }
private void AddNewFilter(string host, int port, params INetworkLayerFactory[] layers) { IpProxyFilterFactory factory = new IpProxyFilterFactory(); factory.Address = host; factory.Port = port; factory.Layers = layers; AddTemplateFactory(factory); }
private void EditFilterForm_Load(object sender, EventArgs e) { if (Filter == null) { Filter = new IpProxyFilterFactory(); Filter.Address = "*"; Filter.Port = 0; Filter.Graph = null; } UpdateNetgraphs(); SetupFilter(); }