public void RefreshDatasetList() { panelDataset.Children.Clear(); List <DatasetInfo> dbList = MyTrees.treeDB.GetDatasets(); foreach (DatasetInfo db in dbList) { BtnDataset btn = new BtnDataset(db); btn.MouseDown += btnDataset_Click; panelDataset.Children.Add(btn); } }
//选中某个数据集时,可以修改该数据集对应的用户权限 private void btnDataset_Click(object sender, RoutedEventArgs e) { BtnDataset btnDataset = sender as BtnDataset; if (selectedDatasetBtn != null) { selectedDatasetBtn.isSelected = false; } selectedDatasetBtn = btnDataset; btnDataset.isSelected = true; btnModify.IsEnabled = true; //根据数据集名字获取对应的用户权限 List <string> allowUser = UserAdmin.GetAllowUserByData(btnDataset.DatasetName); foreach (BtnUserInfo cbx in panelUser.Children) { cbx.isSelected = (allowUser.Contains(cbx.UserId)); } }
//点击某个数据集时,自动改变其选中状态 private void cbxDataset_Click(object sender, RoutedEventArgs e) { BtnDataset cbx = sender as BtnDataset; cbx.isSelected = !cbx.isSelected; }