Ejemplo n.º 1
0
        private async Task LoadAsync()
        {
            if (parameter.ViewType != null)
            {
                ViewModel.ViewType = parameter.ViewType.Value;
            }
            else if (userPreferences.TryLoad("Summary.ViewTypeDescriptor", out SummaryViewTypeDescriptor viewTypeDescriptor))
            {
                ViewModel.ViewType = viewTypeDescriptor.Type;
            }
            else
            {
                ViewModel.ViewType = SummaryViewType.BarGraph;
            }

            switch (parameter.PeriodType)
            {
            case SummaryPeriodType.Month:
                await LoadMonthViewAsync(ViewModel, parameter.Month);

                break;

            case SummaryPeriodType.Year:
                await LoadYearViewAsync(ViewModel, parameter.Year);

                break;

            default:
                throw Ensure.Exception.NotSupported(parameter.PeriodType.ToString());
            }

            if (parameter.SortDescriptor != null)
            {
                ViewModel.SortDescriptor = parameter.SortDescriptor;
            }
            else if (userPreferences.TryLoad("Summary.SortDescriptor", out SortDescriptor <SummarySortType> sortDescriptor))
            {
                ViewModel.SortDescriptor = sortDescriptor;
            }
            else
            {
                ViewModel.SortDescriptor = new SortDescriptor <SummarySortType>(SummarySortType.ByCategory, SortDirection.Ascending);
            }

            ViewModel.PropertyChanged += OnViewModelChanged;
            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            OverviewParameter parameter = (OverviewParameter)e.Parameter;

            string categoryName = parameter.CategoryKey.IsEmpty
                ? "All"
                : await queryDispatcher.QueryAsync(new GetCategoryName(parameter.CategoryKey));

            categoryKey = parameter.CategoryKey;
            object period = null;

            if (parameter.Month != null)
            {
                month  = parameter.Month;
                period = parameter.Month;
            }

            if (parameter.Year != null)
            {
                year   = parameter.Year;
                period = parameter.Year;
            }

            ViewModel         = new OverviewViewModel(navigator, parameter.CategoryKey, categoryName, period);
            ViewModel.Reload += OnViewModelReload;

            handlers.Add(eventHandlers.AddUiThread <OutcomeCreated>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeAmountChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeDescriptionChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeWhenChanged>(ViewModel, Dispatcher));

            if (userPreferences.TryLoad("Overview.SortDescriptor", out SortDescriptor <OverviewSortType> sortDescriptor))
            {
                SortDescriptor = sortDescriptor;
            }
            else
            {
                SortDescriptor = new SortDescriptor <OverviewSortType>(OverviewSortType.ByDate, SortDirection.Ascending);
            }

            await ReloadAsync();

            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }