示例#1
0
        public PlayerWithPageContainerViewModel(HohoemaApp hohoemaApp, HohoemaPlaylist playlist)
        {
            HohoemaPlaylist = playlist;

            IsFillFloatContent = HohoemaPlaylist
                                 .ObserveProperty(x => x.IsPlayerFloatingModeEnable)
                                 .Select(x => !x)
                                 .ToReadOnlyReactiveProperty();

            IsFillFloatContent_DelayedRead = IsFillFloatContent
                                             .Delay(TimeSpan.FromMilliseconds(300))
                                             .ToReadOnlyReactiveProperty();


            IsVisibleFloatContent = HohoemaPlaylist.ObserveProperty(x => x.IsDisplayMainViewPlayer)
                                    .ToReactiveProperty(mode: ReactivePropertyMode.DistinctUntilChanged);

            IsContentDisplayFloating = Observable.CombineLatest(
                IsFillFloatContent.Select(x => !x),
                IsVisibleFloatContent
                )
                                       .Select(x => x.All(y => y))
                                       .ToReactiveProperty();


            HohoemaPlaylist.OpenPlaylistItem += HohoemaPlaylist_OpenPlaylistItem;

            IsVisibleFloatContent
            .Where(x => !x)
            .Subscribe(x =>
            {
                ClosePlayer();
            });

            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
            {
                Observable.Merge(
                    IsVisibleFloatContent.Where(x => !x),
                    IsContentDisplayFloating.Where(x => x)
                    )
                .Subscribe(async x =>
                {
                    var view = ApplicationView.GetForCurrentView();
                    if (view.IsViewModeSupported(ApplicationViewMode.CompactOverlay))
                    {
                        var result = await view.TryEnterViewModeAsync(ApplicationViewMode.Default);
                    }
                });
            }
        }
示例#2
0
        public PlayerWithPageContainerViewModel(HohoemaApp hohoemaApp, HohoemaPlaylist playlist)
        {
            HohoemaPlaylist = playlist;

            IsFillFloatContent = HohoemaPlaylist
                                 .ToReactivePropertyAsSynchronized(x =>
                                                                   x.IsPlayerFloatingModeEnable
                                                                   , (x) => !x
                                                                   , (x) => !x
                                                                   );

            IsFillFloatContent_DelayedRead = IsFillFloatContent
                                             .Delay(TimeSpan.FromMilliseconds(300))
                                             .ToReadOnlyReactiveProperty();


            IsVisibleFloatContent = HohoemaPlaylist.ObserveProperty(x => x.IsDisplayPlayer)
                                    .ToReactiveProperty();

            IsContentDisplayFloating = Observable.CombineLatest(
                IsFillFloatContent.Select(x => !x),
                IsVisibleFloatContent
                )
                                       .Select(x => x.All(y => y))
                                       .ToReactiveProperty();

            ContentVM = new ReactiveProperty <ViewModelBase>();


            HohoemaPlaylist.OpenPlaylistItem += HohoemaPlaylist_OpenPlaylistItem;

            IsVisibleFloatContent
            .Where(x => !x)
            .Subscribe(x =>
            {
                ClosePlayer();
            });


            App.Current.Suspending += Current_Suspending;
        }