async Task <Entry[]> GetCategoriesEntriesAsync(BudgetCategoriesViewModel vm, bool fullSize) { var context = vm.BudgetCategories; List <Entry> entries = new List <Entry>(); var fltCatExpenseSum = (float)context.Where(c => c.CategoryType == BudgetCategoryType.Expense).Sum(c => c.Amount); var fltCatIncomeSum = (float)context.Where(c => c.CategoryType == BudgetCategoryType.Income).Sum(c => c.Amount); Entry[] _entryArray; if (fullSize) { _entryArray = new Entry[] { EntryUtility.GetEntry(fltCatExpenseSum, SKColors.Red, "Expenses", fltCatExpenseSum.ToString("C")), EntryUtility.GetEntry(fltCatIncomeSum, SKColors.Green, "Income", fltCatIncomeSum.ToString("C")) }; } else { _entryArray = new Entry[] { EntryUtility.GetEntry(fltCatExpenseSum, SKColors.Red, "Expenses"), EntryUtility.GetEntry(fltCatIncomeSum, SKColors.Green, "Income") }; } var _entries = await BuildEntryCollectionAsync(_entryArray); entries.AddRange(_entries.ToList()); return(entries.ToArray()); }
async Task <Entry[]> GetBankAccountEntriesAsync(BankAccountViewModel vm, bool fullSize) { var context = vm; List <Entry> entries = new List <Entry>(); var chartData = vm.AccountRegister; foreach (var model in chartData) { SKColor _color = model.EndingBalance > 0 ? SKColors.Green : SKColors.Red; if (fullSize) { await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color, model.ItemDescription, model.EndingBalance.ToString("C")))); } else { await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color))); } //if (objectType == model.ItemType && model.ItemType == AccountRegisterItemViewModel.AccountItemType.Deposits) //{ // if (fullSize) // { // await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color, model.ItemDescription, model.EndingBalance.ToString("C")))); // } // else // { // await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color))); // } //} //else if (objectType == model.ItemType && model.ItemType == AccountRegisterItemViewModel.AccountItemType.Withdrawals) //{ // if (fullSize) // { // await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color, model.ItemDescription, model.EndingBalance.ToString("C")))); // } // { // await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)model.EndingBalance, _color))); // } //} } return(entries.ToArray()); }
public Chart GetChart(T viewModel, int chartIndex, bool fullSize = false) { Chart _chart = null; List <Entry> entries = new List <Entry>(); List <ChartDataGroup> _chartGroups = new List <ChartDataGroup>(); foreach (var _group in viewModel.ChartDataPack.Charts) { _chartGroups.Add(_group); } ChartDataGroup _selectedGroup = _chartGroups[chartIndex]; switch (_selectedGroup.ChartDisplayType) { case ChartType.Bar: _chart = new BarChart(); break; case ChartType.Line: _chart = new LineChart(); break; case ChartType.Pie: _chart = new DonutChart(); break; } foreach (var item in _selectedGroup.ChartDataItems) { // For now, we'll use a random color SKColor color = ChartUtility.Instance.GetColor(); if (fullSize) { entries.Add(EntryUtility.GetEntry(item.FltValue, color, item.Label, item.ValueLabel)); } else { entries.Add(EntryUtility.GetEntry(item.FltValue, color)); } } _chart.Entries = entries.ToArray(); return(_chart); }
async Task <Entry[]> GetCategoryEntriesAsync(BudgetCategoryViewModel vm, CategoryChartType chartType, bool fullSize) { var context = vm; List <Entry> entries = new List <Entry>(); foreach (var itm in context.BudgetItems) { if (fullSize) { await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)itm.BudgetedAmount, GetColor(), itm.ItemDescription, itm.BudgetedAmount.ToString("C")))); } else { await Task.Run(() => entries.Add(EntryUtility.GetEntry((float)itm.BudgetedAmount))); } } return(entries.ToArray()); }
public async Task <Chart> GetChartAsync(T viewModel, int chartIndex, bool fullSize = false) { Chart _chart = null; List <Entry> entries = new List <Entry>(); List <ChartDataGroup> _chartGroups = new List <ChartDataGroup>(); foreach (var _group in viewModel.ChartDataPack.Charts) { _chartGroups.Add(_group); } ChartDataGroup _selectedGroup = _chartGroups[chartIndex]; switch (_selectedGroup.ChartDisplayType) { case ChartType.Bar: _chart = new BarChart(); break; case ChartType.Line: _chart = new LineChart(); break; case ChartType.Pie: _chart = new DonutChart(); break; } foreach (var item in _selectedGroup.ChartDataItems) { SKColor color = !string.IsNullOrEmpty(item.ColorCode) ? SKColor.Parse(item.ColorCode) : ChartUtility.Instance.GetColor(); if (fullSize) { await Task.Run(() => entries.Add(EntryUtility.GetEntry(item.FltValue, color, item.Label, item.ValueLabel))); } else { await Task.Run(() => entries.Add(EntryUtility.GetEntry(item.FltValue, color))); } } _chart.Entries = entries.ToArray(); return(_chart); }
async Task <Entry[]> GetIncomeEntriesAsync(EasyBudgetStatusViewModel vm, bool fullSize) { var context = vm; List <Entry> entries = new List <Entry>(); var fltIncome = (float)context.vmCategories.BudgetCategories .Where(c => c.CategoryType == BudgetCategoryType.Income) .Sum(c => c.Amount); var fltIncomeActual = (float)context.vmAccounts.BankAccounts .Sum(bk => bk.AccountRegister .Where(ar => ar.ItemType == AccountRegisterItemViewModel.AccountItemType.Deposits) .Sum(d => d.ItemAmount)); Entry[] _entryArray; if (fullSize) { _entryArray = new Entry[] { EntryUtility.GetEntry(fltIncome, SKColors.LightGreen, "Budgeted", fltIncome.ToString("C")), EntryUtility.GetEntry(fltIncomeActual, SKColors.Green, "Actual", fltIncomeActual.ToString("C")) }; } else { _entryArray = new Entry[] { EntryUtility.GetEntry(fltIncome, SKColors.LightGreen, "Budgeted"), EntryUtility.GetEntry(fltIncomeActual, SKColors.Green, "Actual") }; } var _entries = await BuildEntryCollectionAsync(_entryArray); entries.AddRange(_entries); return(entries.ToArray()); }