static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //HttpClient client = new HttpClient(); //HttpResponseMessage response = await client.GetAsync("http://localhost:8080/accounts/"); //response.EnsureSuccessStatusCode(); AuthView = new AuthView(); ConnectView = new ConnectView(); LoginView = new LoginView(); PlayView = new PlayView(); RegisterView = new RegisterView(); CreditBankMenurView = new CreditBankMenuView(); CreditBankAuthenticationVIew = new CreditBankAuthenticationVIew(); AuthController = new AuthController(); ConnectController = new ConnectController(); PlayController = new PlayController(); AuthController = new AuthController(); CreditBankController = new CreditBankController(); Application.Run(ConnectView); }
private async void OnClickLogin(object obj) { var progressWindow = new Window { Height = 100, Width = 360, WindowStartupLocation = WindowStartupLocation.CenterOwner, Content = new ProgressBarView { DataContext = new ProgressBarViewModel { Label = "Authenticating..." } } }; progressWindow.Show(); var result = await ClientAPI.ClientLogin(Host, Port, Nick, Pass); progressWindow.Close(); if (result.Result == ClientAuthenticationResult.AuthResult.LoginSuccess) { var mainWindow = new MainWindow { WindowStartupLocation = WindowStartupLocation.CenterScreen }; mainWindow.Show(); ConnectView.Close(); } else { var errorText = result.Result switch { ClientAuthenticationResult.AuthResult.BadPassword => "Incorrect Password", ClientAuthenticationResult.AuthResult.NickInUse => "This nick is already in use", ClientAuthenticationResult.AuthResult.InvalidRequest => "Invalid request", _ => result.Result.ToString(), }; var errorWindow = new Window { Height = 100, Width = 360, Title = "Authentication Error", Content = errorText }; errorWindow.ShowDialog(); } }
//Server Connect private void Button_Click_Connect(object sender, RoutedEventArgs e) { this.connectWin = new ConnectView(); this.stopped = false; connectWin.ShowDialog(); try { this.vm.model.connectToServer(connectWin.Ip, connectWin.Port); } catch { AutoClosingMessageBox.Show("Connection Failed\nPlease try again\nClosing Window Please wait", "Error", 2500); } }
private void App_OnStartup(object sender, StartupEventArgs e) { var connectWindow = new ConnectView {DataContext = new ConnectViewModel()}; connectWindow.Show(); }