public void Refresh_Click() { var list = new List <AuthorizedDevice>(); var userlist = steamService.GetRememberUserList(); var allList = steamService.GetAuthorizedDeviceList(); int count = allList.Count - 1; foreach (var item in allList) { var temp = userlist.FirstOrDefault(x => x.SteamId3_Int == item.SteamId3_Int); item.SteamNickName = temp?.SteamNickName; item.ShowName = item.SteamNickName + $"({item.SteamId64_Int})"; item.AccountName = temp?.AccountName; item.First = item.Index == 0; item.End = item.Index == count; list.Add(item); } _AuthorizedSourceList.Clear(); _AuthorizedSourceList.AddOrUpdate(list); //_AuthorizedSourceList.Refresh(); Refresh_Cash().ConfigureAwait(false); }
public override async void Initialize() { var list = steamService.GetRememberUserList(); if (!list.Any_Nullable()) { return; } _SteamUsersSourceList.AddOrUpdate(list); RefreshRememberUserList(); #region 加载备注信息 IReadOnlyDictionary <long, string?>?accountRemarks = SteamAccountSettings.AccountRemarks.Value; MenuItems = new ObservableCollection <MenuItemViewModel>(); List <(string title, string applicationPath, string iconResourcePath, string arguments, string description, string customCategory)>?jumplistData = OperatingSystem2.IsWindows ? new() : null; foreach (var user in _SteamUsersSourceList.Items) { if (accountRemarks?.TryGetValue(user.SteamId64, out var remark) == true && !string.IsNullOrEmpty(remark)) { user.Remark = remark; } if (OperatingSystem2.IsWindows) { var title = user.SteamNickName ?? user.SteamId64.ToString(CultureInfo.InvariantCulture); if (!string.IsNullOrEmpty(user.Remark)) { title = user.SteamNickName + "(" + user.Remark + ")"; } MenuItems.Add(new MenuItemCustomName(title, AppResources.UserChange_BtnTootlip) { Command = ReactiveCommand.Create(() => { SteamId_Click(user); INotificationService.Instance.Notify(string.Format(AppResources.UserChange_ChangeUserTip, title), NotificationType.Message); }), }); if (!string.IsNullOrEmpty(user.AccountName)) { jumplistData !.Add(( title: title, applicationPath: IApplication.ProgramPath, iconResourcePath: IApplication.ProgramPath, arguments: $"-clt steam -account {user.AccountName}", description: AppResources.UserChange_BtnTootlip, customCategory: Name)); } } } if (jumplistData.Any_Nullable()) { MainThread2.BeginInvokeOnMainThread(async() => { var s = IJumpListService.Instance; await s.AddJumpItemsAsync(jumplistData); }); } _SteamUsersSourceList.Refresh(); #endregion #region 通过webapi加载头像图片用户信息 foreach (var user in _SteamUsersSourceList.Items) { var temp = await webApiService.GetUserInfo(user.SteamId64); if (!string.IsNullOrEmpty(temp.SteamID)) { user.SteamID = temp.SteamID; user.OnlineState = temp.OnlineState; user.MemberSince = temp.MemberSince; user.VacBanned = temp.VacBanned; user.Summary = temp.Summary; user.PrivacyState = temp.PrivacyState; user.AvatarIcon = temp.AvatarIcon; user.AvatarMedium = temp.AvatarMedium; user.AvatarFull = temp.AvatarFull; user.MiniProfile = temp.MiniProfile; if (user.MiniProfile != null && !string.IsNullOrEmpty(user.MiniProfile.AnimatedAvatar)) { user.AvatarStream = httpService.GetImageAsync(user.MiniProfile.AnimatedAvatar, ImageChannelType.SteamAvatars); } else { user.AvatarStream = httpService.GetImageAsync(temp.AvatarFull, ImageChannelType.SteamAvatars); } } } _SteamUsersSourceList.Refresh(); #endregion #region 加载动态头像头像框数据 //foreach (var item in _SteamUsersSourceList.Items) //{ // item.MiniProfile = await webApiService.GetUserMiniProfile(item.SteamId3_Int); // var miniProfile = item.MiniProfile; // if (miniProfile != null) // { // if (!string.IsNullOrEmpty(miniProfile.AnimatedAvatar)) // item.AvatarStream = httpService.GetImageAsync(miniProfile.AnimatedAvatar, ImageChannelType.SteamAvatars); // if (!string.IsNullOrEmpty(miniProfile.AvatarFrame)) // miniProfile.AvatarFrameStream = httpService.GetImageAsync(miniProfile.AvatarFrame, ImageChannelType.SteamAvatars); // //item.Level = miniProfile.Level; // } //} //_SteamUsersSourceList.Refresh(); #endregion }