Пример #1
0
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     if ((String.IsNullOrWhiteSpace(IP.Text)) || (String.IsNullOrWhiteSpace(Port.Text)))
     {
         // Dealing with the visibilty and time of the error lable that appears on the screen.
         this.errorLable.Content    = "Missing IP or Port";
         this.errorLable.FontSize   = 30;
         this.errorLable.Visibility = Visibility.Visible;
         timer.Start();
     }
     else if (!IsValidIP(IP.Text) || !IsValidPort(Port.Text))
     {
         // Dealing with the visibilty and time of the error lable that appears on the screen.
         this.errorLable.Content    = "Invalid Input";
         this.errorLable.FontSize   = 30;
         this.errorLable.Visibility = Visibility.Visible;
         timer.Start();
     }
     else
     {
         try
         {
             // Trying to connect to server using the ip and port from the user.
             model.setClient(new Client());
             vm.connect(IP.Text, Int32.Parse(Port.Text));
             vm.start();
             view = new FlightView();
             view.set_VM(vm);
             this.NavigationService.Navigate(view);
         }
         catch (Exception)
         {
             // Dealing with the visibilty and time of the error lable that appears on the screen.
             this.errorLable.Content    = "Server is not connected";
             this.errorLable.Visibility = Visibility.Visible;
             this.errorLable.FontSize   = 24;
             timer.Interval             = TimeSpan.FromSeconds(5);
             timer.Start();
         }
     }
 }
Пример #2
0
 private void Default_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Trying to connect to server using the ip and port from App.config
         model.setClient(new Client());
         int    defaultPort = Int32.Parse(ConfigurationManager.AppSettings["port"].ToString());
         string defaultIP   = ConfigurationManager.AppSettings["ip"].ToString();
         vm.connect(defaultIP, defaultPort);
         vm.start();
         view = new FlightView();
         view.set_VM(vm);
         this.NavigationService.Navigate(view);
     }
     catch (Exception)
     {
         // Dealing with the visibilty and time of the error lable that appears on the screen.
         this.errorLable.Visibility = Visibility.Visible;
         this.errorLable.FontSize   = 24;
         this.errorLable.Content    = "Server is not connected";
         timer.Interval             = TimeSpan.FromSeconds(6);
         timer.Start();
     }
 }