Esempio n. 1
0
        public HomePageContent(InitRecipes init, List <Recipe> recipeList) : this()
        {
            InitializeComponent();

            this.FeaturedRecipes = recipeList;
            this.Init            = init;


            foreach (Recipe rcp in FeaturedRecipes)
            {
                Button btn = new Button();
                btn.Background = Brushes.Transparent;

                RecipeDisplaySmall _displayCard = new RecipeDisplaySmall(rcp);

                btn.Content = _displayCard;
                btn.Click  += (sender, eventArgs) =>
                {
                    Switcher.SwitchTopPanel(new RecipeHeader(rcp));
                    Switcher.SwitchContentPanel(new RecipeDisplayContent(this.Init, rcp));
                };

                outerPanel.Children.Add(btn);
            }
        }
        public SearchResultsContent(InitRecipes init, List <Recipe> recipeList) : this()
        {
            InitializeComponent();

            this.DisplayedRecipes = recipeList;
            this.Init             = init;

            if (DisplayedRecipes.Count == 0)
            {
                Label lbl = new Label();
                lbl.Content  = "No recipes to display. Try removing some of your filters.";
                lbl.FontSize = 18;
                outerPanel.Children.Add(lbl);
            }
            else
            {
                foreach (Recipe rcp in DisplayedRecipes)
                {
                    Button btn = new Button();
                    btn.Background = Brushes.Transparent;

                    RecipeDisplaySmall _displayCard = new RecipeDisplaySmall(rcp);

                    btn.Content = _displayCard;
                    btn.Click  += (sender, eventArgs) =>
                    {
                        Switcher.SwitchTopPanel(new RecipeHeader(rcp));
                        Switcher.SwitchContentPanel(new RecipeDisplayContent(this.Init, rcp));
                    };

                    outerPanel.Children.Add(btn);
                }
            }
        }
Esempio n. 3
0
        public MyRecipeDisplaySmall(Recipe rcp, InitRecipes init) : this()
        {
            InitializeComponent();
            this.MyRecipe         = rcp;
            this.DataContext      = this.MyRecipe;
            this.Init             = init;
            _prepTimeText.Content = TimeStringFormat.GenerateString(this.MyRecipe.Time);

            switch (rcp.Difficulty)
            {
            case 3:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/expertDifficulty.png", UriKind.Relative));
                break;

            case 2:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/hardDifficulty.png", UriKind.Relative));
                break;

            case 1:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/mediumDifficulty.png", UriKind.Relative));
                break;

            default:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/easyDifficulty.png", UriKind.Relative));
                break;
            }
        }
Esempio n. 4
0
 public AddIngredientPanel(InitRecipes init, Recipe rcp, AddRecipeHeader hdr) : this()
 {
     InitializeComponent();
     this.RecipeForIngredient = rcp;
     this.Init        = init;
     this.ingredients = new List <Ingredient>();
     this.header      = hdr;
 }
Esempio n. 5
0
 public userInformation(string name, string password, Recipe NewRecipe, InitRecipes Init)
 {
     this.UserName    = name;
     this.password    = password;
     this.NewRecipe   = NewRecipe;
     this.Init        = Init;
     this.LogInStatus = 1;
 }
 public SignInContent(InitRecipes init)
 {
     InitializeComponent();
     this.Init          = init;
     Username.Text      = globalvariable.currentLoginUsername;
     _numCreated.Text   = this.Init.UserRecipes.Count().ToString();
     _numFavorites.Text = this.Init.FavoriteRecipes.Count().ToString();
 }
Esempio n. 7
0
        public RecipeDisplayContent(InitRecipes init, Recipe rcp) : this()
        {
            InitializeComponent();
            this.DataContext = rcp;
            this.NewRate     = rcp;

            if (init.FavoriteRecipes.Contains(rcp))
            {
                _favoriteImage.Source = new BitmapImage(new Uri("/images/unfavoriteButton.png", UriKind.Relative));
            }

            foreach ((Ingredient, double)ingredient in rcp.recipeIngredients)
            {
                ingredientTextDisplay ingredientDisplay = new ingredientTextDisplay();
                ingredientDisplay.IngNameTag    = ingredient.Item1.IngredientName;
                ingredientDisplay.IngNumTag     = ingredient.Item2.ToString();
                ingredientDisplay.IngMeasureTag = ingredient.Item1.BaseMeasure;

                this.IngredientsPanel.Children.Add(ingredientDisplay);
            }

            switch (this.NewRate.Difficulty)
            {
            case 3:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/expertDifficulty.png", UriKind.Relative));
                break;

            case 2:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/hardDifficulty.png", UriKind.Relative));
                break;

            case 1:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/mediumDifficulty.png", UriKind.Relative));
                break;

            default:
                _difficultyImage.Source = new BitmapImage(new Uri("/images/easyDifficulty.png", UriKind.Relative));
                break;
            }


            recipeDisplayContent_favoriteButton.Click += (sender, eventArgs) =>
            {
                if (init.FavoriteRecipes.Contains(rcp))                 //If the recipe is already a favorite and the button is clicked to unfavorite
                {
                    _favoriteImage.Source = new BitmapImage(new Uri("/images/favoriteButton.png", UriKind.Relative));
                    init.FavoriteRecipes.Remove(rcp);
                }
                else                            //If the image should be added to favorites
                {
                    _favoriteImage.Source = new BitmapImage(new Uri("/images/unfavoriteButton.png", UriKind.Relative));
                    init.FavoriteRecipes.Add(rcp);
                }
            };

            _prepTimeLabel.Content = TimeStringFormat.GenerateString(rcp.Time);
        }
Esempio n. 8
0
        //Initialize all the pages

        //LoginHeader _loginHeader = new LoginHeader();

        //LoginContent _loginContent = new LoginContent(this.Init);


        public MainWindow()
        {
            InitializeComponent();
            globalvariable.loginstatus = 0;

            this.Init = new InitRecipes();

            //Pass the panels to the switcher
            Switcher.topPanel     = this.topPanel;
            Switcher.contentPanel = this.contentPanel;

            Switcher.SwitchTopPanel(new SearchBar(this.Init));
            Switcher.SwitchContentPanel(new HomePageContent(this.Init, this.Init.FeaturedRecipes));
        }
        //ingredientsearch takes a string which is a user typed input for ingredient searching
        public static List <Ingredient> Insearch(InitRecipes init, string keyword)
        {
            //create a variable for storing searched ingredients
            List <Ingredient> searchresult = new List <Ingredient>();

            //check every ingredients in the system
            foreach (Ingredient ing in init.AllIngredients)
            {
                //if ingredient name contains the user typed keyword, add it to the searchresult
                string lowerIngredientName = ing.IngredientName.ToLower();
                if (lowerIngredientName.Contains(keyword.ToLower()))
                {
                    searchresult.Add(ing);
                }
            }
            //after checking every ingredients, return the searchresult as list of ingredients
            return(searchresult);
        }
Esempio n. 10
0
        public AddRecipeContent(Recipe NewRcp, AddRecipeHeader header, InitRecipes initObject) : this()
        {
            InitializeComponent();
            this.NewRecipe   = NewRcp;
            this.DataContext = this.NewRecipe;
            this.Init        = initObject;
            this.NewHeader   = header;

            foreach ((Ingredient, double)ingredient in this.NewRecipe.recipeIngredients)
            {
                ingredientTextDisplayEdit ingredientDisplay = new ingredientTextDisplayEdit(this.NewRecipe);
                ingredientDisplay.IngNameTag    = ingredient.Item1.IngredientName;
                ingredientDisplay.IngNumTag     = ingredient.Item2.ToString();
                ingredientDisplay.IngMeasureTag = ingredient.Item1.BaseMeasure;

                this.IngredientsPanel.Children.Add(ingredientDisplay);
            }
            _recipePhoto.Source = new BitmapImage(new Uri(this.NewRecipe.Image, UriKind.Relative));
        }
Esempio n. 11
0
        //search function takes list of strings containing all keywords used for searching and filtering
        public static List <Recipe> Searchrecipes(InitRecipes init, string[] keywords)
        {
            //create a varoable for storing searched and filtered recipes
            List <Recipe> searchresult = new List <Recipe>();

            //check every recipes, one at each iteration
            foreach (Recipe rcp in init.AllRecipes)
            {
                //create a variable for storing recipe's tags
                string[] taglist = rcp.tags;

                //call containseverything function to see if this recipe has all the keywords that user want from searching and filtering
                if (Search.Containseverything(taglist, keywords))
                {
                    //if this recipe contains all the keywordss, add it to the searchresult
                    searchresult.Add(rcp);
                }
            }
            //return search result as an output
            return(searchresult);
        }
Esempio n. 12
0
        public MyRecipesContent(InitRecipes init) : this()
        {
            InitializeComponent();

            this.Init = init;


            foreach (Recipe rcp in this.Init.UserRecipes)
            {
                Button btn = new Button();
                btn.Background = Brushes.Transparent;

                MyRecipeDisplaySmall _displayCard = new MyRecipeDisplaySmall(rcp, this.Init);

                btn.Content = _displayCard;
                btn.Click  += (sender, eventArgs) =>
                {
                    Switcher.SwitchTopPanel(new RecipeHeader(rcp));
                    Switcher.SwitchContentPanel(new RecipeDisplayContent(this.Init, rcp));
                };

                outerPanel.Children.Add(btn);
            }
        }
 public LoginContent(InitRecipes init)
 {
     InitializeComponent();
     wrongpasswordtips.Visibility = Visibility.Hidden;
     this.Init = init;
 }
 public SearchBar(InitRecipes initObject) : this()
 {
     InitializeComponent();
     this.Init = initObject;
 }
 public SignUpContent(InitRecipes init)
 {
     InitializeComponent();
     passwordmatchtips.Visibility = Visibility.Hidden;
     this.Init = init;
 }