Exemplo n.º 1
0
        private void SelectMenuItem(BudgetMenuItemViewModel menuItem)
        {
            if (_selectedItemModel == menuItem)
            {
                return;
            }
            if (_selectedItemModel != null)
            {
                _selectedItemModel.IsSelected = false;
            }

            _selectedItemModel            = menuItem;
            _selectedItemModel.IsSelected = true;

            switch (menuItem.MenuItemType)
            {
            case MenuItemTypes.BudgetView:
                var budgetEditor = new BudgetEditorViewModel(BudgetModel);
                _showScreenCallback(budgetEditor);
                break;

            case MenuItemTypes.Account:
                Account account         = menuItem.Payload as Account;
                var     transactionGrid = new TransactionGridViewModel(BudgetModel, account.EntityID);
                _showScreenCallback(transactionGrid);
                break;
            }
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public void TestBudgetEditor()
        {
            var budgetEditor = new BudgetEditorViewModel(TestBudget.BudgetModel);

            budgetEditor.MakeNumberOfMonthsVisible(5);
        }