Beispiel #1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (_curItem.UserId == -1)
     {
         UserHelper.UsersBelongs.Add(new UserInfo
         {
             UserId       = 0,
             UserName     = UserName.Text,
             Type2        = UserIdentity.Text,
             Password     = "******",
             RegisterDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
         });
     }
     else
     {
         foreach (var t in UserHelper.UsersBelongs)
         {
             if (t.UserName != _curItem.UserName)
             {
                 continue;
             }
             t.UserName  = UserName.Text;
             t.Type2     = UserIdentity.Text;
             t.IsChanged = true;
             break;
         }
     }
     UserEdit.Visibility = Visibility.Hidden;
     UserName.Clear();
     NewUser.IsEnabled        = EditUser.IsEnabled =
         DeleteUser.IsEnabled = OkButton.IsEnabled = Cancel.IsEnabled = true;
 }
Beispiel #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     UserName.Clear();
     UserEdit.Visibility      = Visibility.Hidden;
     NewUser.IsEnabled        = EditUser.IsEnabled =
         DeleteUser.IsEnabled = OkButton.IsEnabled = Cancel.IsEnabled = true;
 }
Beispiel #3
0
        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;
            }
        }