public MainWindow() { _app = App.CurrentApp; InitializeComponent(); _dashboardViewModel = (Dashboard)FindResource("DashboardViewModel"); _searchViewModel = (SearchDescriptor)FindResource("SearchViewModel"); var authConfig = _configurationManager.GetAuthConfig(); _dashboardViewModel.UserName = authConfig.UserName; ExpirationDate.SelectedDate = DateTime.Now.AddDays(-1); if (string.IsNullOrEmpty(_dashboardViewModel.UserName)) { _dashboardViewModel.LoginInfoEnabled = true; UserNameBox.Focus(); } else if (string.IsNullOrEmpty(authConfig.AuthToken)) { _dashboardViewModel.LoginInfoEnabled = true; Password.Focus(); } else { Password.Password = "******"; Login.Content = "退出"; } VersionRun.Text = CurrentVersionBlock.Text = GetVersionInfo(); }
private async void AuthorizeButton_Click(object sender, RoutedEventArgs e) { User.Name = UserNameBox.Text; User.Password = UserPasswordBox.Text; if (User.Name != string.Empty && User.Password != string.Empty) { bool isRegistred = Convert.ToBoolean(await ApiManager.Read($"api/authorization/isRegistred/{User.Name}/{User.Password}")); if (isRegistred) { MainWindow mainWindow = new MainWindow(); SignalRManager signalRManager = new SignalRManager(); ApiManager.Change("api/authorization/login", $"{{'Name':'{User.Name}', 'Password':'******'}}"); signalRManager.OnConnect(); Close(); mainWindow.ShowDialog(); } else { MessageBox.Show("Вы не зарегестрированы!"); } UserNameBox.Clear(); UserPasswordBox.Clear(); } else { MessageBox.Show("Заполните все поля!"); } }
public LoginPage() { InitializeComponent(); _SerializationService = Template10.Services.SerializationService.SerializationService.Json; Loaded += (sender, args) => { if (string.IsNullOrEmpty(UserNameBox.Text)) { UserNameBox.Focus(FocusState.Keyboard); } else { PasswordBox.Focus(FocusState.Keyboard); } }; KeyUp += (sender, args) => { if (args.Key == VirtualKey.Enter) { LoginButton_OnClick(sender, args); } }; }
/// <summary> /// Eventmetode for loginknapp /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonLogin_Click(object sender, EventArgs e) { if (!_brukerNavnValidated || !_passordValidated) { return; } if (_dbConnect.CheckPassword(_finalBrukernavn, _finalPassord)) { SpillerNavn = _finalBrukernavn; SpillerID = _dbConnect.GetPlayerId(_finalBrukernavn); SpillerHighScore = _dbConnect.GetPersonalBest(SpillerID); // AllHighScore = _dbConnect.GetHighScores(); //Program.cs sjekker om DoRun er true, lukker så dette formet sånn at tråden kan kjøre spillet. if (!String.IsNullOrEmpty(SpillerNavn) && !String.IsNullOrEmpty(SpillerID.ToString()) && !String.IsNullOrEmpty(SpillerHighScore.ToString())) { DoRun = true; Close(); } else { errorProviderUserName.SetError(UserNameBox, "Database error"); } } else { UserNameBox.Clear(); PasswordBox.Clear(); DoRun = false; errorProviderUserName.SetError(UserNameBox, "Wrong username or password!"); } }
public Login() { InitializeComponent(); UserNameBox.Focus(); UserName = null; Password = null; }
private void ConnectBtn_Click(object sender, EventArgs e) { myFTP = new MyFTP(); myFTP.Server = ServerBox.Text.Trim(); if (myFTP.Server.Length == 0) { ServerWarning.Visible = true; ServerBox.Focus(); return; } ServerWarning.Visible = false; myFTP.UserName = UserNameBox.Text.Trim(); if (myFTP.UserName.Length == 0) { UserWarning.Visible = true; UserNameBox.Focus(); return; } UserWarning.Visible = false; myFTP.Password = PwdBox.Text.Trim(); try { myFTP.Port = int.Parse(PortBox.Text); }catch { PortWarning.Visible = true; PortBoxLabel.Focus(); return; } PortWarning.Visible = false; RemoteTree.Nodes.Clear(); AddLog($"正在尝试连接 {myFTP.Server}:{myFTP.Port}......"); try { myFTP.Connect(); } catch (Exception ex) { AddLog("错误: " + ex.Message, 1); return; } AddLog($"FTP已连接到 {myFTP.Server}:{myFTP.Port}, 成功登录!"); Text = $"极简FTP [{myFTP.Server}:{myFTP.Port}]"; PreLoadRemoteTree(); }
public LoginPage() { InitializeComponent(); ViewModel = new LoginViewModel(); ViewModel.Authenticated += new System.EventHandler(User_Authenticated); DataContext = ViewModel; UserNameBox.Focus(); }
private void FillTextBoxes(ComputerSummary computerMetrics) { UserNameBox.AppendText(computerMetrics.User); ComputerNameBox.AppendText(computerMetrics.Name); RamBox.AppendText(computerMetrics.Ram + " MB"); RamUsageBox.AppendText(computerMetrics.RamUsage + " %"); CpuUsageBox.AppendText(computerMetrics.CpuUsage + " %"); CpuBox.AppendText(computerMetrics.Cpu); IpBox.AppendText(computerMetrics.Ip.ToString()); AverageDiskQueueLengthBox.AppendText(computerMetrics.AverageDiskQueueLength.ToString()); AvailableDiskSpaceGBBox.AppendText(computerMetrics.AvailableDiskSpaceGb + " GB"); VideoCardBox.AppendText(computerMetrics.VideoCard); }
private void ClearTextBoxes() { UserNameBox.Clear(); ComputerNameBox.Clear(); RamBox.Clear(); RamUsageBox.Clear(); CpuUsageBox.Clear(); CpuBox.Clear(); IpBox.Clear(); AverageDiskQueueLengthBox.Clear(); AvailableDiskSpaceGBBox.Clear(); VideoCardBox.Clear(); }
public StartUpForm() { InitializeComponent(); //AB - Creates a random number between 100 and 999 and displays it as the current number of online users. Random r = new Random(); label3.Text = Convert.ToString(r.Next(100, 1000)); //AB & ABo - Cursor starts in the text box when the form is launched. UserNameBox.SelectionStart = UserNameBox.Text.Length; UserNameBox.Focus(); }
private void LoginPage_Loaded(object sender, RoutedEventArgs e) { Pivot.Background = (ImageBrush)App.Current.Resources["BackgroundBrush"]; var settings = IsolatedStorageSettings.ApplicationSettings; if (settings.Contains("UserName")) { UserNameBox.Text = (string)settings["UserName"]; UserNameBox.Foreground = new SolidColorBrush(Colors.Black); FakePasswordBox.Focus(); settings.Remove("UserName"); settings.Save(); } else { UserNameBox.Focus(); } }
/// <summary> /// LogIn button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LogInButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(UserNameBox.Text)) { errorMsg = new AlertOK("Message", "Please enter your user name!"); errorMsg.ShowDialog(); //MessageBox.Show("Please enter your user name!", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); UserNameBox.Focus(); return; } try { using (HotelManagementSystemEntities test = new HotelManagementSystemEntities()) { var query = from o in test.LogIns where o.UserName == UserNameBox.Text && o.PassWord == PassWordBox.Password select o; if (query.SingleOrDefault() != null) { MainWindow MainHome = new MainWindow(); this.Close(); //Application.Current.Shutdown(); MainHome.ShowDialog(); // this.LogInPage.Close(); } else { errorMsg = new AlertOK("Message", "Your user-name or password is incorrect."); errorMsg.ShowDialog(); // MessageBox.Show("Your user-name or password is incorrect.","Message",MessageBoxButton.OK,MessageBoxImage.Information); } } } catch (Exception ex) { errorMsg = new AlertOK("Message", ex.Message); errorMsg.ShowDialog(); //MessageBox.Show(ex.Message,"Message",MessageBoxButton.OK,MessageBoxImage.Error); } }
private void Login_Click(object sender, EventArgs e) { string UserName = UserNameBox.Text; string password = PasswordBox.Text; if (UserName == null || UserName.Equals("")) { MessageBox.Show("Must enter your credentials!"); } else if (LoginChecker.CheckIfValid(UserName, password, ref student)) //Validate the login { LoggedIn = true; Console.WriteLine("user is: " + UserName + "\n" + " pass is: " + password); WelcomeUser.Text = "Welcome to the Nation, " + UserName + "!"; UserNameBox.Clear(); PasswordBox.Clear(); } else { MessageBox.Show("Invalid Login!"); } }
private void UserNameBox_GotFocus(object sender, RoutedEventArgs e) { UserNameBox.Clear(); UserNameBox.Foreground = Brushes.Black; }
private void loginBtn(object sender, RoutedEventArgs e) { try { var user = dc.users.Where(x => x.UserName == UserNameBox.Text && x.Password == PasswordBox.Password).Single(); if (AdminBox.IsChecked == true && EmployeeBox.IsChecked == true) { MessageBox.Show("Please only selected one role!"); } else { if (AdminBox.IsChecked == true) { if (user.Role == AdminBox.Content.ToString()) { Homepage hp = new Homepage(); hp.Show(); this.Hide(); } else { MessageBox.Show("U Dont have access to this!"); UserNameBox.Clear(); PasswordBox.Clear(); } } else if (EmployeeBox.IsChecked == true) { if (user.Role == EmployeeBox.Content.ToString()) { Homepage hp = new Homepage(); hp.Show(); this.Hide(); } else if (user.Role == "Admin") { Homepage hp = new Homepage(); hp.Show(); this.Hide(); } else { MessageBox.Show("U Dont have access to this!"); UserNameBox.Clear(); PasswordBox.Clear(); } } else { MessageBox.Show("u need to check out ur role"); } } } catch { UserNameBox.Clear(); PasswordBox.Clear(); MessageBox.Show("Login failed"); } }
private void ClearAll() { IPmaskedTextBox.Clear(); UserNameBox.Clear(); portTextBox.Clear(); }
private void UsernameClearButton_Click(object sender, EventArgs e) { UserNameBox.Clear(); }
private async void Signin_OnClick(object sender, RoutedEventArgs e) { if (_dashboardViewModel.LoginInfoEnabled) { Login.IsEnabled = false; _dashboardViewModel.LoginInfoEnabled = false; var pageFetcher = ComponentFactory.GetPageFetcher(); var isSignedIn = false; try { var name = _dashboardViewModel.UserName; var password = Password.Password; if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(password)) { //TODO:Use wpf data validation MessageBox.Show("别瞎输、瞎点。"); return; } SigninProgress.Visibility = Visibility.Visible; var authToken = await pageFetcher.Signin(name, password); isSignedIn = true; _configurationManager.SaveAuthConfig(new AuthConfig { UserName = name, AuthToken = authToken }); Password.Password = "******"; _dashboardViewModel.LoginInfoEnabled = false; Login.Content = "退出"; } catch (CannotSigninException cse) { MessageBox.Show(string.IsNullOrEmpty(cse.Message) ? "登录不了,可能是网络不行。" : cse.Message); } finally { Login.IsEnabled = true; SigninProgress.Visibility = Visibility.Hidden; if (!isSignedIn) { _dashboardViewModel.LoginInfoEnabled = true; if (string.IsNullOrWhiteSpace(_dashboardViewModel.UserName)) { UserNameBox.Focus(); } else { Password.Focus(); } } } } else { ComponentFactory.GetPageFetcher().Signout(); _configurationManager.SaveAuthConfig(new AuthConfig { UserName = _dashboardViewModel.UserName, AuthToken = "" }); _dashboardViewModel.LoginInfoEnabled = true; Password.Clear(); Password.Focus(); Login.Content = "登录"; } }
public LogIn() { InitializeComponent(); UserNameBox.Focus(); }
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { // Update with every change (in WPF, this could be accomplished through the UpdateSourceTrigger enum) UserNameBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); }
//----< Handle Login Button Click >------------------------------------- private void LogInButton_Click(object sender, RoutedEventArgs e) { if (!isLoggedIn) { CsEndPoint userEndPoint = new CsEndPoint(); userEndPoint.machineAddress = "localhost"; userEndPoint.port = 9000; CsMessage msg = new CsMessage(); msg.add("to", CsEndPoint.toString(userEndPoint)); msg.add("from", CsEndPoint.toString(endPoint_)); msg.add("command", "check_credentials"); msg.add("userName", UserNameBox.Text); msg.add("password", PasswordBox.Text); UserNameBox.Clear(); PasswordBox.Clear(); translater.postMessage(msg); CsMessage replyMsg = translater.getMessage(); if (replyMsg.value("credentialCheck") == "credential_good_is_admin") { UserNameBox.Clear(); PasswordBox.Clear(); isLoggedIn = true; LogInButton.Content = "Log Out"; CreateNewUserButton.IsEnabled = true; tabItem2.IsEnabled = true; tabItem3.IsEnabled = true; tabItem4.IsEnabled = true; Console.Write("\nValid - Admin"); } else if (replyMsg.value("credentialCheck") == "credential_good_not_admin") { UserNameBox.Clear(); PasswordBox.Clear(); isLoggedIn = true; LogInButton.Content = "Log Out"; tabItem2.IsEnabled = true; tabItem3.IsEnabled = true; tabItem4.IsEnabled = true; Console.Write("\nValid - Not Admin"); } else if (replyMsg.value("credentialCheck") == "credential_not_good") { Console.Write("\nNot Valid"); } else { Console.Write("\nLog In Error"); } } else { UserNameBox.Clear(); PasswordBox.Clear(); isLoggedIn = false; LogInButton.Content = "Log In"; CreateNewUserButton.IsEnabled = false; CreateNewUserButton.Content = "Create New User"; tabItem2.IsEnabled = false; tabItem3.IsEnabled = false; tabItem4.IsEnabled = false; Console.Write("\nLogging Out"); } }
public SignInWindow() { InitializeComponent(); UserNameBox.Focus(); }