private async void LoginButton_ClickAsync(object sender, RoutedEventArgs e) { LoginButton.IsEnabled = false; var res = await Connection.Login(UserName.Text, Password.Password); switch (res) { case 1: { MessageBox.Show("用户名或密码错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error); break; } default: { if (res != 0) { MessageBox.Show("未知错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error); } break; } } LoginButton.IsEnabled = true; if (res != 0) { return; } UpdateListBoxContent( $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {UserHelper.CurrentUser.UserName} 欢迎登录 hjudge 服务端", null, false); UserName.Clear(); Password.Password = string.Empty; LoginGrid.Visibility = Visibility.Hidden; ContentGrid.Visibility = Visibility.Visible; var hiddenDaV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.5))); var showDaV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); var scratchWidthDaV = new DoubleAnimation(473, 673, new Duration(TimeSpan.FromSeconds(0.25))); var scratchHeightDaV = new DoubleAnimation(228, 328, new Duration(TimeSpan.FromSeconds(0.25))); LoginGrid.BeginAnimation(OpacityProperty, hiddenDaV); BeginAnimation(WidthProperty, scratchWidthDaV); await Task.Run(() => { Thread.Sleep(300); }); BeginAnimation(HeightProperty, scratchHeightDaV); ContentGrid.BeginAnimation(OpacityProperty, showDaV); switch (UserHelper.CurrentUser.Type) { case 1: SetEnvironmentForBoss(); break; case 2: SetEnvironmentForAdministrator(); break; case 3: SetEnvironmentForTeacher(); break; case 4: SetEnvironmentForStudent(); break; } }