private void EditSelectedFilter_EventHandler(object sender, EventArgs e) { if (listViewFilters.SelectedItems.Count > 0) { ListViewItem item = listViewFilters.SelectedItems[0]; using (EditFilterForm frm = new EditFilterForm()) { frm.Filter = (IpProxyFilterFactory)item.Tag; if (frm.ShowDialog(this) == DialogResult.OK) { if (!_readOnly) { IpProxyFilterFactory filter = frm.Filter; item.Text = filter.ToString(); item.Tag = filter; ResizeColumns(); } } } UpdateFilters(); } }
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(); }
private void toggleEnabledToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewFilters.SelectedItems.Count > 0) { if (!_readOnly) { IpProxyFilterFactory factory = (IpProxyFilterFactory)listViewFilters.SelectedItems[0].Tag; factory.Disabled = !factory.Disabled; listViewFilters.SelectedItems[0].Text = factory.ToString(); UpdateFilters(); ResizeColumns(); } } }