Ejemplo n.º 1
0
        public FeedGroupManagePageViewModel(HohoemaApp hohoemaApp, PageManager pageManager, TextInputDialogService textInputDialog)
            : base(hohoemaApp, pageManager)
        {
            _TextInputDialogService = textInputDialog;

            FeedGroupItems    = new ObservableCollection <FeedGroupListItem>();
            HasFeedGroupItems = FeedGroupItems.ObserveProperty(x => x.Count)
                                .Select(x => x > 0)
                                .ToReadOnlyReactiveProperty()
                                .AddTo(_CompositeDisposable);
            IsSelectionModeEnable = new ReactiveProperty <bool>(false)
                                    .AddTo(_CompositeDisposable);
            SelectedFeedGroupItem = new ReactiveProperty <FeedGroupListItem>()
                                    .AddTo(_CompositeDisposable);



            NewFeedGroupName = new ReactiveProperty <string>("")
                               .AddTo(_CompositeDisposable);

            AddFeedGroupCommand = NewFeedGroupName
                                  .Select(x =>
            {
                if (string.IsNullOrWhiteSpace(x))
                {
                    return(false);
                }

                if (!HohoemaApp.FeedManager.CanAddLabel(x))
                {
                    return(false);
                }

                return(true);
            })
                                  .ToReactiveCommand()
                                  .AddTo(_CompositeDisposable);

            AddFeedGroupCommand.Subscribe(async _ =>
            {
                var feedGroup = await HohoemaApp.FeedManager.AddFeedGroup(NewFeedGroupName.Value);

                PageManager.OpenPage(HohoemaPageType.FeedGroup, feedGroup.Id);
            })
            .AddTo(_CompositeDisposable);
        }
Ejemplo n.º 2
0
 public ShereVideoInfoContentViewModel(NicoVideo nicoVideo, TextInputDialogService textInputService, ToastNotificationService toastService)
 {
     _NicoVideo = nicoVideo;
     _TextInputDialogService   = textInputService;
     _ToastNotificationService = toastService;
 }
Ejemplo n.º 3
0
        public LiveVideoPlayerControlViewModel(
            HohoemaApp hohoemaApp,
            PageManager pageManager,
            TextInputDialogService textInputDialogService,
            ToastNotificationService toast
            )
            : base(hohoemaApp, pageManager, canActivateBackgroundUpdate: true)
        {
            _TextInputDialogService   = textInputDialogService;
            _ToastNotificationService = toast;

            MediaPlayer = HohoemaApp.MediaPlayer;

            // play
            CurrentState = new ReactiveProperty <MediaElementState>();
            NowPlaying   = CurrentState.Select(x => x == MediaElementState.Playing)
                           .ToReactiveProperty();


            NowUpdating    = new ReactiveProperty <bool>(false);
            LivePlayerType = new ReactiveProperty <Models.Live.LivePlayerType?>();

            CanChangeQuality = new ReactiveProperty <bool>(false);
            RequestQuality   = new ReactiveProperty <string>();
            CurrentQuality   = new ReactiveProperty <string>();

            IsAvailableSuperLowQuality = new ReactiveProperty <bool>(false);
            IsAvailableLowQuality      = new ReactiveProperty <bool>(false);
            IsAvailableNormalQuality   = new ReactiveProperty <bool>(false);
            IsAvailableHighQuality     = new ReactiveProperty <bool>(false);

            ChangeQualityCommand = new DelegateCommand <string>(
                (quality) =>
            {
                NicoLiveVideo.ChangeQualityRequest(quality).ConfigureAwait(false);
                HohoemaApp.UserSettings.PlayerSettings.DefaultLiveQuality = quality;
                HohoemaApp.UserSettings.PlayerSettings.Save().ConfigureAwait(false);
            },
                (quality) => NicoLiveVideo.Qualities.Any(x => x == quality)
                );

            IsVisibleComment = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, true).AddTo(_CompositeDisposable);

            CommentCanvasHeight = new ReactiveProperty <double>(PlayerWindowUIDispatcherScheduler, 0.0).AddTo(_CompositeDisposable);
            CommentDefaultColor = new ReactiveProperty <Color>(PlayerWindowUIDispatcherScheduler, Colors.White).AddTo(_CompositeDisposable);

            CommentOpacity = HohoemaApp.UserSettings.PlayerSettings.ObserveProperty(x => x.CommentOpacity)
                             .Select(x => x.ToOpacity())
                             .ToReadOnlyReactiveProperty(eventScheduler: PlayerWindowUIDispatcherScheduler);


            // post comment
            WritingComment       = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable);
            NowCommentWriting    = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler).AddTo(_CompositeDisposable);
            NowSubmittingComment = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler).AddTo(_CompositeDisposable);

            // TODO: ニコ生での匿名コメント設定
            CommandString   = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable);
            CommandEditerVM = new CommentCommandEditerViewModel(true /* isDefaultAnnonymous */);
            CommandEditerVM.OnCommandChanged += CommandEditerVM_OnCommandChanged;
            CommandEditerVM.ChangeEnableAnonymity(true);
            CommandEditerVM.IsAnonymousComment.Value = true;

            CommandEditerVM_OnCommandChanged();


            CommentSubmitCommand = Observable.CombineLatest(
                WritingComment.Select(x => !string.IsNullOrEmpty(x)),
                NowSubmittingComment.Select(x => !x)
                )
                                   .Select(x => x.All(y => y))
                                   .ToReactiveCommand(PlayerWindowUIDispatcherScheduler)
                                   .AddTo(_CompositeDisposable);

            CommentSubmitCommand.Subscribe(async x =>
            {
                if (NicoLiveVideo != null)
                {
                    NowSubmittingComment.Value = true;
                    await NicoLiveVideo.PostComment(WritingComment.Value, CommandString.Value, LiveElapsedTime);
                }
            });


            // operation command
            PermanentDisplayText = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable);


            // sound
            IsFullScreen = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, false).AddTo(_CompositeDisposable);
            IsFullScreen
            .Subscribe(isFullScreen =>
            {
                var appView = ApplicationView.GetForCurrentView();
                if (isFullScreen)
                {
                    if (!appView.TryEnterFullScreenMode())
                    {
                        IsFullScreen.Value = false;
                    }
                }
                else
                {
                    appView.ExitFullScreenMode();
                }
            })
            .AddTo(_CompositeDisposable);

            IsSmallWindowModeEnable = HohoemaApp.Playlist
                                      .ToReactivePropertyAsSynchronized(x => x.IsPlayerFloatingModeEnable);


            IsAutoHideEnable =
                Observable.CombineLatest(
                    NowPlaying
                    , NowCommentWriting.Select(x => !x)
                    )
                .Select(x => x.All(y => y))
                .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                .AddTo(_CompositeDisposable);

            Suggestion    = new ReactiveProperty <LiveSuggestion>();
            HasSuggestion = Suggestion.Select(x => x != null)
                            .ToReactiveProperty();

            AutoHideDelayTime = HohoemaApp.UserSettings.PlayerSettings
                                .ToReactivePropertyAsSynchronized(x => x.AutoHidePlayerControlUIPreventTime, PlayerWindowUIDispatcherScheduler)
                                .AddTo(_CompositeDisposable);

            IsDisplayControlUI = HohoemaApp.Playlist.ToReactivePropertyAsSynchronized(x => x.IsDisplayPlayerControlUI);


            IsMuted = HohoemaApp.UserSettings.PlayerSettings
                      .ToReactivePropertyAsSynchronized(x => x.IsMute, PlayerWindowUIDispatcherScheduler)
                      .AddTo(_CompositeDisposable);
            IsMuted.Subscribe(isMuted =>
            {
                MediaPlayer.IsMuted = isMuted;
            })
            .AddTo(_CompositeDisposable);

            SoundVolume = HohoemaApp.UserSettings.PlayerSettings
                          .ToReactivePropertyAsSynchronized(x => x.SoundVolume, PlayerWindowUIDispatcherScheduler)
                          .AddTo(_CompositeDisposable);
            SoundVolume.Subscribe(volume =>
            {
                MediaPlayer.Volume = volume;
            })
            .AddTo(_CompositeDisposable);

            CommentUpdateInterval = HohoemaApp.UserSettings.PlayerSettings.ObserveProperty(x => x.CommentRenderingFPS)
                                    .Select(x => TimeSpan.FromSeconds(1.0 / x))
                                    .ToReactiveProperty()
                                    .AddTo(_CompositeDisposable);

            RequestCommentDisplayDuration = HohoemaApp.UserSettings.PlayerSettings
                                            .ObserveProperty(x => x.CommentDisplayDuration)
                                            .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                                            .AddTo(_CompositeDisposable);

            CommentFontScale = HohoemaApp.UserSettings.PlayerSettings
                               .ObserveProperty(x => x.DefaultCommentFontScale)
                               .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                               .AddTo(_CompositeDisposable);


            IsForceLandscape = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, HohoemaApp.UserSettings.PlayerSettings.IsForceLandscape);



            IsStillLoggedInTwitter = new ReactiveProperty <bool>(!TwitterHelper.IsLoggedIn)
                                     .AddTo(_CompositeDisposable);
        }