/// <summary> /// Set us up with the complete list of calendars. /// </summary> /// <param name="parent"></param> public CategoryAllPageViewModel(IScreen parent) { HostScreen = parent; // The list of categories. UpdateCategoryList = ReactiveCommand.Create(); ListOfCalendars = new ReactiveList <CategoryConfigInfo>(); UpdateCategoryList .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { ListOfCalendars.Clear(); ListOfCalendars.AddRange(CategoryDB.LoadCategories()); }); UpdateCategoryList.Execute(null); // And setup the category VM ShowCategoryDetails = ReactiveCommand.Create(); var asCategoryInfo = ShowCategoryDetails .Cast <CategoryConfigInfo>(); asCategoryInfo .Select(ci => { var index = ListOfCalendars.IndexOf(ci); var civm = new CategoryConfigViewModel(ci); civm.UpdateToCI .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(newCI => ListOfCalendars[index] = newCI); return(civm); }) .ToProperty(this, x => x.ConfigViewModel, out _categoryConfig, null); asCategoryInfo .Select(ci => new CategoryURIViewModel(ci.MeetingList)) .ToProperty(this, x => x.CategoryFullListVM, out _catgoryFullListVM, null); // Track what we are doing ViewCategory = asCategoryInfo; // Keep the display "clean" until somethign is selected. asCategoryInfo .Select(_ => true) .ToProperty(this, x => x.ValidCategorySelected, out _validCategorySelected, false); }
/// <summary> /// Initialize a new category page view model /// </summary> /// <param name="parent"></param> public CategoryPageViewModel(IScreen parent, IMeetingListRef meetings, IBlobCache cache = null) { HostScreen = parent; CategoryListing = new CategoryURIViewModel(meetings, cache); CategoryConfig = new CategoryConfigViewModel(meetings); }