Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (client.ifConnect == false)
- ConnectBtn.Click += Connect_Click;
- if (client.ifConnect)
- AutorizatBtn.Click += Autorizat_Click;
- private void Autorizat_Click(object sender, RoutedEventArgs e)
- {
- string userName = UserNameTxt.Text;
- if (client.Authorizat(userName))
- {
- NavigationService nav = NavigationService.GetNavigationService(this);
- nav.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
- }
- else
- {
- AutorizatTextBlock.Text = "Неверное имя или пароль";
- };
- }
- private void Connect_Click(object sender, RoutedEventArgs e)
- {
- client.Connect();
- if (client.ifConnect)
- AutorizatTextBlock.Text = "Успешное подключение";
- else AutorizatTextBlock.Text = "Сервер не доступен";
- }
- public void Connect ()
- {
- try
- {
- if (!ifConnect)
- {
- client = new TcpClient(address, port);
- stream = client.GetStream();
- ifConnect = true;
- }
- }
- catch (Exception ex)
- {
- ifConnect = false;
- }
- }
Add Comment
Please, Sign In to add comment