/// <summary> /// Constructes the shell view and activates the Dependancy Injection. /// </summary> /// <param name="eventAggregator">Caliburns Event Manager.</param> /// <param name="fileBrowser">Custom Save/Open/Folder FileDialog Manager.</param> public ShellViewModel(IEventAggregator eventAggregator, IFileBrowser fileBrowser, IExceptionLogger exceptionLogger, IWindowManager windowManager) { // Testing only. _windowManager = windowManager; _exceptionLogger = exceptionLogger; _fileBrowser = fileBrowser; _eventAggregator = eventAggregator; _eventAggregator.Subscribe(this); DataViewModel = new DataViewModel(eventAggregator); SubCategoryViewModel = new SubCategoryViewModel(eventAggregator, fileBrowser); NewBudgetViewModel = new NewBudgetViewModel(eventAggregator, fileBrowser); PaystubViewModel = new PaystubViewModel(eventAggregator, fileBrowser, windowManager); InitializeAll(); ActivateItem(NewBudgetViewModel); lastScreenIsNF = true; //DataViewModel.SortCategories(); _eventAggregator.PublishOnUIThread(new UpdateDataListEvent()); #region Testing ONLY: BudgetFileName = "Test ONLY"; TestDataAccesser testData = new TestDataAccesser(2); DataViewModel.IncomeDataList = new BindableCollection <Income>(testData.IncomeList); DataViewModel.ExpenseDataList = new BindableCollection <Expense>(testData.ExpenseList); #endregion }
/// <summary> /// Clears all data from the DataLists and SubCategory Lists. /// </summary> private void ClearData() { DataViewModel.ClearData(); SubCategoryViewModel.ClearData(); Income.ClearData(); Expense.ClearData(); WindowTitle = "Budget Planner"; BudgetFileName = String.Empty; MainFileDirectory = String.Empty; CategoryDirectory = String.Empty; }
/// <summary> /// Not used anymore because of Dependancy Injection. /// </summary> public ShellViewModel() { InitializeAll(); ActivateItem(NewBudgetViewModel); lastScreenIsNF = true; DataViewModel.SortCategories(); //SubCategoryViewModel.SubCatEventManager += this.SubCatEventManager_Event; }
/// <summary> /// Switches to DataView.xaml. Updates the SubCategory Data. /// </summary> public void ViewData() { if (lastScreenIsNF) { _eventAggregator.PublishOnUIThread(new CancelNewEvent()); //CancellingNewBudget?.Invoke(this, new EventArgs()); } Activate_DataView(); DataViewModel.SortCategories(); SubCategoryViewModel.FinishCategories(); DataViewModel.UpdateData(); }
/// <summary> /// Sets up empty data lists. /// </summary> public void InitializeAll() { DataViewModel.Initialize(); SubCategoryViewModel.Initialize(); }