private void ExtractUserNames(IEnumerable <string> userGamesFiles, string fileNamePattern) { foreach (var userGameFile in userGamesFiles.Select(Path.GetFileName)) { UserNames.Add(userGameFile.Substring(0, userGameFile.Length - fileNamePattern.Length + 1)); } }
public void Save(string userName, string sdfName) { UserNames.Add(userName); UserNames = UserNames.Distinct().ToList(); UserName = userName; SdfName = sdfName; }
private void Button_Click(object sender, RoutedEventArgs e) { string s = newUser.Text.Trim(); if (s.Length > 0) { if ((from a in UserNames where a.ToLower() == s.ToLower() select a).Count() == 0) { UserNames.Add(s); newUser.Text = ""; } } }
public LoginViewModel() { UserService = new UserService(); User_MenuService = new User_MenuService(); userNames = new List <string>(); loginCommand = new DelegateCommand(); loginCommand.ExcuteAction = new Action <object>(Login); //moveCommand.ExcuteAction = new Action<object>((o) => //{ // var win = o as Window; // win.DragMove(); //}); closeCommand.ExcuteAction = new Action <object>(o => { Application.Current.Shutdown(); }); loadNameAndPwdCommand = new DelegateCommand(); //加载用户名列表和加载上次登录用户的密码 loadNameAndPwdCommand.ExcuteAction = new Action <object>(o => { Thread.Sleep(2000); var config = JsonHelper.ReadJsonFileToStr <Configs>(AppDomain.CurrentDomain.BaseDirectory + @"config/configs.json"); if (config != null) { if (config.UserConfig.Count > 0) { UserName = config.UserConfig[0].UserName; config.UserConfig.ForEach(u => { //添加到用户名列表 UserNames.Add(u.UserName); }); if (!string.IsNullOrEmpty(config.UserConfig[0].Token)) { //根据用户名和token获取密码 Pwd = UserService.GetPwdByTokenAndName(UserName, config.UserConfig[0].Token); } } } }); //选择项改变 selectChangeCommand = new DelegateCommand(); selectChangeCommand.ExcuteAction = new Action <object>(o => { var combox = o as ComboBox; var config = JsonHelper.ReadJsonFileToStr <Configs>(AppDomain.CurrentDomain.BaseDirectory + @"config/configs.json"); foreach (var item in config.UserConfig) { if (item.UserName == combox.SelectedItem as string) { if (!string.IsNullOrEmpty(item.Token)) { //根据用户名和token获取密码 Pwd = UserService.GetPwdByTokenAndName(item.UserName, item.Token); return; } } } Pwd = ""; }); }
public MeetingViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation) { _dispatcher = dispatcher; _serviceProvider = serviceProvider; _navigationState = navigationState; _navigation = navigation; token = ConnectEvent.Instance.Subscribe((c) => { lock (lockobj) //Synchronous { if (c.Parms.ContainsKey("HostCode") && c.Parms["HostCode"] != null && ((string)c.Parms["HostCode"]).ToUpper() == HostCode) { switch (c.Method) { case "ReceiveUpdate": _dispatcher.Invoke(Dispatcher, () => { var newUserNames = (List <string>)c.Parms["UserNames"]; foreach (var newUser in newUserNames) { if (!UserNames.Contains(newUser)) { UserNames.Add(newUser); } } var removeUsers = new List <string>(); foreach (var existUser in UserNames) { if (!newUserNames.Contains(existUser)) { removeUsers.Add(existUser); } } foreach (var user in removeUsers) { UserNames.Remove(user); } }); break; case "ReceiveUpdateRaiseHands": if (c.Parms.ContainsKey("HostCode")) { _dispatcher.Invoke(Dispatcher, () => { var RaisedHands = (List <string>)c.Parms["RaisedHands"]; RaisedNames.Clear(); foreach (var name in RaisedHands) { RaisedNames.Add(name); } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RaisedNames")); }); } break; case "ReceiveCloseHost": if (!IsHost) { var leaveparms = new Dictionary <string, object>(); leaveparms.Add("HostCode", HostCode); leaveparms.Add("Name", Name); leaveparms.Add("IsHost", IsHost); ConnectEvent.Instance.Publish(new Connect() { Method = "Set", Parms = leaveparms }); _navigation.GoBack(); } break; } } } }); LoadedCommand = new DelegateCommand(OnLoaded); LeaveCommand = new DelegateCommand(OnLeave); RaiseHandCommand = new DelegateCommand <string>(OnRaiseHand); }