コード例 #1
0
        public CategoryRowViewModel(MasterCategoryRowViewModel masterCategory, Category category, BudgetEditorViewModel budgetEditor)
        {
            InitializeRelayCommands();

            MasterCategory      = masterCategory;
            _category           = category;
            _budgetEditor       = budgetEditor;
            _categoryMonthViews = new TransformingObservableCollection <BudgetMonthViewModel, CategoryMonthViewModel>(
                _budgetEditor.VisibleMonthViews, v =>
            {
                //BudgetMonthView holds it's own copy of the Budget and Categories so you have to match them up based on entityId
                //instead of ReferenceEquals on the instance
                BudgetMonthView view = v.BudgetMonthView;
                MasterCategoryMonthView masterView = view.MasterCategories.Where(mcv => mcv.MasterCategory.EntityID == category.Parent.EntityID).Single();
                var categoryMonthView = masterView.Categories.Where(c => c.Category.EntityID == _category.EntityID).SingleOrDefault();
                if (categoryMonthView != null)
                {
                    return(new CategoryMonthViewModel(v, this, categoryMonthView));
                }
                else
                {
                    return(new CategoryMonthViewModel(v, this, masterView, _category.EntityID));
                }
            },
                cmv =>
            {
                cmv.Dispose();
            });
        }
コード例 #2
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));
 }
コード例 #3
0
 private void CategoryCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.NewItems != null)
     {
         foreach (CategoryMonthView item in e.NewItems)
         {
             if (item.Category.EntityID == _categoryId)
             {
                 CategoryMonthView = item;
                 _masterCategoryMonthView.Categories.CollectionChanged -= CategoryCollectionChanged;
                 _masterCategoryMonthView = null;
                 _categoryId = null;
             }
         }
     }
 }
コード例 #4
0
 private void InitializeMonthViews()
 {
     _masterCategoryMonthViews = new TransformingObservableCollection <BudgetMonthViewModel, MasterCategoryMonthViewModel>(
         _budgetEditor.VisibleMonthViews, v =>
     {
         //BudgetMonthView holds it's own copy of the Budget and Categories so you have to match them up based on entityId
         //instead of ReferenceEquals on the instance
         BudgetMonthView view = v.BudgetMonthView;
         MasterCategoryMonthView masterView = view.MasterCategories.Where(mcv => mcv.MasterCategory.EntityID == _masterCategory.EntityID).SingleOrDefault();
         if (masterView != null)
         {
             return(new MasterCategoryMonthViewModel(_budgetEditor, v, this, masterView));
         }
         else
         {
             return(new MasterCategoryMonthViewModel(_budgetEditor, v, this, view, _masterCategory.EntityID));
         }
     },
         cmv =>
     {
     });
 }
コード例 #5
0
 private void RegisterForCallBack(MasterCategoryMonthView masterCategoryMonthView, string categoryId)
 {
     _masterCategoryMonthView = masterCategoryMonthView;
     _categoryId = categoryId;
     masterCategoryMonthView.Categories.CollectionChanged += CategoryCollectionChanged;
 }
コード例 #6
0
 public CategoryMonthViewModel(BudgetMonthViewModel budgetMonthViewModel, CategoryRowViewModel categoryRowViewModel, MasterCategoryMonthView masterCategoryMonthView, string categoryId)
 {
     BudgetMonthViewModel = budgetMonthViewModel;
     CategoryRowViewModel = categoryRowViewModel;
     RegisterForCallBack(masterCategoryMonthView, categoryId);
 }