public FDSelectItemVCSource(SearchVM container) { _container = container; _container.PropertyChanged += (sender, e) => { if (e.PropertyName == "Results") { if (String.IsNullOrEmpty(_container.Query)) { Collection = _emptyVM.ItemList; } else { Collection = _container.Results; } } }; #if !DEBUG1 #endif _emptyVM = new PeriodVM(DateTime.Now.Date, container.Period); _emptyVM.PropertyChanged += (sender, e) => { if (e.PropertyName == "ItemList") { Collection = _emptyVM.ItemList; } }; _emptyVM.StartRequery(); Collection = _emptyVM.ItemList; }
public PeriodView() { InitializeComponent(); #if DEBUG DataContext = new PeriodVM(DateTime.Now.Date, Period.Breakfast); #endif }
public SearchResultRecyclerAdapter(Context context, SearchVM container, SRCType type) : base() { _context = context; _container = container; _container.PropertyChanged += (sender, e) => { if (e.PropertyName == "Results") { if (String.IsNullOrEmpty(_container.Query)) { Collection = _emptyVM.ItemList; } else { Collection = _container.Results; } } }; #if !DEBUG1 #endif _emptyVM = new PeriodVM(DateTime.Now.Date, container.Period); _emptyVM.PropertyChanged += (sender, e) => { if (e.PropertyName == "ItemList") { Collection = _emptyVM.ItemList; } }; _emptyVM.StartRequery(); _type = type; Collection = _emptyVM.ItemList; }
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { PeriodVM periodVM = (((Pivot.SelectedItem as PivotItem).Content as PeriodView).DataContext as PeriodVM); Navigate.selectedPeriod = periodVM.Period; periodVM.StartRequery(); } catch (Exception ex) { LittleWatson.ReportException(ex); } }
protected override void OnNavigatedLayoutUpdated() { MessageCenter.AskForReviewIfAppropriate(); try { SyncDayTotal(); PeriodVM periodVM = (((Pivot.SelectedItem as PivotItem).Content as PeriodView).DataContext as PeriodVM); periodVM.StartRequery(); } catch (Exception ex) { LittleWatson.ReportException(ex); } }
public PeriodListAdapter(Context context, PeriodVM vm) { this.vm = vm; _context = context; vm.EntryList.CollectionChanged += ItemList_CollectionChanged; entrylist = vm.EntryList; vm.ItemList.CollectionChanged += ItemList_CollectionChanged; itemlist = vm.ItemList; vm.PropertyChanged += (sender, e) => { if (e.PropertyName == "EntryList") { if (entrylist != null) { entrylist.CollectionChanged -= ItemList_CollectionChanged; } entrylist = vm.EntryList; entrylist.CollectionChanged += ItemList_CollectionChanged; } if (e.PropertyName == "ItemList") { if (itemlist != null) { itemlist.CollectionChanged -= ItemList_CollectionChanged; } itemlist = vm.ItemList; itemlist.CollectionChanged += ItemList_CollectionChanged; } SessionLog.Debug(string.Format("PropertyChanged: {0} - {1}", vm.Period, e.PropertyName)); this.NotifyDataSetChanged(); }; }
public PeriodView(PeriodVM vm) { InitializeComponent(); ViewModel = vm; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle bundle = this.Arguments; DateTime date = Arguments.GetString("date").ToDateTime(); Period = (Period)Enum.Parse(typeof(Period), Arguments.GetString("period")); view = inflater.Inflate(Resource.Layout.fragment_today_card, container, false); vm = new PeriodVM(date, Period, true); var binding = DataContext <PeriodVM> .FromView(view); binding.VM = vm; if (binding.Bindings.Count == 0) { binding.Add(Resource.Id.layout_time_calories, x => x.TimeOrTotalVisibility); binding.Add(Resource.Id.text_totalCalories1, x => x.TotalVisibility); binding.Add(Resource.Id.text_totalCalories2, x => x.TotalVisibility); binding.Add(Resource.Id.text_totalCalories1, x => x.TotalText); binding.Add(Resource.Id.text_totalCalories2, x => x.TotalValue); binding.Add(Resource.Id.button_pick_time, x => x.Time); binding.Add(Resource.Id.button_pick_time, x => x.TimeVisibility); binding.Add(Resource.Id.button_pick_time, (x) => { DateTime current; if (!DateTime.TryParse(x.Time, out current)) { current = DateTime.Now; } var tpd = new Android.App.TimePickerDialog(Activity, (s, e) => { x.Time = DateTime.Now.SetTime(e.HourOfDay, e.Minute, 0).ToShortTimeString(); } , current.Hour, current.Minute, true); tpd.Show(); }); binding.Add(Resource.Id.editText_Notes, x => x.Note); binding.Add(Resource.Id.layout_notes, x => x.NoteVisibility); binding.Add(Resource.Id.btn_delete, x => { x.Note = null; }); } recycler = view.FindViewById <RecyclerView>(Resource.Id.recycler); editText = view.FindViewById <EditText>(Resource.Id.editText_Notes); advertisement = view.FindViewById <LinearLayout>(Resource.Id.advertisement); linearLayoutTimeCalories = view.FindViewById <LinearLayout>(Resource.Id.layout_time_calories); editNotes = view.FindViewById <LinearLayout>(Resource.Id.inputNotes); ImageView cross = view.FindViewById <ImageView>(Resource.Id.btn_delete); textTotalCalories = view.FindViewById <TextView>(Resource.Id.text_totalCalories); buttonSetTime = view.FindViewById <Button>(Resource.Id.button_pick_time); textNotes = view.FindViewById <TextView>(Resource.Id.text_today_notes); layoutNotesSection = view.FindViewById <LinearLayout>(Resource.Id.layout_note_section); emptyScreenImage = view.FindViewById <ImageView>(Resource.Id.empty_screen); getStarted = view.FindViewById <TextView>(Resource.Id.get_started); getStartedText = view.FindViewById <TextView>(Resource.Id.get_started_text); text_totalCalories2 = view.FindViewById <TextView>(Resource.Id.text_totalCalories2); UpdateEmptyVisibility(); cross.Click += async delegate { Android.Views.InputMethods.InputMethodManager inputManager = (Android.Views.InputMethods.InputMethodManager)inflater.Context.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(cross.WindowToken, 0); }; setupRecycler(); this.HasOptionsMenu = true; #if DEBUG AndroidDebug.SetViewBorders(view); #endif return(view); }
public async Task <IActionResult> Stat(PeriodVM period) { var user = await _userManager.GetUserAsync(HttpContext.User); if (user == null) { return(RedirectToAction("Error")); } ViewData["Name"] = user.RealName ?? user.UserName; var spendings = _dbContext.GetUserPurchases(user); if (spendings.Any()) { //filter by period if (period != null && period.IsActive) { spendings = spendings.WhereDateBetween(period.Start, period.End); } else { period.Start = spendings.Min(x => x.Date); period.End = DateTime.Now; } //calc stat model var totalSpend = spendings.Sum(x => x.Value); var calcStat = spendings .GroupBy(x => x.Category) .ToDictionary(k => k.Key, e => { var summ = e.Sum(c => c.Value); return(new StatVM.CatStat { Count = e.Count(), Summ = summ, HistPerc = ((summ + 0.0) / totalSpend * 100).ToString().Replace(',', '.') }); }).OrderByDescending(o => o.Value.Summ); return(View( new StatVM { Name = user.UserName, TotalPurchases = spendings.Count(), TotalSpend = spendings.Sum(x => x.Value), PurchasesByCategory = calcStat, Period = period })); } else { return(View( new StatVM { Name = user.UserName, TotalPurchases = 0, TotalSpend = 0, PurchasesByCategory = null, Period = period })); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { try { DateTime date = DateTime.Parse(Arguments.GetString("date")); Period period = (Period)Enum.Parse(typeof(Period), Arguments.GetString("period")); vm = new PeriodVM(date, period); //View view = inflater.Inflate(Resource.Layout.PeriodView, container, false); View view = inflater.Inflate(Resource.Layout.PeriodView2, container, false); var binding = DataContext <PeriodVM> .FromView(view); binding.VM = vm; if (binding.Bindings.Count == 0) { binding.Add(Resource.Id.button2, (x) => { //Com.Example.Testlib.Adapters.Xamarin.Instance = new XamarinCommunicator(); //Intent intent = new Intent (Activity, typeof(Com.Example.Testlib.Adapters.MainActivity)); Intent intent = new Intent(Activity, typeof(MainActivity)); StartActivity(intent); //Navigate.selectedPeriod = vm.Period; //Navigate.ToSearchPage (null); }); } var list = view.FindViewById <ExpandableListView> (Resource.Id.periodListView); //list.AddFooterView(new Button(container.Context)); list.SetGroupIndicator(null); pda = new PeriodListAdapter(container.Context, vm); list.SetAdapter(pda); list.ExpandGroup(0); list.ExpandGroup(1); list.ExpandGroup(2); list.GroupCollapse += (object sender, ExpandableListView.GroupCollapseEventArgs e) => { try { list.ExpandGroup(e.GroupPosition); } catch (Exception ex) { LittleWatson.ReportException(ex); } }; list.GroupClick += (object sender, ExpandableListView.GroupClickEventArgs e) => { }; list.ChildClick += (object sender, ExpandableListView.ChildClickEventArgs e) => { try { if (e.GroupPosition == 0) { if (vm.EntryList.Count > 0) { vm.EntryList [e.ChildPosition].NavigateToEntryDetail(); } } if (e.GroupPosition == 2) { vm.OnItemTap(vm.ItemList [e.ChildPosition]); } } catch (Exception ex) { LittleWatson.ReportException(ex); } }; return(view); } catch (Exception ex) { LittleWatson.ReportException(ex); return(null); } }