public ProtectionViewModel()
{
Servers = new ObservableCollection<ServerModel>();
{
Servers.Add(new ServerModel
{
Country = "Germany",
Image = "https://tse2.mm.bing.net/th?id=OIP.xp_gP4N6JVcGfHcGVr7acgHaD6",
Config = "--config ./VPN/de-udp6.ovpn"
});
Servers.Add(new ServerModel
{
Country = "United States",
Image = "https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/2560px-Flag_of_the_United_States.svg.png",
Config = "--config ./VPN/us-udp6.ovpn"
});
}
ConnectCommand = new RelayCommand(o =>
{
ConnectionStatus = "Connecting...";
var process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Program Files\OpenVPN\bin\openvpn.exe";
startInfo.Arguments = "--config ./VPN/de-udp6.ovpn";
startInfo.Verb = "runas";
startInfo.UseShellExecute = true;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
ConnectionStatus = "Connected";
ShowSelectedItem();
});
}