using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.Pages.View; using BPA.Helper; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.CustomResource.Pages.ViewModel { public class UserManagerViewModel { /// /// datagrid绑定 /// public ObservableCollection userManager { get; set; } = Global.userManager.userInfos; public BPARelayCommand ChangePasswardCommand { get; set; } public BPARelayCommand AddNewUserCommand { get; set; } public BPARelayCommand DeleteUserCommand { get; set; } public BPARelayCommand EditUserConfigCommand { get; set; } private void ChangePassward(object o) { if (o != null && o is UserInfo infos) { Global.changeUserInfo = infos; PasswordChangeView passwordChangeView = new PasswordChangeView(); passwordChangeView.ShowDialog(); } } private void DeleteUser(object o) { if (o != null && o is UserInfo infos) { var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == infos.UserName); if (res != null) Global.userManager.userInfos.Remove(res); Config.GetInstance.SaveUser(); } } private void EditUserConfig(object o) { if (o != null && o is UserInfo infos) { Global.changeUserInfo = null; Global.changeUserInfo = infos; UserConfigView userConfigView = new UserConfigView(); userConfigView.ShowDialog(); } } public UserManagerViewModel() { ChangePasswardCommand = new BPARelayCommand(ChangePassward); AddNewUserCommand = new BPARelayCommand(() => { AddNewUser addNewUser = new AddNewUser(); addNewUser.ShowDialog(); }); DeleteUserCommand = new BPARelayCommand(DeleteUser); EditUserConfigCommand = new BPARelayCommand(EditUserConfig); } } }