Ejemplo n.º 1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (txtUsername.Text.Length < 1 || txtPassword.Password.Length < 1 || txtServer.Text.Length < 1 || txtLocal.Text.Length < 1 || txtRemote.Text.Length < 1 || txtDelay.Text.Length < 1)
     {
         lblWarn.Content = "Fill all fields!";
     }
     else
     {
         int local, remote, delay = 0;
         if (int.TryParse(txtLocal.Text, out local) && int.TryParse(txtRemote.Text, out remote) && int.TryParse(txtDelay.Text, out delay))
         {
             if (local >= 1024 && local <= 65535 && remote >= 1024 && remote <= 65535)
             {
                 Properties.Settings.Default.username     = txtUsername.Text;
                 Properties.Settings.Default.remoteServer = txtServer.Text;
                 Properties.Settings.Default.localPort    = local;
                 Properties.Settings.Default.remotePort   = remote;
                 Properties.Settings.Default.delay        = delay;
                 Properties.Settings.Default.password     = ObfuscatePW.EncryptString(txtPassword.SecurePassword);
                 this.DialogResult = true;
             }
             else
             {
                 lblWarn.Content = "Ports between 1024 and 65535";
             }
         }
         else
         {
             lblWarn.Content = "Local, remote, delay only numbers";
         }
     }
 }
Ejemplo n.º 2
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (txtUsername.Text.Length < 1 || txtPassword.Password.Length < 1)
     {
         lblWarn.Content = "FILL ALL FIELDS!";
     }
     else
     {
         Properties.Settings.Default.username = txtUsername.Text;
         Properties.Settings.Default.password = ObfuscatePW.EncryptString(txtPassword.SecurePassword);
         this.DialogResult = true;
     }
 }