示例#1
0
        private CategoryMonthViewModel FindNextCategoryMonth(BudgetEditorViewModel editorViewModel, CategoryMonthViewModel currentCategoryMonth)
        {
            var budgetMonthViewModel = currentCategoryMonth.BudgetMonthViewModel;
            int index = editorViewModel.VisibleMonthViews.IndexOf(budgetMonthViewModel);
            int count = editorViewModel.VisibleMonthViews.Count;

            int nextMonthIndex;

            if (index + 1 == count)
            {
                nextMonthIndex = 0;
            }
            else
            {
                nextMonthIndex = Math.Min(index + 1, count - 1);
            }
            BudgetMonthViewModel nextMonthViewModel = editorViewModel.VisibleMonthViews[nextMonthIndex];

            var firstMasterCategory = editorViewModel.MasterCategories.First(mc => mc.Categories.Count >= 1);
            var firstCategory       = firstMasterCategory.Categories[0];

            return(firstCategory.CategoryMonthViews.Single(cmv => cmv.BudgetMonthViewModel == nextMonthViewModel));
        }
示例#2
0
        private CategoryMonthViewModel FindPreviousCategoryMonth(BudgetEditorViewModel editorViewModel, CategoryMonthViewModel currentCategoryMonth)
        {
            var budgetMonthViewModel = currentCategoryMonth.BudgetMonthViewModel;
            int index = editorViewModel.VisibleMonthViews.IndexOf(budgetMonthViewModel);
            int count = editorViewModel.VisibleMonthViews.Count;

            int nextMonthIndex;

            if (index - 1 == -1)
            {
                nextMonthIndex = count - 1;
            }
            else
            {
                nextMonthIndex = index - 1;
            }
            BudgetMonthViewModel previousMonthViewModel = editorViewModel.VisibleMonthViews[nextMonthIndex];

            var lastMasterCategory = editorViewModel.MasterCategories.Last(mc => mc.Categories.Count >= 1);
            var lastCategory       = lastMasterCategory.Categories[lastMasterCategory.Categories.Count - 1];

            return(lastCategory.CategoryMonthViews.Single(cmv => cmv.BudgetMonthViewModel == previousMonthViewModel));
        }