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; } }
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)); }
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)); }
public void TestBudgetEditor() { var budgetEditor = new BudgetEditorViewModel(TestBudget.BudgetModel); budgetEditor.MakeNumberOfMonthsVisible(5); }