예제 #1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                FoodItems.Clear();
                var foodItems = await FoodDataStore.GetItemsAsync(true);

                foreach (var item in foodItems)
                {
                    FoodItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        void UpdateJournal(object sender, EventArgs args)
        {
            var calendar = NSCalendar.CurrentCalendar;

            var startDate = DateTime.Now.Date;
            var endDate   = startDate.AddDays(1);

            var sampleType = HKSampleType.GetQuantityType(HKQuantityTypeIdentifierKey.DietaryEnergyConsumed);
            var predicate  = HKQuery.GetPredicateForSamples((NSDate)startDate, (NSDate)endDate, HKQueryOptions.None);

            var query = new HKSampleQuery(sampleType, predicate, 0, new NSSortDescriptor[0], (resultQuery, results, error) => {
                if (error != null)
                {
                    Console.WriteLine("An error occured fetching the user's tracked food. " +
                                      "In your app, try to handle this gracefully. The error was: {0}.", error.LocalizedDescription);
                    return;
                }

                InvokeOnMainThread(() => {
                    FoodItems.RemoveAllObjects();
                    foreach (HKQuantitySample sample in results)
                    {
                        var foodName  = (NSString)sample.Metadata.Dictionary [HKMetadataKey.FoodType];
                        double joules = sample.Quantity.GetDoubleValue(HKUnit.Joule);
                        var foodItem  = FoodItem.Create(foodName, joules);

                        FoodItems.Add(foodItem);
                    }

                    TableView.ReloadData();
                });
            });

            HealthStore.ExecuteQuery(query);
        }
예제 #3
0
        private async Task ExecuteLoadItemsCommand(bool allItems)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                FoodItems.Clear();
                var items = allItems ? await DataStore.GetItemsAsync() : await DataStore.GetMyItemsAsync();

                foreach (var item in items)
                {
                    FoodItems.Add(item);
                    Console.WriteLine(item.FoodName + " " + item.BrandName);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #4
0
        public MainWindow()
        {
            InitializeComponent();

            Canvas.SetLeft(AntHill, (1400 - 20) / 2);
            Canvas.SetTop(AntHill, (800 - 20) / 2);

            for (int i = 0; i < 40; i++)
            {
                Thread.Sleep(30);
                var ant = new Ant();
                Ants.Add(ant);
                Canvas.Children.Add(ant);

                for (int j = 0; j < 5; j++)
                {
                    Thread.Sleep(30);
                    var food = new Food();
                    FoodItems.Add(food);
                    Canvas.Children.Add(food);
                }
            }

            RunLooper();
        }
예제 #5
0
        private async void GetFoodItems()
        {
            var foods = new FoodItemService();
            var items = await foods.GetFoodItemsAsync();

            foreach (var item in items)
            {
                FoodItems.Add(item);
            }
        }
        private void GetCustomerList()
        {
            FoodItems.Clear();
            selectedFoodItem = null;

            foreach (var fooditem in _dbLayerObj.GetFoodItems())
            {
                FoodItems.Add(fooditem);
            }
        }
예제 #7
0
        private void Refresh()
        {
            FoodItems.Clear();

            var fooditems = _dataService.Refresh();

            foreach (var fooditem in fooditems)
            {
                FoodItems.Add(fooditem);
            }
        }
예제 #8
0
        public void Clone(RecipeViewModel mealViewModel)
        {
            Id   = mealViewModel.Id;
            Name = mealViewModel.Name;

            FoodItems.Clear();
            foreach (RecipeItemViewModel x in mealViewModel.FoodItems)
            {
                FoodItems.Add(new RecipeItemViewModel()
                {
                    Consumable = x.Consumable,
                    Quantity   = x.Quantity
                });
            }
        }
예제 #9
0
        async Task LoadDataAsync()
        {
            try {
                IsBusy = true;

                var items = await FoodManager.GetAsync();

                var favorites = await FavoriteManager.GetAsync();

                var fooditems = from fi in items
                                join fav in favorites on fi.Id equals fav.FoodItemId
                                select fi;

                FoodItems.Clear();

                foreach (var item in fooditems)
                {
                    FoodItems.Add(new FoodViewModel(item));
                }
            } finally {
                IsBusy = false;
            }
        }
예제 #10
0
파일: Menu.cs 프로젝트: gphann/RestaMenu
 public List <MenuItem> AddFoodItem(MenuItem foodItem)
 {
     FoodItems.Add(foodItem);
     return(FoodItems);
 }
예제 #11
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                GlucItems.Clear();
                RecentGlucItems.Clear();
                var glucItems = await GlucDataStore.GetItemsAsync(true);

                foreach (var item in glucItems)
                {
                    GlucItems.Add(item);
                }

                if (GlucItems.Count > 10)
                {
                    for (int i = GlucItems.Count - 10; i < GlucItems.Count; i++)
                    {
                        RecentGlucItems.Add(GlucItems[i]);
                    }
                }
                else
                {
                    foreach (GlucoseEntry entry in GlucItems)
                    {
                        RecentGlucItems.Add(entry);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            try
            {
                ExItems.Clear();
                RecentExItems.Clear();
                var exItems = await ExDataStore.GetItemsAsync(true);

                foreach (var item in exItems)
                {
                    ExItems.Add(item);
                }

                if (ExItems.Count > 10)
                {
                    for (int i = ExItems.Count - 10; i < ExItems.Count; i++)
                    {
                        RecentExItems.Add(ExItems[i]);
                    }
                }
                else
                {
                    foreach (ExerciseEntry entry in ExItems)
                    {
                        RecentExItems.Add(entry);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            try
            {
                FoodItems.Clear();
                RecentFoodItems.Clear();
                var foodItems = await FoodDataStore.GetItemsAsync(true);

                foreach (var item in foodItems)
                {
                    FoodItems.Add(item);
                }

                if (FoodItems.Count > 10)
                {
                    for (int i = FoodItems.Count - 10; i < FoodItems.Count; i++)
                    {
                        RecentFoodItems.Add(FoodItems[i]);
                    }
                }
                else
                {
                    foreach (FoodEntry entry in FoodItems)
                    {
                        RecentFoodItems.Add(entry);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }