Example #1
0
        public RecipeSearchPage()
        {
            InitializeComponent();
            BindingContext = new SQLentry();

            //we check if theres duplicate values, if so we dont add it
            RecipeNameOC = new ObservableCollection <SQLentry>();
            var entries = App.Database.ListRecipes("");

            foreach (var item in entries)
            {
                if ((!RecipeNameOC.Contains(item)))
                {
                    RecipeNameOC.Add(item);
                }
            }


            searchitemslistView.ItemsSource = RecipeNameOC;


            if (MainPage.TurkishClicked == false)
            {
                QuickSearchLabel.Text = Language.QuickSearchEN;
                searchbar.Placeholder = "Name";
            }
            else
            {
                QuickSearchLabel.Text = Language.QuickSearchTR;
                searchbar.Placeholder = "Tarif";
            }
        }
        public Categories(string selectedcategory)
        {
            InitializeComponent();
            BindingContext   = new SQLentry();
            SelectedCategory = selectedcategory;



            CategoryOC          = new ObservableCollection <SQLentry>();
            categoryListEntries = App.Database.GetCategory(selectedcategory);

            foreach (var item in categoryListEntries)
            {
                if (!CategoryOC.Contains(item))
                {
                    CategoryOC.Add(item);
                }
            }
            //item source of list is the OC where only categories are the same as the selected category provided in constructor

            categoriesList.ItemsSource = CategoryOC;

            if (MainPage.TurkishClicked == false)
            {
                CategoryLabel.Text = Language.RecipeNameEnglish;
            }
            else
            {
                CategoryLabel.Text = Language.RecipeNameTurkish;
            }
        }
Example #3
0
        public AddRecipesPage(SQLentry sqlentry)
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);

            passedSQLentry = sqlentry;

            RecipeImage.Source       = sqlentry.ImageFilePath;
            txtRecipeName.Text       = sqlentry.RecipeName.ToLower();
            txtcategory.SelectedItem = sqlentry.Category;
            txtIngredients.Text      = sqlentry.Ingredients;
            txtRecipe.Text           = sqlentry.Recipe;
            txtNotes.Text            = sqlentry.Notes;



            foreach (var item in Application.Current.Properties)
            {
                txtcategory.Items.Add(item.Value.ToString());
            }

            if (MainPage.TurkishClicked == false)
            {
                recipeNameLabel.Text  = Language.RecipeNameEnglish;
                categoryLabel.Text    = Language.CategoryEnglish;
                ingredientsLabel.Text = Language.IngredientsEnglish;
                recipeLabel.Text      = Language.RecipeEnglish;
                notesLabel.Text       = Language.NotesEnglish;
                SaveButton.Text       = Language.SaveButtonEnglish;
                CameraButton.Text     = Language.TakePhotoButtonEnglish;
                ChooseImage.Text      = Language.ChooseImageButtonEnglish;

                txtcategory.Items.Add("Breakfast");
                txtcategory.Items.Add("Lunch");
                txtcategory.Items.Add("Dinner");
                txtcategory.Items.Add("Desserts");
                txtcategory.Items.Add("Quick Bites");
            }
            else
            {
                recipeNameLabel.Text  = Language.RecipeNameTurkish;
                categoryLabel.Text    = Language.CategoryTurkish;
                ingredientsLabel.Text = Language.IngredientsTurkish;
                recipeLabel.Text      = Language.RecipeTurkish;
                notesLabel.Text       = Language.NotesTurkish;
                SaveButton.Text       = Language.SaveButtonTurkish;
                CameraButton.Text     = Language.TakePhotoButtonTurkish;
                ChooseImage.Text      = Language.ChooseImageButtonTurkish;

                txtcategory.Items.Add("Kahvaltı");
                txtcategory.Items.Add("Öğlen Yemeği");
                txtcategory.Items.Add("Akşam Yemegi");
                txtcategory.Items.Add("Tatlılar");
                txtcategory.Items.Add("Aperatifler");
            }
        }
Example #4
0
        //we select an item and get the item and explicitly convert the list item to a SQLentry type, pass it to the next page as a parameter

        private async void searchitemslist_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            SQLentry mychoice = e.SelectedItem as SQLentry;


            if (mychoice == null)
            {
                return;
            }
            else
            {
                //first line is making usre that after selecting listview item, and going back to this page, the selection doesnt remain checked
                ((ListView)sender).SelectedItem = null;
                await Navigation.PushAsync(new RecipeDisplayPage(mychoice));

                searchbar.Text = "";
            }
        }
        private async Task categoriesList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            //a copy of the navigation technique in the recipessearchpage list

            SQLentry mychoice = e.SelectedItem as SQLentry;


            if (mychoice == null)
            {
                return;
            }
            else
            {
                //first line is making usre that after selecting listview item, and going back to this page, the selection doesnt remain checked
                ((ListView)sender).SelectedItem = null;
                await Navigation.PushAsync(new RecipeDisplayPage(mychoice));
            }
        }
Example #6
0
        async void Click_Save(object sender, EventArgs e)
        {
            bool saved = true;

            bool answer;

            if (txtRecipeName.Text != null)
            {
                if (MainPage.TurkishClicked == false)
                {
                    answer = await DisplayAlert("Save Recipe", "Are you sure?", "Yes", "No");
                }
                else
                {
                    answer = await DisplayAlert("Yeni Tarif", "Kaydetmek ister misiniz?", "Evet", "Hayır");
                }
            }
            else
            {
                if (MainPage.TurkishClicked == false)
                {
                    await DisplayAlert("", "Recipe name and Category are required fields", "OK");

                    answer = false;
                }
                else
                {
                    await DisplayAlert("", "Lütfen Tarif ismini ve Kategoriyi doldurunuz", "OK");

                    answer = false;
                }
            }


            if (answer == true)
            {
                try
                {
                    SQLentry fileexist = App.Database.GetItem(txtRecipeName.Text.ToUpper());
                    if (fileexist == null)
                    {
                        if (txtRecipeName.Text != null)

                        {
                            SQLentry entry = new SQLentry();



                            entry.RecipeName = txtRecipeName.Text.ToUpper();

                            //we want to save each category only in english, even if user app is in turkish mode.
                            if (txtcategory.SelectedItem.ToString() == "Kahvaltı")
                            {
                                entry.Category = "Breakfast";
                            }
                            else if (txtcategory.SelectedItem.ToString() == "Öğlen Yemeği")
                            {
                                entry.Category = "Lunch";
                            }
                            else if (txtcategory.SelectedItem.ToString() == "Akşam Yemegi")
                            {
                                entry.Category = "Dinner";
                            }
                            else if (txtcategory.SelectedItem.ToString() == "Aperatifler")
                            {
                                entry.Category = "Quick Bites";
                            }
                            else if (txtcategory.SelectedItem.ToString() == "Tatlılar")
                            {
                                entry.Category = "Desserts";
                            }
                            else
                            {
                                entry.Category = txtcategory.SelectedItem.ToString();
                            }


                            entry.Recipe      = txtRecipe.Text;
                            entry.Notes       = txtNotes.Text;
                            entry.Ingredients = txtIngredients.Text;


                            if (PicTakenFile != null)
                            {
                                entry.ImageFilePath = PicTakenFile.Path.ToString();
                                PicTakenFile        = null;
                            }
                            else
                            {
                                entry.ImageFilePath = "";
                            }



                            int i = App.Database.SaveItem(entry);


                            if (i > 0)
                            {
                                if (MainPage.TurkishClicked == false)
                                {
                                    await DisplayAlert("New Recipe", "Save successful!", "OK");

                                    await Navigation.PopToRootAsync();
                                }
                                else
                                {
                                    await DisplayAlert("Yeni Tarif", "Kayıt Başarılı!", "OK");

                                    await Navigation.PopToRootAsync();
                                }
                            }
                            else
                            {
                                if (MainPage.TurkishClicked == false)
                                {
                                    await DisplayAlert("Oops!", "Try Again", "OK");
                                }
                                else
                                {
                                    await DisplayAlert("Oops!", "Tekrar Deneyiniz", "OK");
                                }
                            }
                        }
                        else
                        {
                            if (MainPage.TurkishClicked == false)
                            {
                                await DisplayAlert("", "Recipe name and Category are required fields", "OK");
                            }
                            else
                            {
                                await DisplayAlert("", "Lütfen tarif ismini ve kategoriyi doldurunuz", "OK");
                            }
                        }
                    }
                    else if (fileexist != null && passedSQLentry != null)
                    {
                        if (txtRecipeName.Text != null)
                        {
                            SQLentry entry2 = new SQLentry();
                            entry2.RecipeID = passedSQLentry.RecipeID;
                            if (PicTakenFile == null)
                            {
                                entry2.ImageFilePath         = passedSQLentry.ImageFilePath;
                                passedSQLentry.ImageFilePath = null;
                            }
                            else
                            {
                                entry2.ImageFilePath = PicTakenFile.Path.ToString();
                                PicTakenFile         = null;
                            }
                            entry2.Category    = txtcategory.SelectedItem.ToString();
                            entry2.RecipeName  = txtRecipeName.Text.ToUpper();
                            entry2.Ingredients = txtIngredients.Text;
                            entry2.Recipe      = txtRecipe.Text;
                            entry2.Notes       = txtNotes.Text;

                            int i = App.Database.SaveItem(entry2);


                            if (i > 0)
                            {
                                if (MainPage.TurkishClicked == false)
                                {
                                    await DisplayAlert("Edit Recipe", "Save successful!", "OK");

                                    await Navigation.PopToRootAsync();
                                }
                                else
                                {
                                    await DisplayAlert("Tarif düzenleme", "Başarılı!", "OK");

                                    await Navigation.PopToRootAsync();
                                }
                            }
                            else
                            {
                                if (MainPage.TurkishClicked == false)
                                {
                                    await DisplayAlert("Oops!", "Try Again", "OK");
                                }
                                else
                                {
                                    await DisplayAlert("Oops!", "Tekrar Deneyiniz", "OK");
                                }
                            }
                        }
                        else
                        {
                            if (MainPage.TurkishClicked == false)
                            {
                                await DisplayAlert("", "Recipe name and Category are required fields", "OK");
                            }
                            else
                            {
                                await DisplayAlert("", "Lütfen tarif ismini ve kategoriyi doldurunuz", "OK");
                            }
                        }
                    }
                    else if (fileexist != null && passedSQLentry == null)
                    {
                        if (MainPage.TurkishClicked == false)
                        {
                            await DisplayAlert("Save Failed", "Recipe Already Exists ", "OK");

                            txtRecipeName.Text = "";
                        }
                        else
                        {
                            await DisplayAlert("Tarif Ekleme Başarısız oldu", "Lütfen Yeni Tarif Ekle", "OK");

                            txtRecipeName.Text = "";
                        }
                    }
                }
                catch
                {
                    e.ToString();
                }
            }
        }
Example #7
0
        public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new MainPage())
            {
                BarBackgroundColor = Color.Black
            };
            NavigationPage.SetHasNavigationBar(MainPage, false);



            SQLentry fileexist = App.Database.GetItem("SALMON WITH HERB SAUCE RAVIGOTE");

            if (fileexist == null)
            {
                SQLentry stockRecipe1 = new SQLentry();
                stockRecipe1.RecipeName  = "SALMON WITH HERB SAUCE RAVIGOTE";
                stockRecipe1.Category    = "Dinner";
                stockRecipe1.Ingredients = "250g salmon" + Environment.NewLine + "Handful of thyme" + Environment.NewLine + "Handful of rosemary and thyme"
                                           + Environment.NewLine + "2 lemons" + Environment.NewLine + "Vinegar" + Environment.NewLine + "250g prepared chips or potatoes"
                                           + Environment.NewLine + "Olive Oil/Butter";
                stockRecipe1.Recipe = "1) Pour some oil/melt butter in a non stick frying pan " + Environment.NewLine +
                                      "2) Cook the salmon the pan on low heatt until the skin is slightly hardened" + Environment.NewLine +
                                      "3) In a mortar and pestle crush the rosemary and thyme with some lemon juice and vinegar for the sauce ravigote " + Environment.NewLine +
                                      "4) Cook the chips in the olive oil" + Environment.NewLine +
                                      "5) Serve the chips and salmon with sauce ravigote poured to taste"

                ;

                //this is how we use an IMAGE from the resources drawable. just quote the name of file with extension
                //BE CAREFUL its best to use PNG extension. If you file is jpg, dont change it directly, better to open via paint and savea as png, otherwise becomes
                //unusable currupt file
                stockRecipe1.ImageFilePath = "salmon.png";


                Database.SaveItem(stockRecipe1);
            }

            SQLentry fileexist2 = App.Database.GetItem("FRENCH TOAST");

            if (fileexist2 == null)
            {
                SQLentry stockRecipe1 = new SQLentry();
                stockRecipe1.RecipeName  = "FRENCH TOAST";
                stockRecipe1.Category    = "Breakfast";
                stockRecipe1.Ingredients = "2 pieces of toast" + Environment.NewLine + "Honey" + Environment.NewLine + "Half a Banana"
                                           + Environment.NewLine + "Handful of Strawberries" + Environment.NewLine + "1 Egg" + Environment.NewLine + "Butter";
                stockRecipe1.Recipe = "1) Crack and mix the eggs in a flat plate" + Environment.NewLine +
                                      "2) Dab both sides of the toast onto the eggs and place on a low heat flat frying pan" + Environment.NewLine +
                                      "3) When the toast is as desired pour honey and place your chopped fruits ontop";

                //this is how we use an IMAGE from the resources drawable. just quote the name of file with extension
                //BE CAREFUL its best to use PNG extension. If you file is jpg, dont change it directly, better to open via paint and savea as png, otherwise becomes
                //unusable currupt file
                stockRecipe1.ImageFilePath = "FrenchToast.png";


                Database.SaveItem(stockRecipe1);
            }
        }