public AddMealPage(IPluginCollector pluginCollector, MealDataPoint point)
 {
     this.BindingContext = new AddMealPageModel(pluginCollector, point);
     model = (AddMealPageModel)this.BindingContext;
     model.WireEvents(this);
     InitializeComponent();
 }
 public AddMealPageModel(IPluginCollector _pluginCollector, MealDataPoint point)
 {
     Name            = "AddMeal";
     pluginCollector = _pluginCollector;
     Ingredients     = point.Ingredients;
     Time            = point.Date.TimeOfDay;
     Date            = point.Date;
     BreadUnits      = point.BreadUnits;
     EnergyAmount    = point.EnergyAmount;
     existingPoint   = point;
 }
        public async void on_SelectedIndexChangedBs(object sender, ChartSelectionEventArgs e)
        {
            if (e.SelectedSeries != null && e.SelectedDataPointIndex != -1)
            {
                if (e.SelectedSeries.Label == "Bloodsugar")
                {
                    BloodSugarDataPoint bloodPoint = model.SettingsModel.BloodSugarDataPoints[e.SelectedDataPointIndex];
                    bool action = await DisplayAlert("BloodSugar:", bloodPoint.BloodSugarLevel.ToString(), "Edit", "Back");

                    if (action == true)
                    {
                        openDataPoint(e.SelectedDataPointIndex, DataPoints.BloodSugar.ToString());
                    }
                }
                if (e.SelectedSeries.Label == "Meal")
                {
                    MealDataPoint mealPoint = model.SettingsModel.MealDataPoints[e.SelectedDataPointIndex];

                    string content = "";
                    content = "Total BreadUnits: " + mealPoint.BreadUnits + "\t\t\t\t" + "Total Energy: " + mealPoint.EnergyAmount + " kcal" + "\n\n";

                    foreach (Ingredient ing in mealPoint.Ingredients)
                    {
                        content += ing.Name + "\n"
                                   + "Breadunits: " + ing.BreadUnits + "\t\t" + "Energy: " + ing.EnergyAmount + "\t\t" + "Amount: " + ing.amount + "\n\n";
                    }
                    var action = await DisplayAlert("Meal:", content, "Edit", "Back");

                    if (action == true)
                    {
                        openDataPoint(e.SelectedDataPointIndex, DataPoints.Meal.ToString());
                    }
                }

                if (e.SelectedSeries.Label == "Med")
                {
                    MedicineDataPoint medPoint = model.SettingsModel.MedicineDataPoints[e.SelectedDataPointIndex];
                    var action = await DisplayAlert("Medicine:", medPoint.Name + ": " + medPoint.Amount + " " + medPoint.Unit, "Edit", "Back");

                    if (action == true)
                    {
                        openDataPoint(e.SelectedDataPointIndex, DataPoints.Medicine.ToString());
                    }
                }
            }
        }