Guest User

Untitled

a guest
Oct 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. if (client.ifConnect == false)
  2. ConnectBtn.Click += Connect_Click;
  3. if (client.ifConnect)
  4. AutorizatBtn.Click += Autorizat_Click;
  5.  
  6.  
  7.  
  8. private void Autorizat_Click(object sender, RoutedEventArgs e)
  9. {
  10. string userName = UserNameTxt.Text;
  11.  
  12. if (client.Authorizat(userName))
  13. {
  14. NavigationService nav = NavigationService.GetNavigationService(this);
  15. nav.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
  16. }
  17. else
  18. {
  19. AutorizatTextBlock.Text = "Неверное имя или пароль";
  20.  
  21. };
  22. }
  23.  
  24. private void Connect_Click(object sender, RoutedEventArgs e)
  25. {
  26. client.Connect();
  27. if (client.ifConnect)
  28. AutorizatTextBlock.Text = "Успешное подключение";
  29. else AutorizatTextBlock.Text = "Сервер не доступен";
  30. }
  31.  
  32.  
  33. public void Connect ()
  34. {
  35. try
  36. {
  37. if (!ifConnect)
  38. {
  39. client = new TcpClient(address, port);
  40. stream = client.GetStream();
  41. ifConnect = true;
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. ifConnect = false;
  47. }
  48. }
Add Comment
Please, Sign In to add comment