static public void MakeContextMenuForAllBaseProxyServers(List <ToolStripItem> items) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Disconnect_from_active_VPN_connection; if (!NetConnUtils.IsActiveConnectionPresent()) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { NetConnUtils.CloseAllActiveConnections(true); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Show_created_VPN_entries_info; menuItem.Click += (s, em) => { try { MessageBox.Show(NetConnUtils.ShowConnectionEntries()); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Show_active_VPN_connection_info; if (!NetConnUtils.IsActiveConnectionPresent()) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { MessageBox.Show(NetConnUtils.ShowActiveConnections()); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Delete_all_VPN_entries; menuItem.Click += (s, em) => { try { DialogResult res = MessageBox.Show(null, VpnSelectorLibRes.Delete_VPN_entries__Press__Yes__to_delete_, FrwCRUDRes.WARNING, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { if (NetConnUtils.IsActiveConnectionPresent()) { NetConnUtils.CloseAllActiveConnections(true); } NetConnUtils.RemoveAllConnectionEntry(); } } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); }
static public void MakeContextMenuForBaseProxyServer(List <ToolStripItem> items, BaseProxyServer item) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Create_VPN_entry_ + " PPTP " + item.GetConnectionName(); if (NetConnUtils.IsConnectionEntryExist(item) || item.IsProtocolAvailable(ProxyProtocolTypeEnum.PPTP) == false) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.PPTP); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Create_VPN_entry_ + " L2TP " + item.GetConnectionName(); if (NetConnUtils.IsConnectionEntryExist(item) || item.IsProtocolAvailable(ProxyProtocolTypeEnum.L2TP) == false) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.L2TP); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Connect_to_VPN_server; if (NetConnUtils.IsConnected(item)) { menuItem.Enabled = false; } if (NetConnUtils.IsConnectionEntryExist(item)) { menuItem.Text = menuItem.Text + VpnSelectorLibRes.__created_; } menuItem.Text = menuItem.Text + " " + item.GetConnectionName(); menuItem.Click += (s, em) => { try { DialogResult res = DialogResult.Cancel; if (NetConnUtils.IsActiveConnectionPresent()) { res = MessageBox.Show(VpnSelectorLibRes.Active_VPN_connection_found____ + NetConnUtils.ShowConnectionEntries() + VpnSelectorLibRes.__Press_OK_to_close_it_and_connect_to_selected_VPN_server_, VpnSelectorLibRes.Warning_, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (res == DialogResult.OK) { NetConnUtils.CloseAllActiveConnections(false); } } else { res = DialogResult.OK; } if (res == DialogResult.OK) { bool statusChanged = CreateAndConnectToProxyAsync(item); } } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Disonnect_from_VPN_server_ + item.GetConnectionName(); if (!NetConnUtils.IsConnected(item)) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { NetConnUtils.CloseConnect(item, true); } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); menuItem = new ToolStripMenuItem(); menuItem.Text = VpnSelectorLibRes.Set_as_default_VPN_connection_ + item.GetConnectionName(); if (NetConnUtils.GetDefaulBaseProxyServer() == item) { menuItem.Enabled = false; } menuItem.Click += (s, em) => { try { BaseProxyServerDefault = item; JSetting setting = FrwConfig.Instance.GetProperty(DEFAULT_JPROXY_SERVER); setting.Value = item; } catch (Exception ex) { Log.ShowError(ex); } }; items.Add(menuItem); }