public BudgetMonthView(BudgetModel model, DateTime date) { _model = model; Date = date.FirstDayOfMonth(); _internalBudget = _model.GetBudget(); _internalBudget.MasterCategories.LoadCollection(); _lastDayOfMonth = Date.LastDayOfMonth(); _incomeCategory = _internalBudget.IncomeCategories.GetIncomeCategory(Date); _masterCategories = new TransformingObservableCollection <MasterCategory, MasterCategoryMonthView>( _internalBudget.MasterCategories, mc => { return(new MasterCategoryMonthView(mc, Date)); }, mcv => { mcv.Dispose(); }); _cache = _model.BudgetViewCache; _cache.CacheUpdated += Cache_CacheUpdated; RefreshValues(); }
public void MountBudget(BudgetModel budgetModel) { //Set thread culture before updating the Budget so when bindings refresh the appropriate culture //is used for display. var budget = budgetModel.GetBudget(); try { if (!string.IsNullOrWhiteSpace(budget.CurrencyCulture)) { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(budget.CurrencyCulture); } } catch (Exception) { } BudgetModel = budgetModel; this.Header = $"OpenBudget - {budget.Name}"; }
public BudgetEditorViewModel(BudgetModel budgetModel) { _budgetModel = budgetModel; InitializeRelayCommands(); _addMasterCategoryEditor = new AddMasterCategoryViewModel(this); _budget = _budgetModel.GetBudget(); _budget.MasterCategories.LoadCollection(); _monthSelector = new MonthSelectorViewModel(); _monthSelector.OnMonthSelected += MonthSelector_OnMonthSelected; InitializeMonthViews(); _masterCategories = new TransformingObservableCollection <MasterCategory, MasterCategoryRowViewModel>( _budget.MasterCategories, (mc) => { return(new MasterCategoryRowViewModel(mc, this)); }, mcvm => { mcvm.Dispose(); }); _masterCategories.Sort(mcr => mcr.MasterCategory.SortOrder); }
private void OpenBudget() { var budgetPath = _budgetLoader.GetBudgetOpenPath(); if (budgetPath == null) { return; } ValidBudgetCheck validBudgetCheck = _budgetLoader.IsBudgetValid(budgetPath); if (!validBudgetCheck.IsValid) { _dialogService.ShowError(validBudgetCheck.Error); return; } try { BudgetModel budgetModel = _budgetLoader.LoadBudget(budgetPath); Budget budget = budgetModel.GetBudget(); BudgetStub stub = new BudgetStub() { BudgetName = budget.Name, BudgetPath = budgetPath, LastEdited = DateTime.Now }; var deviceSettings = _settingsProvider.Get <Device>(); deviceSettings.AddRecentBudgetToTop(stub); deviceSettings.Save(); _mainViewModel.MountBudget(budgetModel); _navigationService.NavigateTo <MainBudgetViewModel>(); } catch (Exception) { _dialogService.ShowError($"There was an error opening the budget {budgetPath}. It may be corrupt."); } }
public void ReloadBudget() { BudgetModel = BudgetModel.Load(DeviceID, BudgetStore); Budget = BudgetModel.GetBudget(); }