Beispiel #1
0
        private async void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                VPN vpn = _service.VPN_UPV;
                if (!vpn.IsReachable())
                {
                    bool exists = !string.IsNullOrEmpty(vpn.Name) || await CreateVPN(vpn, "la UPV desde fuera del campus");

                    if (exists)
                    {
                        _service.SaveChanges();
                        await vpn.ConnectAsync();
                    }
                    else
                    {
                        throw new OperationCanceledException();
                    }
                }

                OnStarted(EventArgs.Empty);
            }
            catch (OperationCanceledException)
            {
                // The user canceled the connection
            }
        }
Beispiel #2
0
        public async Task Start()
        {
            if (!started)
            {
                VPN vpn = _service.VPN_UPV;
                if (string.IsNullOrEmpty(vpn.Name))
                {
                    SelectVPN window = new SelectVPN(vpn);
                    window.ShowDialog();
                    if (window.Canceled)
                    {
                        throw new OperationCanceledException();
                    }
                    _service.SaveChanges();
                }

                await vpn.ConnectAsync();

                started = true;
                OnStarted();
            }
        }