public void RefreshDisplay()
        {
            FillupSelection = null;

            Fillups.Clear();

            using (var db = Util.Database.Connection())
            {
                var data = db.Table<Fillup>().OrderByDescending(item => item.Odometer).ToList();

                if (data.Count > 0)
                {
                    for (int i = 0; i < data.Count-1; i++)
                        Fillups.Add(new FillupView(data[i], data[i + 1]));

                    Fillups.Add(new FillupView(data[data.Count-1]));
                }
            }
        }
Exemplo n.º 2
0
        private static void AddFillupMessages()
        {
            using (var db = Util.Database.Connection())
            {
                var fillups = db.Table<Fillup.Fillup>();
                switch (fillups.Count())
                {
                    case 0:
                        Messages.Add("No fill-up data to show.");
                        break;
                    case 1:
                        Messages.Add("You've filled your tank once. Do it again for stats!");
                        break;
                    default:
                        var twoRecent = fillups.OrderByDescending(item => item.Odometer).Take(2).ToList();
                        var stats = new FillupView(twoRecent[0], twoRecent[1]);

                        Messages.Add("You drove " + stats.Miles + " on your last tank of gas.");
                        Messages.Add("You got " + stats.Efficiency + " on your last tank of gas.");
                        break;
                }
            }
        }
        private void OnItemClick(object sender, ItemClickEventArgs e)
        {
            if (FillupSelection != null)
            {
                FillupSelection.ItemBackground = new SolidColorBrush(Windows.UI.Colors.Transparent);
            }

            FillupSelection = (FillupView)e.ClickedItem;
            FillupSelection.ItemBackground = (Brush)App.Current.Resources["ButtonBackground"];
        }