Example #1
0
        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);
        }