コード例 #1
0
        private void Start()
        {
            // AsyncReactiveCommand<Unit>と同義
            var asyncReactiveCommand = new AsyncReactiveCommand();

            // ButtonとBind
            asyncReactiveCommand.BindTo(_button);

            // ボタンが押されたら3秒待つ
            asyncReactiveCommand.Subscribe(_ =>
            {
                return(Observable.Timer(TimeSpan.FromSeconds(3)).AsUnitObservable());
            });

            // ボタンが押されたらサーバと通信する
            asyncReactiveCommand.Subscribe(_ =>
            {
                return(FetchAsync("http://api.example.com/status")
                       .ToObservable()
                       .ForEachAsync(x =>
                {
                    _resultText.text = x;     // 結果をUIに表示
                }));
            });
        }
コード例 #2
0
        public static AsyncReactiveCommand CreateAsyncReactiveCommand(Func <Task> func)
        {
            var command = new AsyncReactiveCommand();

            command.Subscribe(func);
            return(command);
        }
コード例 #3
0
        public StageEventListRootPageViewModel(INavigationService navigationService, IFilterGroupingStageEvent eventUsecase)
        {
            _eventUsecase = eventUsecase;

            Title.AddTo(this.Disposable);
            SelectedSegment.AddTo(this.Disposable);
            FavStateObservable.AddTo(this.Disposable);

            SelectedSegment.Subscribe(selectedSegment =>
            {
                _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId);
            }).AddTo(this.Disposable);

            FavButtonClickCommand = new DelegateCommand(() =>
            {
                FavStateObservable.Value = !FavStateObservable.Value;
                _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId);
            });

            IconSource = FavStateObservable.Select((isFavActive) =>
            {
                return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}");
            }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable);

            Plannings = _eventUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable);

            SelectedItemCommand = new AsyncReactiveCommand <IPlanning>();
            SelectedItemCommand.Subscribe(async(item) =>
            {
                await navigationService.NavigateAsync(
                    nameof(PlanningDetailPageViewModel).GetViewNameFromRule(),
                    PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType));
            }).AddTo(this.Disposable);
        }
コード例 #4
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService)
            : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _googleService     = googleService;
            _facebookService   = facebookService;
            _appleService      = appleService;

            _multiFactorService = new MultiFactorService(this);

            Title = "Main Page";

            _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) =>
            {
                _isSignedIn.Value = auth.CurrentUser != null;
            });

            ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand();

            SignUpCommand.Subscribe(SignUp);
            SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword);
            SignInWithGoogleCommand.Subscribe(SignInWithGoogle);
            SignInWithTwitterCommand.Subscribe(() => SignInWithProvider("twitter.com"));
            SignInWithFacebookCommand.Subscribe(SignInWithFacebook);
            SignInWithGitHubCommand.Subscribe(() => SignInWithProvider("github.com"));
            SignInWithYahooCommand.Subscribe(() => SignInWithProvider("yahoo.com"));
            SignInWithMicrosoftCommand.Subscribe(() => SignInWithProvider("microsoft.com"));
            SignInWithAppleCommand.Subscribe(SignInWithApple);
            SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber);
            SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously);
            ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>());
        }
コード例 #5
0
        public AsyncLoginViewModel()
        {
            Tips = new StringReactiveProperty(INPUT_TIPS);

            InputNameCommand = new AsyncReactiveCommand <string>();
            InputNameCommand.Subscribe(InputPassword);
        }
コード例 #6
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAuthService authService)
            : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _authService       = authService;

            Title = "Main Page";

            _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) =>
            {
                _isSignedIn.Value = auth.CurrentUser != null;
            });

            ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand();

            SignUpCommand.Subscribe(SignUp);
            SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword);
            SignInWithGoogleCommand.Subscribe(SignInWithGoogle);
            SignInWithTwitterCommand.Subscribe(SignInWithTwitter);
            SignInWithFacebookCommand.Subscribe(SignInWithFacebook);
            SignInWithGitHubCommand.Subscribe(SignInWithGitHub);
            SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber);
            SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously);
            ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>());
        }
コード例 #7
0
    public void DefaultConstructor()
    {
        var command = new AsyncReactiveCommand();
        var task1   = new TaskCompletionSource <object>();
        var task2   = new TaskCompletionSource <object>();

        command.Subscribe(_ => task1.Task);
        command.Subscribe(_ => task2.Task);

        command.Execute();
        command.CanExecute().IsFalse();
        task1.SetResult(null);
        command.CanExecute().IsFalse();
        task2.SetResult(null);
        command.CanExecute().IsTrue();
    }
コード例 #8
0
        public UpComingMoviePageViewModelBase(INavigationService navigationService, IMovieService movieService, IDialogService dialogService) : base(navigationService, dialogService)
        {
            _movieService = movieService;
            Keyword       = new ReactiveProperty <string>();

            IsExistText.Value  = false;
            SearchMovieCommand = new AsyncReactiveCommand();
            SearchMovieCommand.Subscribe(async() =>
            {
                PullData();
            });
            SelectedItemCommand = new AsyncReactiveCommand <Movie>();
            SelectedItemCommand.Subscribe(async movie =>
            {
                var param = new NavigationParameters
                {
                    { "Id", movie.Id }
                };
                await _navigationService.NavigateAsync(nameof(MovieDetailPage), param);
            });
            ClearSearchCommand = new AsyncReactiveCommand();
            ClearSearchCommand.Subscribe(async() =>
            {
                MovieList     = new List <Movie>();
                Keyword.Value = null;
            });
        }
コード例 #9
0
    public void RemoveSubscription()
    {
        var command = new AsyncReactiveCommand();
        var task1   = new TaskCompletionSource <object>();
        var task2   = new TaskCompletionSource <object>();

        var subscription1 = command.Subscribe(_ => task1.Task);
        var subscription2 = command.Subscribe(_ => task2.Task);

        subscription2.Dispose();

        command.Execute();
        command.CanExecute().IsFalse();
        task1.SetResult(null);
        command.CanExecute().IsTrue();
    }
コード例 #10
0
        public MainPageViewModel(IPageDialogService pageDialog, ToDo todo)
        {
            Title = todo.ToReactivePropertyAsSynchronized(x => x.Title, ignoreValidationErrorValue: true) //ModelのTitleとシンクロして、エラー以降の値はModelにセットしない
                    .SetValidateAttribute(() => this.Title);                                              //Validationセット

            Description = todo.ToReactivePropertyAsSynchronized(x => x.Descriptions, ignoreValidationErrorValue: true)
                          .SetValidateAttribute(() => this.Description);

            Priority = todo.ToReactivePropertyAsSynchronized(
                x => x.Priority,
                x => x.ToString(),                  // M->VMは文字列変換
                x => {
                // VM->Mは数値変換
                int ret;
                int.TryParse(x, out ret);
                return(ret);
            },
                ignoreValidationErrorValue: true
                )
                       .SetValidateAttribute(() => this.Priority);

            TitleError = Title.ObserveErrorChanged
                         .Select(x => x?.Cast <string>()?.FirstOrDefault())     //発生したエラーの最初の値を文字列として取得
                         .ToReadOnlyReactiveProperty();


            DescriptionError = Description.ObserveErrorChanged
                               .Select(x => x?.Cast <string>()?.FirstOrDefault())
                               .ToReadOnlyReactiveProperty();

            PriorityError = Priority.ObserveErrorChanged
                            .Select(x => x?.Cast <string>()?.FirstOrDefault())
                            .ToReadOnlyReactiveProperty();

            DateTo   = todo.ToReactivePropertyAsSynchronized(x => x.DateTo, ignoreValidationErrorValue: true);
            DateFrom = todo.ToReactivePropertyAsSynchronized(x => x.DateFrom, ignoreValidationErrorValue: true);

            CombineDate = new[] {
                DateFrom,
                DateTo
            }.CombineLatest()                              //開始日、終了日をドッキングして
            .ToReactiveProperty()                          //ReactiveProperty化して
            .SetValidateAttribute(() => this.CombineDate); //カスタムルールを適用

            //それをエラーに流す
            DateError = CombineDate.ObserveErrorChanged.Select(x => x?.Cast <string>()?.FirstOrDefault()).ToReadOnlyReactiveProperty();

            OKCommand = new[] {
                Title.ObserveHasErrors,
                Description.ObserveHasErrors,
                Priority.ObserveHasErrors,
                CombineDate.ObserveHasErrors
            }.CombineLatest(x => x.All(y => !y)).ToAsyncReactiveCommand();  //エラーをまとめてCommand化


            OKCommand.Subscribe(async _ => {
                await pageDialog.DisplayAlertAsync("", "Done", "OK");
            });
        }
コード例 #11
0
 public ViewModel()
 {
     Command = new AsyncReactiveCommand();
     Command.Subscribe(async _ =>
     {
         await _model.Add();
     });
 }
コード例 #12
0
ファイル: IDialog.cs プロジェクト: msjoiya/rharbor
 public static IDisposable SubscribeAsDialogCommand(this AsyncReactiveCommand command, IDialog dialog, bool dialogResult, Func <Task <bool> > onExecute)
 {
     return(command.Subscribe(async() => { if (await onExecute())
                                           {
                                               dialog.CloseWindow(dialogResult);
                                           }
                              }));
 }
コード例 #13
0
 public MainPageViewModel(INavigationService navigationService, IDialogService dialogService) : base(navigationService, dialogService)
 {
     TestCommand = new AsyncReactiveCommand();
     TestCommand.Subscribe(async() =>
     {
         await _navigationService.NavigateAsync(nameof(NextPage));
     });
 }
コード例 #14
0
ファイル: WatchItLater.cs プロジェクト: kokkiemouse/Hohoema
        public WatchItLater(
            IScheduler scheduler,
            SubscriptionManager subscriptionManager,
            Models.Provider.LoginUserHistoryProvider loginUserDataProvider,
            UseCase.Playlist.PlaylistAggregateGetter playlistAggregate
            )
        {
            Scheduler             = scheduler;
            SubscriptionManager   = subscriptionManager;
            LoginUserDataProvider = loginUserDataProvider;
            _playlistAggregate    = playlistAggregate;
            Refresh = new AsyncReactiveCommand();
            Refresh.Subscribe(async() => await Update())
            .AddTo(_disposables);

            {
                var localObjectStorageHelper = new LocalObjectStorageHelper();
                IsAutoUpdateEnabled = localObjectStorageHelper.Read(nameof(IsAutoUpdateEnabled), true);
                AutoUpdateInterval  = localObjectStorageHelper.Read(nameof(AutoUpdateInterval), DefaultAutoUpdateInterval);
            }

            this.ObserveProperty(x => x.IsAutoUpdateEnabled)
            .Subscribe(x =>
            {
                var localObjectStorageHelper = new LocalObjectStorageHelper();
                localObjectStorageHelper.Save(nameof(IsAutoUpdateEnabled), IsAutoUpdateEnabled);
            })
            .AddTo(_disposables);

            this.ObserveProperty(x => x.AutoUpdateInterval)
            .Subscribe(x =>
            {
                var localObjectStorageHelper = new LocalObjectStorageHelper();
                localObjectStorageHelper.Save(nameof(AutoUpdateInterval), AutoUpdateInterval);
            })
            .AddTo(_disposables);

            Observable.Merge(new[]
            {
                this.ObserveProperty(x => x.IsAutoUpdateEnabled).ToUnit(),
                this.ObserveProperty(x => x.AutoUpdateInterval).ToUnit()
            })
            .Subscribe(x =>
            {
                if (IsAutoUpdateEnabled)
                {
                    StartOrResetAutoUpdate();
                }
                else
                {
                    StopAutoUpdate();
                }
            })
            .AddTo(_disposables);

            App.Current.Suspending += Current_Suspending;
            App.Current.Resuming   += Current_Resuming;
        }
コード例 #15
0
    public void SubscribeAction()
    {
        var         command      = new AsyncReactiveCommand();
        var         task1        = new TaskCompletionSource <object>();
        var         task2        = new TaskCompletionSource <object>();
        Func <Task> asyncAction1 = () => task1.Task;
        Func <Task> asyncAction2 = () => task2.Task;

        command.Subscribe(asyncAction1);
        command.Subscribe(asyncAction2);

        command.Execute();
        command.CanExecute().IsFalse();
        task1.SetResult(null);
        command.CanExecute().IsFalse();
        task2.SetResult(null);
        command.CanExecute().IsTrue();
    }
コード例 #16
0
ファイル: LeaderboardModel.cs プロジェクト: polats/meta
 public void Start()
 {
     // update user parse task
     RefreshCommand.Subscribe(
         _ =>
     {
         return(null);
     });
 }
コード例 #17
0
        public AppNavigationRootPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator)
        {
            _navigationService = navigationService;
            _eventAggregator   = eventAggregator;

            MasterPageItems = new List <MasterPageListItem> {
                new MasterPageListItem {
                    Title = "ホーム", Icon = iOSIconHome, PageName = nameof(Pages.HomePageViewModel).GetViewNameFromRule()
                },
                new MasterPageListItem {
                    Title = "模擬店/展示", Icon = iOSIconList, PageName = nameof(Pages.PlanningListRootPageViewModel).GetViewNameFromRule()
                },
                new MasterPageListItem {
                    Title = "ステージイベント", Icon = iOSIconStage, PageName = nameof(Pages.StageEventListRootPageViewModel).GetViewNameFromRule()
                },
                new MasterPageListItem {
                    Title = "マップ", Icon = iOSIconMap, PageName = nameof(Pages.FestaMapRootPageViewModel).GetViewNameFromRule()
                },
                new MasterPageListItem {
                    Title = "投票", Icon = iOSIconVote, PageName = nameof(Pages.VoteAnnouncePageViewModel).GetViewNameFromRule()
                },
            };

            SelectedItemCommand = new AsyncReactiveCommand <MasterPageListItem>();
            SelectedItemCommand.Subscribe(async(item) =>
            {
                await NavigationPageWrappedNavigation(item.PageName);
            }).AddTo(this.Disposable);

            ReactiveCurrentTabIndex.Subscribe((value) =>
            {
                switch (value)
                {
                case 0:
                    _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.HomePageViewModel).GetViewNameFromRule()));
                    break;

                case 1:
                    _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.PlanningListRootPageViewModel).GetViewNameFromRule()));
                    break;

                case 3:
                    _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.FestaMapRootPageViewModel).GetViewNameFromRule()));
                    break;

                case 4:
                    _eventAggregator.GetEvent <TabbedPageOpendEvent>().Publish(new TabbedPageOpendEventArgs(nameof(Pages.VoteAnnouncePageViewModel).GetViewNameFromRule()));
                    break;

                default:
                    break;
                }
            }).AddTo(this.Disposable);

            ReactiveCurrentTabIndex.AddTo(this.Disposable);
        }
コード例 #18
0
    private async UniTaskVoid Start()
    {
        var ap = new AsyncReactiveCommand <string>(_isEnabled);

        WaitCommandAsync(ap).Forget();

        ap.Subscribe(_ => { return(Observable.Timer(TimeSpan.FromSeconds(2)).AsUnitObservable()); });

        Observable.Timer(TimeSpan.FromSeconds(5))
        .Subscribe(_ => ap.Execute("aaa"));
    }
コード例 #19
0
        public DownloadViewModel(ApplicationContext applicationContext, IFormatSelectionViewModelFactory factory, IVideoDownloadService videoDownloadService, IApplicationService applicationService)
        {
            this.applicationContext   = applicationContext;
            this.factory              = factory;
            this.videoDownloadService = videoDownloadService;
            this.applicationService   = applicationService;

            VideoUrl = applicationContext.ToReactivePropertyAsSynchronized(x => x.VideoUrl);

            SelectFormatCommand = new AsyncReactiveCommand().DisposeWith(this);
            SelectFormatCommand.Subscribe(x => OpenVideoFormatSelectionAsync()).DisposeWith(this);
        }
        public SignInWithEmailAndPasswordPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService)
        {
            _pageDialogService = pageDialogService;

            Title = "Sign In ";

            SignInCommand = new[] {
                Email.Select(s => string.IsNullOrEmpty(s)),
                Password.Select(s => string.IsNullOrEmpty(s))
            }.CombineLatest(x => x.All(y => !y))
            .ToAsyncReactiveCommand();

            SignInCommand.Subscribe(async() =>
            {
                try
                {
                    var result = await CrossFirebaseAuth.Current
                                 .Instance
                                 .SignInWithEmailAndPasswordAsync(Email.Value, Password.Value);

                    await NavigationService.GoBackAsync(result.User);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);

                    await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK");
                }
            });

            ResetPasswordCommand = new[] {
                Email.Select(s => string.IsNullOrEmpty(s)),
            }.CombineLatest(x => x.All(y => !y))
            .ToAsyncReactiveCommand();

            ResetPasswordCommand.Subscribe(async() =>
            {
                try
                {
                    await CrossFirebaseAuth.Current
                    .Instance
                    .SendPasswordResetEmailAsync(Email.Value);

                    await _pageDialogService.DisplayAlertAsync(null, "Email has been sent.", "OK");
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);

                    await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK");
                }
            });
        }
コード例 #21
0
        public SignupPageViewModel(INavigationService navigationService, ISignupService signupService, IPageDialogService pageDialogService) : base(navigationService)
        {
            _signupService     = signupService;
            _pageDialogService = pageDialogService;

            Title = "サインアップ";

            Email    = _signupService.Email;
            Name     = _signupService.Name;
            Password = _signupService.Password;

            _signupService.Image.Value = "user.png";

            _signupService.SignupCompletedNotifier
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ =>
            {
                var navigation = NavigationFactory.Create <MainPageViewModel>()
                                 .Add(NavigationNameProvider.DefaultNavigationPageName)
                                 .Add <HomePageViewModel>();
                return(NavigateAsync(navigation, noHistory: true));
            })
            .Subscribe()
            .AddTo(_disposables);

            _signupService.SignupErrorNotifier
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ => _pageDialogService.DisplayAlertAsync("エラー", "サインアップに失敗しました", "OK"))
            .AddTo(_disposables);

            _signupService.IsSigningUp
            .Skip(1)
            .Where(b => b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => NavigateAsync <LoadingPageViewModel>())
            .Subscribe()
            .AddTo(_disposables);

            _signupService.IsSigningUp
            .Skip(1)
            .Where(b => !b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => GoBackAsync())
            .Subscribe()
            .AddTo(_disposables);

            SignupCommand = _signupService.CanSignup
                            .ToAsyncReactiveCommand()
                            .AddTo(_disposables);

            SignupCommand.Subscribe(async() => await _signupService.Signup());
        }
        public SignInWithPhoneNumberPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService)
        {
            Title = "Phone Numbe";

            _pageDialogService = pageDialogService;

            SignInCommand = PhoneNumber.Select(s => !string.IsNullOrEmpty(s)).ToAsyncReactiveCommand();

            SignInCommand.Subscribe(async() =>
            {
                try
                {
                    PhoneNumberVerificationResult verificationResult;

                    if (_multiFactorSession != null)
                    {
                        verificationResult = await CrossFirebaseAuth.Current.PhoneAuthProvider
                                             .VerifyPhoneNumberAsync(PhoneNumber.Value, _multiFactorSession);
                    }
                    else
                    {
                        verificationResult = await CrossFirebaseAuth.Current.PhoneAuthProvider
                                             .VerifyPhoneNumberAsync(PhoneNumber.Value);
                    }

                    if (verificationResult.Credential != null)
                    {
                        await NavigationService.GoBackAsync(verificationResult.Credential);
                    }
                    else
                    {
                        var verificationCode = await NavigationService.NavigateAsync <VerificationCodePageViewModel, string>();

                        if (verificationCode != null)
                        {
                            var credential = CrossFirebaseAuth.Current.PhoneAuthProvider
                                             .GetCredential(verificationResult.VerificationId, verificationCode);

                            await Task.Delay(TimeSpan.FromMilliseconds(1));

                            await NavigationService.GoBackAsync(credential);
                        }
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);

                    await _pageDialogService.DisplayAlertAsync("Failure", e.Message, "OK");
                }
            });
        }
コード例 #23
0
        public PlanningDetailPageViewModel(INavigationService navigationService, IShowPlanningDetail showDetail, IOpenWebPageService openWeb, IAnalyticsService analyticsService)
        {
            _showDetail        = showDetail;
            _navigationService = navigationService;
            _webPageService    = openWeb;

            IsFavorited = showDetail.IsFavorited;

            ToggleFavorited = new AsyncReactiveCommand();
            ToggleFavorited.Subscribe(async(_) =>
            {
                var next = !IsFavorited.Value;
                await _showDetail.TogglePlanningFavoritedState(!IsFavorited.Value);
                if (next)
                {
                    switch (DetailModel.Value.PlanningType)
                    {
                    case PlanningTypeEnum.EXHIBITION:
                        await analyticsService.SendFavoritedExhibition(DetailModel.Value.Id, DetailModel.Value.Title);
                        break;

                    case PlanningTypeEnum.STAGE:
                        await analyticsService.SendFavoritedStage(DetailModel.Value.Id, DetailModel.Value.Title);
                        break;

                    case PlanningTypeEnum.STALL:
                        await analyticsService.SendFavoritedStall(DetailModel.Value.Id, DetailModel.Value.Title);
                        break;
                    }
                }
            }).AddTo(this.Disposable);

            IconSource = IsFavorited
                         .Select((isFav) => $@"ion_ios_heart{(isFav ? "" : "_outline")}")
                         .ToReadOnlyReactiveProperty($@"ion_ios_heart{(IsFavorited.Value ? "" : "_outline")}")
                         .AddTo(this.Disposable);

            OpenMapCommand = new AsyncReactiveCommand();
            OpenMapCommand.Subscribe(async(_) =>
            {
                await _navigationService.NavigateAsync("NavigationPage/FestaMapRootPage",
                                                       FestaMapRootPageViewModel.GetNavigationParameter(DetailModel.Value.Id, DetailModel.Value.PlanningType), true);
            }).AddTo(this.Disposable);

            OpenUriCommand = new DelegateCommand <string>((uri) =>
            {
                _webPageService.OpenUri(uri);
            });

            DetailModel.AddTo(this.Disposable);
        }
コード例 #24
0
        public DetailFloorPageViewModel(INavigationService navigationService, IRepository <MyGroupHeader> repository)
        {
            _navigationService = navigationService;
            _repository        = repository;

            CloseButtonClickCommand = new AsyncReactiveCommand();
            CloseButtonClickCommand.Subscribe(async() =>
            {
                await _navigationService.GoBackAsync(null, true);
            }).AddTo(this.Disposable);

            Title.AddTo(this.Disposable);
            ImageSource.AddTo(this.Disposable);
        }
コード例 #25
0
        public ClosableInternalWebViewPageViewModel(INavigationService navigationService, IRepository <Announcement> announceRep)
        {
            _navigationService = navigationService;
            _repository        = announceRep;

            CloseButtonClickCommand = new AsyncReactiveCommand();
            CloseButtonClickCommand.Subscribe(async() =>
            {
                await _navigationService.GoBackAsync(null, true);
            }).AddTo(this.Disposable);

            Title.AddTo(this.Disposable);
            Content.AddTo(this.Disposable);
        }
コード例 #26
0
        protected EmailLoginPageViewModel(INavigationService navigationService, IEmailLoginService emailLoginService, IPageDialogService pageDialogService) : base(navigationService)
        {
            _emailLoginService = emailLoginService;
            _pageDialogService = pageDialogService;

            Title = "ログイン";

            Email    = _emailLoginService.Email;
            Password = _emailLoginService.Password;

            _emailLoginService.LoginCompletedNotifier
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ =>
            {
                var navigation = NavigationFactory.Create <MainPageViewModel>()
                                 .Add(NavigationNameProvider.DefaultNavigationPageName)
                                 .Add <HomePageViewModel>();
                return(NavigateAsync(navigation, noHistory: true));
            })
            .Subscribe()
            .AddTo(_disposables);

            _emailLoginService.LoginErrorNotifier
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ => _pageDialogService.DisplayAlertAsync("エラー", "ログインに失敗しました", "OK"))
            .AddTo(_disposables);

            _emailLoginService.IsLoggingIn
            .Skip(1)
            .Where(b => b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => NavigateAsync <LoadingPageViewModel>())
            .Subscribe()
            .AddTo(_disposables);

            _emailLoginService.IsLoggingIn
            .Skip(1)
            .Where(b => !b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => GoBackAsync())
            .Subscribe()
            .AddTo(_disposables);

            LoginCommand = _emailLoginService.CanLogin
                           .ToAsyncReactiveCommand()
                           .AddTo(_disposables);

            LoginCommand.Subscribe(async() => await _emailLoginService.Login());
        }
コード例 #27
0
        public Conv()
        {
            IsDrag = new ReactiveProperty <bool>(true).AddTo(Disposable);

            IsConvertingShare = new ReactiveProperty <bool>(true).AddTo(Disposable);

            ButtonStart = new AsyncReactiveCommand().AddTo(Disposable);
            ButtonStart = IsConvertingShare.ToAsyncReactiveCommand();
            ButtonStart.Subscribe(async _ =>
            {
                await Task.Run(() =>
                {
                    using (var Pdf = new iTextSharp())
                    {
                        Pdf.Output = SaveFile(Path.GetFileName(LastInput), Path.GetDirectoryName(LastInput));

                        if (Pdf.Output == string.Empty)
                        {
                            return;
                        }

                        Pdf.Open();

                        foreach (var dp in DataPieces.OrderBy(x => x.page.Value))
                        {
                            switch (dp.fork)
                            {
                            case DataPiece.Fork.Bitmap:
                                Pdf.AddToPdf(dp.path);
                                break;

                            case DataPiece.Fork.Zip:
                                Pdf.AddToPdf(dp.byteData);
                                break;
                            }
                        }
                    }
                });

                MessageBox.Show("完了");
            });

            ButtonRemoveAll = new AsyncReactiveCommand().AddTo(Disposable);
            ButtonRemoveAll = IsConvertingShare.ToAsyncReactiveCommand();
            ButtonRemoveAll.Subscribe(async _ =>
            {
                DataPieces.Clear();
            });
        }
コード例 #28
0
        /// <summary>
        /// Initialize Instance.
        /// </summary>
        /// <param name="editExpense"></param>
        public ReceiptPageViewModel(IEditExpense editExpense)
        {
            _editExpense = editExpense;

            Receipt = _editExpense.ObserveProperty(x => x.Receipt)
                      .Where(x => x != null)
                      .Select(x => ImageSource.FromStream(x.GetStream))
                      .ToReadOnlyReactiveProperty().AddTo(Disposable);

            PickPhotoAsyncCommand = _editExpense.ObserveProperty(m => m.IsPickPhotoSupported).ToAsyncReactiveCommand().AddTo(Disposable);
            PickPhotoAsyncCommand.Subscribe(async _ => await _editExpense.PickPhotoAsync());

            TakePhotoAsyncCommand = _editExpense.ObserveProperty(m => m.IsTakePhotoSupported).ToAsyncReactiveCommand().AddTo(Disposable);
            TakePhotoAsyncCommand.Subscribe(async _ => await _editExpense.TakePhotoAsync());
        }
コード例 #29
0
        public MovieDetailPageViewModel(INavigationService navigationService, MovieService movieService, IDialogService dialogService, IGenerateCodeHelpers generateCode) : base(navigationService, dialogService)
        {
            _movieService = movieService;
            _generateCode = generateCode;

            BookTicketCommand = new AsyncReactiveCommand();
            BookTicketCommand.Subscribe(async() =>
            {
                string verifierId = _generateCode.SetMovieBookingVerifier();
                var param         = new NavigationParameters
                {
                    { "VerifierId", verifierId }
                };
                await _navigationService.NavigateAsync(nameof(GenerateMovieQRCodePage), param);
            });
        }
コード例 #30
0
        public MainPageViewModel(IChatClient chatClient)
        {
            _chatClient = chatClient;

            SendMessageCommand = Text.Select(s => !string.IsNullOrEmpty(s)).ToAsyncReactiveCommand();
            SendMessageCommand.Subscribe(async() =>
            {
                var text   = Text.Value;
                Text.Value = null;
                await _chatClient.CreateMessageAsync("0", text, UserId);
            });

            _chatClient.ObserveMessageCreated("0")
            .Subscribe((message) => Messages.Add(message))
            .AddTo(_disposable);
        }
コード例 #31
0
        public void RemoveSubscription()
        {
            var command = new AsyncReactiveCommand();
            var task1 = new TaskCompletionSource<object>();
            var task2 = new TaskCompletionSource<object>();

            var subscription1 = command.Subscribe(_ => task1.Task);
            var subscription2 = command.Subscribe(_ => task2.Task);

            subscription2.Dispose();

            command.Execute();
            command.CanExecute().IsFalse();
            task1.SetResult(null);
            command.CanExecute().IsTrue();
        }
コード例 #32
0
        public void DefaultConstructor()
        {
            var command = new AsyncReactiveCommand();
            var task1 = new TaskCompletionSource<object>();
            var task2 = new TaskCompletionSource<object>();

            command.Subscribe(_ => task1.Task);
            command.Subscribe(_ => task2.Task);

            command.Execute();
            command.CanExecute().IsFalse();
            task1.SetResult(null);
            command.CanExecute().IsFalse();
            task2.SetResult(null);
            command.CanExecute().IsTrue();
        }