예제 #1
0
        private async void btnadd_Clicked(object sender, EventArgs e)
        {
            await btnadd.ScaleTo(1.1, 80);

            await btnadd.ScaleTo(1, 80, Easing.BounceOut);

            var pop = new PopUp();
            await App.Current.MainPage.Navigation.PushPopupAsync(pop, true);

            pop.OnDialogClosed += (s, arg) =>
            {
                string productname = Regex.Replace(arg.ProductName, @"\s+", " ").Trim();

                if (!string.IsNullOrWhiteSpace(productname) && !productname.Equals(""))
                {
                    productname = char.ToUpper(productname[0]) + productname.Substring(1);
                    DateTime date       = arg.ExpirationDate;
                    var      ingredient = new Ingredient(productname, date);
                    db.InsertIntoTable(ingredient);
                    PersonalIngredientList.Add(ingredient);
                    PersonalIngredientList.Sort((a, b) => a.Date.CompareTo(b.Date));
                    Model          = new IngredientsViewModel(PersonalIngredientList);
                    BindingContext = Model;

                    CrossLocalNotifications.Current.Show("Utgående vara", "Din vara '" + ingredient.Name + "' går ut snart! Använd vår sökfunktion för att hitta passande recept:)", ingredient.ID, date.AddDays(-2).AddHours(16));
                }
            };
        }
예제 #2
0
        public App()
        {
            InitializeComponent();


            MainPage       = new NavigationPage(new MainPage());
            BindingContext = new IngredientsViewModel();
        }
예제 #3
0
        public MainPage()
        {
            InitializeComponent();

            PersonalIngredientList = new List <Ingredient>();
            RecipeList             = new List <Recipe>();

            db = new DataBase();
            db.createDataBase();
            PersonalIngredientList = db.GetIngredientsItems();
            PersonalIngredientList.Sort((a, b) => a.Date.CompareTo(b.Date));
            Model = new IngredientsViewModel(GreenOrRed(PersonalIngredientList));

            RModel = new RecipeViewModel();

            BindingContext = Model;
            categoryPicker.SelectedIndex = 0;
        }
예제 #4
0
        private async void btnscan_Clicked(object sender, EventArgs e)
        {
            await btnscan.ScaleTo(1.1, 80);

            await btnscan.ScaleTo(1, 80, Easing.BounceOut);

            scanPage = new ZXingScannerPage();
            scanPage.OnScanResult += (result) =>
            {
                scanPage.IsScanning = false;

                var pop = new PopUp(BarCodeManager.getCorrectName(BarCodeManager.getBarNameDabas(result.Text)));

                App.Current.MainPage.Navigation.PushPopupAsync(pop, true);

                pop.OnDialogClosed += (s, arg) =>
                {
                    string productname = Regex.Replace(arg.ProductName, @"\s+", " ").Trim();

                    if (!string.IsNullOrWhiteSpace(productname) && !productname.Equals(""))
                    {
                        productname = char.ToUpper(productname[0]) + productname.Substring(1);
                        DateTime date       = arg.ExpirationDate;
                        var      ingredient = new Ingredient(productname, date);
                        db.InsertIntoTable(ingredient);
                        PersonalIngredientList.Add(ingredient);
                        Model.IngredientList.Add(ingredient);
                        PersonalIngredientList.Sort((a, b) => a.Date.CompareTo(b.Date));
                        Model          = new IngredientsViewModel(PersonalIngredientList);
                        BindingContext = Model;

                        CrossLocalNotifications.Current.Show("Utgående vara", "Din vara '" + ingredient.Name + "' går ut snart! Använd vår sökfunktion för att hitta passande recept:)", ingredient.ID, date.AddDays(-2).AddHours(16));
                    }
                };

                //Gör något med "result"
                Device.BeginInvokeOnMainThread(() =>
                {
                    Navigation.PopModalAsync();
                });
            };

            await Navigation.PushModalAsync(scanPage);
        }