public void RefreshUserList() { panelUser.Children.Clear(); List <UserInfo> userList = UserAdmin.GetUserInfoList(); foreach (UserInfo user in userList) { BtnUserInfo cbx = new BtnUserInfo(user); cbx.MouseDown += cbxUser_Click; panelUser.Children.Add(cbx); } }
//选中某个用户时,可以修改该用户对应的数据集权限 private void btnUser_Click(object sender, RoutedEventArgs e) { BtnUserInfo btnUser = sender as BtnUserInfo; if (selectedUserBtn != null) { selectedUserBtn.isSelected = false; } selectedUserBtn = btnUser; btnUser.isSelected = true; btnModify.IsEnabled = true; //根据用户ID获取对应的数据权限 List <string> allowData = UserAdmin.GetAllowDataByUser(btnUser.UserId); foreach (BtnDataset cbx in panelDataset.Children) { cbx.isSelected = (allowData.Contains(cbx.DatasetName)); } }
//点击某个用户时,自动改变其选中状态 private void cbxUser_Click(object sender, RoutedEventArgs e) { BtnUserInfo cbx = sender as BtnUserInfo; cbx.isSelected = !cbx.isSelected; }