public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            SelectedSortOptionItem = QueuePlaylist.DefaultSortOption;

            Observable.Merge(
                IsEnableGroupingByTitleSimulality.ToUnit(),
                this.ObserveProperty(x => x.SelectedSortOptionItem, isPushCurrentValueAtFirst: false).ToUnit()
                )
            .Subscribe(sort => ResetList())
            .AddTo(_navigationDisposables);


            _messenger.Register <PlaylistItemRemovedMessage, PlaylistId>(this, QueuePlaylist.Id, (r, m) =>
            {
                foreach (var item in m.Value.RemovedItems)
                {
                    var remove = ItemsView.Cast <IVideoContent>().FirstOrDefault(x => x.VideoId == item.VideoId);
                    ItemsView.Remove(remove);
                }
            });

            _messenger.Register <PlaylistItemAddedMessage, PlaylistId>(this, QueuePlaylist.Id, (r, m) =>
            {
                ItemsView.Clear();
                ItemsView.Refresh();
            });
        }
Esempio n. 2
0
        void RefreshItems()
        {
            if (Playlist != null)
            {
                WeakReferenceMessenger.Default.Register <PlaylistItemRemovedMessage, PlaylistId>(this, Playlist.PlaylistId, (r, m) =>
                {
                    var args = m.Value;
                    foreach (var video in args.RemovedItems)
                    {
                        var removedItem = ItemsView.Cast <VideoListItemControlViewModel>().FirstOrDefault(x => x.VideoId == video.VideoId);
                        if (removedItem != null)
                        {
                            ItemsView.Remove(removedItem);
                        }
                    }

                    PlaylistPlayAllCommand.NotifyCanExecuteChanged();
                });

                WeakReferenceMessenger.Default.Register <PlaylistItemAddedMessage, PlaylistId>(this, Playlist.PlaylistId, (r, m) =>
                {
                    var args  = m.Value;
                    int index = ItemsView.Count;
                    foreach (var video in args.AddedItems)
                    {
                        var nicoVideo = _nicoVideoProvider.GetCachedVideoInfo(video.VideoId);
                        ItemsView.Add(new VideoListItemControlViewModel(nicoVideo)
                        {
                            PlaylistItemToken = new PlaylistItemToken(Playlist, SelectedSortOptionItem, video)
                        });
                    }

                    PlaylistPlayAllCommand.NotifyCanExecuteChanged();
                });

                _localMylistManager.LocalPlaylists.ObserveRemoveChanged()
                .Subscribe(removed =>
                {
                    if (Playlist.PlaylistId == removed.PlaylistId)
                    {
                        _pageManager.ForgetLastPage();
                        _pageManager.OpenPage(HohoemaPageType.UserMylist);
                    }
                })
                .AddTo(_navigationDisposables);
            }
        }
Esempio n. 3
0
        private void MoveNext()
        {
            if (IsShuffle)
            {
                ItemsView.MoveCurrentToPosition(this.random.Next(0, ItemsView.Cast <Object>().Count()));
            }
            else
            {
                ItemsView.MoveCurrentToNext();

                if (ItemsView.IsCurrentAfterLast)
                {
                    ItemsView.MoveCurrentToFirst();
                }
            }
            ((IAudioListItemViewModel)ItemsView.CurrentItem).PlayCommand.Execute(null);
        }