コード例 #1
0
        public QueuesViewModel(IParameterViewStackService parameterViewStackService, IQueueService queueService)
            : base(parameterViewStackService)
        {
            _queueService = queueService;

            _queueService
            .Queue
            .Connect()
            .RefCount()
            .Transform(x => new QueuedItemViewModel(x))
            .AutoRefresh(x => x.CurrentQueueTime)
            .Sort(SortExpressionComparer <QueuedItemViewModel> .Descending(x => x.CurrentQueueTime))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _queue)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Subscriptions);

            Observable
            .Interval(TimeSpan.FromSeconds(5))
            .Subscribe(_ => _queueService.GetQueue(Guid.Empty))
            .DisposeWith(Subscriptions);

            InitializeData = ReactiveCommand.CreateFromObservable(ExecuteInitializeData);
        }
コード例 #2
0
        public StoreDetailViewModel(
            IParameterViewStackService parameterViewStackService,
            IPopupViewStackService popupViewStackService,
            IStoreService storeService,
            IQueueService queueService,
            IDialogs dialogs)
            : base(parameterViewStackService)
        {
            _popupViewStackService = popupViewStackService;
            _storeService          = storeService;
            _queueService          = queueService;
            _dialogs = dialogs;


            var getStore =
                ReactiveCommand.CreateFromObservable <Guid, Unit>(ExecuteGetStore);

            this.WhenAnyValue(x => x.StoreId)
            .Where(x => x != Guid.Empty)
            .DistinctUntilChanged()
            .InvokeCommand(getStore)
            .DisposeWith(Subscriptions);

            InitializeData = ReactiveCommand.CreateFromObservable <Guid, Unit>(ExecuteInitializeData);
            Add            = ReactiveCommand.CreateFromObservable(ExecuteAdd);
        }
コード例 #3
0
 public TabViewModel(string tabTitle, string tabIcon, IParameterViewStackService stackService, Func <ViewModelBase> pageCreate)
     : base(stackService)
 {
     TabIcon   = tabIcon;
     TabTitle  = tabTitle;
     ViewModel = pageCreate();
 }
コード例 #4
0
 public TabViewModel(string tabTitle, string tabIcon, IParameterViewStackService stackService, Func <NavigationViewModelBase> pageCreate)
 {
     _pageCreate = pageCreate;
     TabIcon     = tabIcon;
     TabTitle    = tabTitle;
     ViewModel   = _pageCreate();
 }
コード例 #5
0
        private static ViewModelBase CreateMenuItem <TViewModel>(IParameterViewStackService service)
            where TViewModel : ViewModelBase
        {
            var viewmodel = Locator.Current.GetService <TViewModel>();

            viewmodel.SetNavigationService(service);
            return(viewmodel);
        }
コード例 #6
0
 public BottomMenuViewModel(IParameterViewStackService parameterViewStackService)
     : base(parameterViewStackService)
 {
     TabViewModels = new List <Func <IParameterViewStackService, TabViewModel> >
     {
         service => new TabViewModel("Search", "", service, () => CreateMenuItem <StoreSearchViewModel>(service)),
         service => new TabViewModel("Queue", "", service, () => CreateMenuItem <QueuesViewModel>(service)),
         service => new TabViewModel("Me", "", service, () => CreateMenuItem <UserViewModel>(service))
     };
 }
コード例 #7
0
ファイル: UserViewModel.cs プロジェクト: rodhemphill/SocialQ
        public UserViewModel(IParameterViewStackService parameterViewStackService, ISettings settings)
            : base(parameterViewStackService)
        {
            settings
            .WhenAnyValue(x => x.UserName)
            .ToProperty(this, nameof(UserName), out _userName)
            .DisposeWith(Subscriptions);

            SignUp = ReactiveCommand.CreateFromObservable(ExecuteSignUp);
        }
コード例 #8
0
 public MainViewModel(
     IParameterViewStackService parameterViewStackService,
     INotificationManager notificationManager,
     IBlobCache blobCache)
     : base(parameterViewStackService)
 {
     _parameterViewStackService = parameterViewStackService;
     _notificationManager       = notificationManager;
     _blobCache = blobCache;
 }
        public SpeakerDetailViewModel(IParameterViewStackService viewStackService, ISpeakerService speakerService)
        {
            _viewStackService = viewStackService;
            _speakerService   = speakerService;

            this.WhenAnyValue(x => x.Speaker)
            .WhereNotNull()
            .Subscribe(x => ImageSource = ImageSource.FromUri(x.ProfilePicture));

            GetSpeaker = ReactiveCommand.CreateFromTask <Guid>(ExecuteGetSpeaker);
        }
コード例 #10
0
        public StoreSearchViewModel(
            IParameterViewStackService parameterViewStackService,
            IPopupViewStackService popupViewStackService,
            IStoreService storeService,
            INotificationManager notificationManager)
            : base(parameterViewStackService)
        {
            _popupViewStackService = popupViewStackService;
            _storeService          = storeService;
            _notificationManager   = notificationManager;

            _searchFunction.DisposeWith(Subscriptions);

            _storeService
            .Stores
            .Connect()
            .RefCount()
            .Filter(_searchFunction.AsObservable())
            .Transform(x => new StoreCardViewModel(x))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _stores)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Subscriptions);

            _storeService
            .Metadata
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _storeNames)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Subscriptions);

            var isLoading =
                this.WhenAnyObservable(x => x.Search.IsExecuting,
                                       x => x.InitializeData.IsExecuting,
                                       x => x.Details.IsExecuting,
                                       x => x.Category.IsExecuting,
                                       (search, initialize, details, category) =>
                                       search || initialize || details || category);

            isLoading
            .ToProperty(this, nameof(IsLoading), out _isLoading, deferSubscription: true)
            .DisposeWith(Subscriptions);

            var canExecute = isLoading.Select(x => !x).StartWith(true);

            Search         = ReactiveCommand.CreateFromObservable <string, Unit>(ExecuteSearch, canExecute);
            Details        = ReactiveCommand.CreateFromObservable <StoreCardViewModel, Unit>(ExecuteDetails);
            InitializeData = ReactiveCommand.CreateFromObservable(ExecuteInitializeData);
            Category       = ReactiveCommand.CreateFromObservable <string, Unit>(ExecuteCategory, canExecute);
        }
コード例 #11
0
        public NavigationRootViewModel()
        {
            _parameterViewStackService = Locator.Current.GetService <IParameterViewStackService>();

            NavigationItems = new ObservableCollection <NavigationItemViewModel>
            {
                new NavigationItemViewModel {
                    Title = "List View", Icon = ListAlt, IViewFor = typeof(ListOptionsViewModel)
                },
                new NavigationItemViewModel {
                    Title = "Collection View", Icon = LayerGroup, IViewFor = typeof(CollectionOptionsViewModel)
                }
            };

            Navigate = ReactiveCommand.CreateFromObservable <NavigationItemViewModel, Unit>(ExecuteNavigate);
        }
コード例 #12
0
        public DrinkCollectionViewModel()
        {
            _viewStackService = Locator.Current.GetService <IParameterViewStackService>();
            _coffeeService    = Locator.Current.GetService <ICoffeeService>();

            CoffeeDetails = ReactiveCommand.CreateFromObservable <DrinkViewModel, Unit>(ExecuteNavigate).DisposeWith(ViewModelSubscriptions);

            _coffeeService
            .ChangeSet
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .Transform(x => new DrinkViewModel(x.Id, x.Name, x.Species, x.Regions, x.Image))
            // .Sort(SortExpressionComparer<DrinkViewModel>.Ascending(p => p.Name))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _coffeeList)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(ViewModelSubscriptions);
        }
コード例 #13
0
        public SpeakerProfileViewModel(IParameterViewStackService viewStackService, ISpeakerService speakerService)
        {
            _viewStackService = viewStackService;
            _speakerService   = speakerService;

            this.WhenAnyValue(x => x.SpeakerId)
            .Subscribe(id =>
            {
                Observable
                .Return(Unit.Default)
                .SelectMany(async x =>
                {
                    Speaker = await _speakerService.Get(SpeakerId.ToString());
                    return(Unit.Default);
                })
                .Subscribe();
            });
        }
コード例 #14
0
        public CollectionOptionsViewModel()
        {
            _viewStackService = Locator.Current.GetService <IParameterViewStackService>();

            Navigate = ReactiveCommand.CreateFromObservable <CollectionOptionViewModel, Unit>(ExecuteNavigate);

            Items = new ObservableCollection <CollectionOptionViewModel>
            {
                new CollectionOptionViewModel {
                    Option = CollectionOption.DetailNavigation
                },
                new CollectionOptionViewModel {
                    Option = CollectionOption.Search
                },
                new CollectionOptionViewModel {
                    Option = CollectionOption.InfiniteScroll
                }
            };
        }
コード例 #15
0
        public SpeakerListViewModel(IParameterViewStackService viewStackService, ISpeakerService speakerService)
        {
            _viewStackService = viewStackService;
            _speakerService   = speakerService;

            Refresh    = ReactiveCommand.CreateFromTask(ExecuteRefresh);
            ItemTapped = ReactiveCommand.Create <SpeakerItemViewModel, Unit>(item =>
            {
                var profile = new SpeakerDetailViewModel(_viewStackService, new SpeakerServiceMock());
                _viewStackService.PushPage(profile, new NavigationParameter {
                    { "Id", item.SpeakerId.ToString() }
                }).Subscribe();
                return(Unit.Default);
            });

            _isRefreshing =
                this.WhenAnyObservable(x => x.Refresh.IsExecuting)
                .ToProperty(this, x => x.IsRefreshing)
                .DisposeWith(Subscriptions);
        }
コード例 #16
0
        public CoffeeListViewModel(IParameterViewStackService parameterViewStackService, ICoffeeService coffeeService)
        {
            _viewStackService = parameterViewStackService;
            _coffeeService    = coffeeService;

            CoffeeDetails = ReactiveCommand.CreateFromObservable <CoffeeCellViewModel, Unit>(ExecuteNavigate).DisposeWith(ViewModelSubscriptions);

            Refresh = ReactiveCommand.CreateFromTask(ExecuteRefresh).DisposeWith(ViewModelSubscriptions);

            _coffeeService
            .ChangeSet
            .Transform(x => new CoffeeCellViewModel(x.Id, x.Name, x.Species, x.Regions, x.Image))
            .Sort(SortExpressionComparer <CoffeeCellViewModel> .Ascending(p => p.Name))
            .Bind(out _coffeeList)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(ViewModelSubscriptions);

            CoffeeDetails = ReactiveCommand.CreateFromObservable <CoffeeCellViewModel, Unit>(ExecuteNavigate).DisposeWith(ViewModelSubscriptions);
        }
コード例 #17
0
        public SplashViewModel(IParameterViewStackService parameterViewStackService, IAppStartup appStartup)
            : base(parameterViewStackService)
        {
            _appStartup = appStartup;
            Initialize  = ReactiveCommand.CreateFromObservable(ExecuteInitialize);
            Navigate    = ReactiveCommand.CreateFromObservable(ExecuteNavigate);

            var initializing =
                this.WhenAnyObservable(x => x.Initialize.IsExecuting)
                .StartWith(false);

            initializing
            .ToProperty(this, nameof(IsLoading), out _loading)
            .DisposeWith(Subscriptions);

            initializing
            .Zip(initializing.Skip(1), (first, second) => first && !second)
            .Where(x => x)
            .Select(x => Unit.Default)
            .InvokeCommand(Navigate);
        }
コード例 #18
0
        protected BaseViewModel(IParameterViewStackService parameterViewStackService)
        {
            var type = GetType();

            this.Log().Write("View Model Initialization", type, LogLevel.Info);
            Disposable = new CompositeDisposable();
            Id         = type.Name;
            ParameterViewStackService = parameterViewStackService;
            GoBack       = ReactiveCommand.CreateFromObservable(() => ParameterViewStackService.PopPage());
            GoBackModal  = ReactiveCommand.CreateFromObservable(() => ParameterViewStackService.PopModal());
            GoBackToRoot = ReactiveCommand.CreateFromObservable(() => ParameterViewStackService.PopToRootPage());

            GoBack
            .ThrownExceptions
            .Subscribe(x => this.Log().Write(x, nameof(GoBack), LogLevel.Error));
            GoBackModal
            .ThrownExceptions
            .Subscribe(x => this.Log().Write(x, nameof(GoBackModal), LogLevel.Error));
            GoBackToRoot
            .ThrownExceptions
            .Subscribe(x => this.Log().Write(x, nameof(GoBackToRoot), LogLevel.Error));
        }
コード例 #19
0
 public ScheduleViewModel(IParameterViewStackService viewStackService)
 {
     _viewStackService = viewStackService;
 }
コード例 #20
0
 public SignUpViewModel(IParameterViewStackService parameterViewStackService)
     : base(parameterViewStackService)
 {
     Cancel = ReactiveCommand.CreateFromObservable(ExecuteCancel);
 }
コード例 #21
0
 public AgendaViewModel(IParameterViewStackService viewStackService)
 {
     _viewStackService = viewStackService;
 }
コード例 #22
0
 static NavigationExtensions()
 {
     _stackService = Locator.Current.GetService <IParameterViewStackService>();
 }
コード例 #23
0
ファイル: ViewModelBase.cs プロジェクト: rodhemphill/SocialQ
 public void SetNavigationService(IParameterViewStackService viewStackService)
 {
     ViewStackService = viewStackService;
 }
コード例 #24
0
ファイル: ViewModelBase.cs プロジェクト: rodhemphill/SocialQ
 protected ViewModelBase(IParameterViewStackService parameterViewStackService)
 {
     ViewStackService = parameterViewStackService;
 }
コード例 #25
0
 public SponsorListViewModel(IParameterViewStackService viewStackService)
 {
     _viewStackService = viewStackService;
 }