示例#1
0
        public override async Task Initialize()
        {
            await base.Initialize();

            var now = timeService.CurrentDateTime;

            initialMonth = new CalendarMonth(now.Year, now.Month).AddMonths(-(MonthsToShow - 1));

            beginningOfWeekObservable = dataSource.User.Current
                                        .Select(user => user.BeginningOfWeek)
                                        .DistinctUntilChanged();

            DayHeadersObservable = beginningOfWeekObservable.Select(mapDayHeaders);

            ReloadObservable = reloadSubject.AsObservable();

            MonthsObservable = beginningOfWeekObservable.CombineLatest(
                timeService.MidnightObservable.StartWith(timeService.CurrentDateTime),
                (beginningOfWeek, today) =>
            {
                var monthIterator = new CalendarMonth(today.Year, today.Month).AddMonths(-(MonthsToShow - 1));
                var months        = new List <ReportsCalendarPageViewModel>();
                for (int i = 0; i < MonthsToShow; i++, monthIterator = monthIterator.Next())
                {
                    months.Add(new ReportsCalendarPageViewModel(monthIterator, beginningOfWeek, today));
                }
                return(months);
            });

            RowsInCurrentMonthObservable = MonthsObservable.CombineLatest(
                CurrentPageObservable.DistinctUntilChanged(),
                (months, page) => months[page].RowCount)
                                           .Select(CommonFunctions.Identity);

            CurrentMonthObservable = monthSubject
                                     .AsObservable()
                                     .StartWith(MonthsToShow - 1)
                                     .Select(convertPageIndexToCalendarMonth)
                                     .Share();

            QuickSelectShortcutsObservable = beginningOfWeekObservable.Select(createQuickSelectShortcuts);

            beginningOfWeek = (await dataSource.User.Current.FirstAsync()).BeginningOfWeek;

            QuickSelectShortcuts = createQuickSelectShortcuts(beginningOfWeek);

            SelectPeriod(reportPeriod);

            isInitialized    = true;
            viewAppearedOnce = false;
        }
        public override async Task Initialize()
        {
            await base.Initialize();

            var now = timeService.CurrentDateTime;

            initialMonth = new CalendarMonth(now.Year, now.Month).AddMonths(-(MonthsToShow - 1));

            beginningOfWeekObservable = dataSource.User.Current
                                        .Select(user => user.BeginningOfWeek)
                                        .DistinctUntilChanged();

            DayHeadersObservable = beginningOfWeekObservable
                                   .Select(mapDayHeaders)
                                   .AsDriver(new List <string>().AsReadOnly(), schedulerProvider);

            ReloadObservable = reloadSubject.AsObservable();

            MonthsObservable = beginningOfWeekObservable.CombineLatest(
                timeService.MidnightObservable.StartWith(timeService.CurrentDateTime),
                (beginningOfWeek, today) =>
            {
                var monthIterator = new CalendarMonth(today.Year, today.Month).AddMonths(-(MonthsToShow - 1));
                var months        = new List <ReportsCalendarPageViewModel>();
                for (int i = 0; i < MonthsToShow; i++, monthIterator = monthIterator.Next())
                {
                    months.Add(new ReportsCalendarPageViewModel(monthIterator, beginningOfWeek, today));
                }
                return(months.ToImmutableList());
            })
                               .AsDriver(ImmutableList <ReportsCalendarPageViewModel> .Empty, schedulerProvider);

            RowsInCurrentMonthObservable = MonthsObservable.CombineLatest(
                CurrentPageObservable.DistinctUntilChanged(),
                (months, page) => months[page].RowCount)
                                           .Select(CommonFunctions.Identity)
                                           .AsDriver(0, schedulerProvider);

            CurrentMonthObservable = monthSubject
                                     .AsObservable()
                                     .StartWith(MonthsToShow - 1)
                                     .Select(convertPageIndexToCalendarMonth)
                                     .Share()
                                     .AsDriver(default, schedulerProvider);