示例#1
0
 /// <summary>
 /// Load chats into observable cache
 /// </summary>
 private IDisposable LoadChats(IChatLoader chatLoader, IAvatarLoader avatarLoader)
 {
     return(chatLoader.LoadChats()
            .Select(GetChatEntryModel)
            .Aggregate(new List <EntryModel>(), (list, model) =>
     {
         model.Order = list.Count;
         list.Add(model);
         return list;
     })
            .Synchronize(_chats)
            .Do(entries =>
     {
         _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
         _chats.Refresh();
     })
            .SelectMany(entries => entries)
            .SelectMany(entry => LoadAvatar(avatarLoader, entry)
                        .Select(avatar => new
     {
         Entry = entry,
         Avatar = avatar
     }))
            .SubscribeOn(TaskPoolScheduler.Default)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(item =>
     {
         var entry = item.Entry;
         var avatar = item.Avatar;
         entry.Avatar = avatar;
     }));
 }
        /// <summary>
        /// Load chats into observable cache
        /// </summary>
        private IDisposable LoadChats()
        {
            return(_chatLoader.LoadChats()
                   .Select(GetChatEntryModel)
                   .Aggregate(new List <EntryModel>(), (list, model) =>
            {
                model.Order = list.Count;
                list.Add(model);
                return list;
            })
                   .Accept(entries =>
            {
                entries.Insert(0, HomeEntryModel.Instance);

                _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
                _chats.Refresh();
            }));
        }
示例#3
0
        public void GroupTest_RefreshItemWithoutGroupKeyChanged()
        {
            using (var cache = new SourceCache <Groupable <int, string>, Guid>(x => x.Key))
                using (var aggregator = cache.Connect()
                                        .Group(x => x.GroupKey)
                                        .AsAggregator())
                {
                    cache.AddOrUpdate(_items);
                    cache.Refresh(_items[0]);

                    Assert.AreEqual(1, aggregator.Messages.Count);
                    EnumerableAssert.None(aggregator.Messages.SelectMany(x => x), x => x.Reason == ChangeReason.Refresh);
                }
        }
示例#4
0
 /// <summary>
 /// Load chats into observable cache
 /// </summary>
 private IDisposable LoadChats(
     IChatLoader chatLoader)
 {
     return(chatLoader.LoadChats()
            .Select(GetChatEntryModel)
            .Aggregate(new List <EntryModel>(), (list, model) =>
     {
         model.Order = list.Count;
         list.Add(model);
         return list;
     })
            .Synchronize(_chats)
            .Accept(entries =>
     {
         _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
         _chats.Refresh();
     }));
 }
        public async Task Refresh_Cash()
        {
            IReadOnlyDictionary <long, string?>?accountRemarks = SteamAccountSettings.AccountRemarks.Value;

            foreach (var item in _AuthorizedSourceList.Items)
            {
                var temp = await webApiService.GetUserInfo(item.SteamId64_Int);

                item.SteamID       = temp.SteamID;
                item.SteamNickName = temp.SteamNickName ?? item.AccountName ?? item.SteamId3_Int.ToString();
                item.AvatarIcon    = temp.AvatarIcon;
                item.AvatarMedium  = temp.AvatarMedium;
                item.MiniProfile   = temp.MiniProfile;
                if (item.MiniProfile != null && !string.IsNullOrEmpty(item.MiniProfile.AnimatedAvatar))
                {
                    item.AvatarStream = httpService.GetImageAsync(item.MiniProfile.AnimatedAvatar, ImageChannelType.SteamAvatars);
                }
                else
                {
                    item.AvatarStream = httpService.GetImageAsync(temp.AvatarFull, ImageChannelType.SteamAvatars);
                }

                if (accountRemarks?.TryGetValue(item.SteamId64_Int, out var remark) == true &&
                    !string.IsNullOrEmpty(remark))
                {
                    item.Remark = remark;
                }
            }

            _AuthorizedSourceList.Refresh();

            //foreach (var item in _AuthorizedSourceList.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);
            //        //miniProfile.AvatarFrameStream = httpService.GetImageAsync(miniProfile.AvatarFrame, ImageChannelType.SteamAvatars);
            //    }
            //}
            //_AuthorizedSourceList.Refresh();
        }
示例#6
0
        public void DuplicateKeysRefreshAfterRemove()
        {
            var source1 = new SourceCache <Person, string>(p => p.Name);
            var source2 = new SourceCache <Person, string>(p => p.Name);

            var person = new Person("Person2", 12);

            var results = source1.Connect().Merge(source2.Connect()).DistinctValues(p => p.Age).AsAggregator();

            source1.AddOrUpdate(person);
            source2.AddOrUpdate(person);
            source2.Remove(person);
            source1.Refresh(person); // would previously throw KeyNotFoundException here

            results.Messages.Should().HaveCount(1);
            results.Data.Items.ShouldAllBeEquivalentTo(new[] { 12 });

            source1.Remove(person);

            results.Messages.Should().HaveCount(2);
            results.Data.Items.Should().BeEmpty();
        }
示例#7
0
        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
        }
 public void Refresh()
 {
     _cache.Refresh();
 }