Beispiel #1
0
 public void MakeNumberOfMonthsVisible(int number)
 {
     if (VisibleMonthViews.Count == number)
     {
         return;
     }
     if (VisibleMonthViews.Count < number)
     {
         DateTime rightMostDate = VisibleMonthViews.Last().BudgetMonthView.Date;
         int      monthsToAdd   = number - VisibleMonthViews.Count;
         for (int i = 0; i < monthsToAdd; i++)
         {
             rightMostDate = rightMostDate.AddMonths(1);
             BudgetMonthViewModel newView = new BudgetMonthViewModel(new BudgetMonthView(_budgetModel, rightMostDate));
             VisibleMonthViews.Add(newView);
         }
     }
     else if (VisibleMonthViews.Count > number)
     {
         int monthsToRemove = VisibleMonthViews.Count - number;
         while (VisibleMonthViews.Count > number)
         {
             BudgetMonthViewModel monthToRemove = VisibleMonthViews[VisibleMonthViews.Count - 1];
             VisibleMonthViews.Remove(monthToRemove);
             monthToRemove.Dispose();
         }
     }
     SetFirstVisibleMonthProperty();
     UpdateMonthSelector();
 }
Beispiel #2
0
        private void InitializeMonthViews()
        {
            VisibleMonthViews = new ObservableCollection <BudgetMonthViewModel>();

            _selectedMonth = new BudgetMonthViewModel(new BudgetMonthView(_budgetModel, DateTime.Today));
            VisibleMonthViews.Add(_selectedMonth);
            SetFirstVisibleMonthProperty();
            UpdateMonthSelector();
        }
Beispiel #3
0
 public MasterCategoryMonthViewModel(BudgetEditorViewModel budgetEditor,
                                     BudgetMonthViewModel budgetMonthViewModel,
                                     MasterCategoryRowViewModel masterCategoryRow,
                                     MasterCategoryMonthView masterCategoryMonthView)
 {
     _budgetEditor           = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor));
     _budgetMonthViewModel   = budgetMonthViewModel ?? throw new ArgumentNullException(nameof(budgetMonthViewModel));
     _masterCategoryRow      = masterCategoryRow ?? throw new ArgumentNullException(nameof(masterCategoryRow));
     MasterCategoryMonthView = masterCategoryMonthView ?? throw new ArgumentNullException(nameof(masterCategoryMonthView));
 }
Beispiel #4
0
 public MasterCategoryMonthViewModel(BudgetEditorViewModel budgetEditor,
                                     BudgetMonthViewModel budgetMonthViewModel,
                                     MasterCategoryRowViewModel masterCategoryRow,
                                     BudgetMonthView budgetMonthView,
                                     string masterCategoryId)
 {
     _budgetEditor         = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor));
     _budgetMonthViewModel = budgetMonthViewModel ?? throw new ArgumentNullException(nameof(budgetMonthViewModel));
     _masterCategoryRow    = masterCategoryRow ?? throw new ArgumentNullException(nameof(masterCategoryRow));
     _budgetMonthView      = budgetMonthView ?? throw new ArgumentNullException(nameof(budgetMonthView));
     _masterCategoryId     = masterCategoryId ?? throw new ArgumentNullException(nameof(masterCategoryId));
     RegisterForCallback();
 }
Beispiel #5
0
        private void SelectMonth(DateTime month)
        {
            if (_selectedMonth.BudgetMonthView.Date == month)
            {
                return;
            }

            int visibleMonthsCount = VisibleMonthViews.Count;
            var desiredMonths      = CalculateDesiredMonths(month, visibleMonthsCount);
            List <BudgetMonthViewModel> monthsToKeep = new List <BudgetMonthViewModel>();

            for (int i = 0; i < desiredMonths.Count; i++)
            {
                var desiredMonth = desiredMonths[i];
                var monthToKeep  = VisibleMonthViews.Where(vm => vm.BudgetMonthView.Date == desiredMonth.desiredMonthDate).SingleOrDefault();
                if (monthToKeep != null)
                {
                    desiredMonth.desiredMonth = monthToKeep;
                    monthsToKeep.Add(monthToKeep);
                }
                else
                {
                    desiredMonth.desiredMonth = new BudgetMonthViewModel(new BudgetMonthView(_budgetModel, desiredMonth.desiredMonthDate));
                }
                desiredMonths[i] = desiredMonth;
            }

            var monthsToDispose = VisibleMonthViews.Where(vm => !monthsToKeep.Contains(vm)).ToList();

            foreach (var monthToDispose in monthsToDispose)
            {
                monthToDispose.Dispose();
            }

            for (int i = 0; i < visibleMonthsCount; i++)
            {
                VisibleMonthViews[i] = desiredMonths[i].desiredMonth;
            }

            _selectedMonth = VisibleMonthViews[0];
            UpdateMonthSelector();
            SetFirstVisibleMonthProperty();
        }
Beispiel #6
0
 public CategoryMonthViewModel(BudgetMonthViewModel budgetMonthViewModel, CategoryRowViewModel categoryRowViewModel, MasterCategoryMonthView masterCategoryMonthView, string categoryId)
 {
     BudgetMonthViewModel = budgetMonthViewModel;
     CategoryRowViewModel = categoryRowViewModel;
     RegisterForCallBack(masterCategoryMonthView, categoryId);
 }
Beispiel #7
0
 public CategoryMonthViewModel(BudgetMonthViewModel budgetMonthViewModel, CategoryRowViewModel categoryRowViewModel, CategoryMonthView monthView)
 {
     BudgetMonthViewModel = budgetMonthViewModel;
     CategoryRowViewModel = categoryRowViewModel;
     CategoryMonthView    = monthView;
 }