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(); } }