diff --git a/MCTG/Model/Recipes/RecipeCollection.cs b/MCTG/Model/Recipes/RecipeCollection.cs
index dcbcb90..7579d5f 100644
--- a/MCTG/Model/Recipes/RecipeCollection.cs
+++ b/MCTG/Model/Recipes/RecipeCollection.cs
@@ -1,110 +1,110 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Text;
-
-namespace Model
-{
- ///
- /// Define a collection of .
- /// This class is derived from
- /// and implement and .
- ///
- public class RecipeCollection : ObservableCollection, IEquatable, ICloneable
- {
- #region Attributes
- private string _description = "";
- #endregion
-
- #region Properties
- ///
- /// A short description of what this collection contain.
- /// Set to "No description." when the value passed is null, empty or contain white spaces.
- ///
- public string Description
- {
- get => _description;
- set
- {
- if (string.IsNullOrWhiteSpace(value))
- _description = "No description.";
- else
- _description = value;
- }
- }
- #endregion
-
- #region Constructors
- ///
- /// Construct a new collection of _recipes.
- ///
- /// A short description of what this list will contain
- /// Recipes to add in this new collection
- public RecipeCollection(string description, params Recipe[] recipes)
- : base(recipes)
- {
- Description = description;
- }
- #endregion
-
- #region Methods
- ///
- /// Find a recipe in this list by giving the id.
- ///
- /// The id of the list we are looking for
- /// The recipe of the id given
- ///
- public Recipe? GetRecipeById(int id)
- {
- Recipe? recipe = this.ToList().Find(r => r.Id == id);
-
- if (recipe == null) throw new ArgumentException("No _recipes match the given id.");
- return recipe;
- }
-
- ///
- /// Utility to find a recipe by his _name.
- ///
- /// The string for the search
- /// A collection of Recipe where their Title contain the string.
- public RecipeCollection ResearchByName(string str)
- {
- if (string.IsNullOrEmpty(str))
- return this;
-
- return new RecipeCollection(
- description: $"Results of the research: {str}",
- recipes: this.ToList().FindAll(x => x.Title.ToLower().Contains(str.ToLower())).ToArray());
- }
-
- public virtual bool Equals(RecipeCollection? other)
- {
- if (other == null) return false;
- if (other == this) return true;
- return this.Description.Equals(other.Description);
- }
-
- public override bool Equals(object? obj)
- {
- var item = obj as RecipeCollection;
- if (item == null) return false;
- return Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return Description.GetHashCode();
- }
-
- public override string ToString()
- {
- StringBuilder sb = new StringBuilder($"[RecipeCollection] - {Description}:\n");
- foreach (Recipe r in this)
- {
- sb.AppendFormat("\t - {0}\n", r.ToString());
- }
- return sb.ToString();
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Text;
+
+namespace Model
+{
+ ///
+ /// Define a collection of .
+ /// This class is derived from
+ /// and implement and .
+ ///
+ public class RecipeCollection : ObservableCollection, IEquatable, ICloneable
+ {
+ #region Attributes
+ private string _description = "";
+ #endregion
+
+ #region Properties
+ ///
+ /// A short description of what this collection contain.
+ /// Set to "No description." when the value passed is null, empty or contain white spaces.
+ ///
+ public string Description
+ {
+ get => _description;
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ _description = "No description.";
+ else
+ _description = value;
+ }
+ }
+ #endregion
+
+ #region Constructors
+ ///
+ /// Construct a new collection of _recipes.
+ ///
+ /// A short description of what this list will contain
+ /// Recipes to add in this new collection
+ public RecipeCollection(string description, params Recipe[] recipes)
+ : base(recipes)
+ {
+ Description = description;
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Find a recipe in this list by giving the id.
+ ///
+ /// The id of the list we are looking for
+ /// The recipe of the id given
+ ///
+ public Recipe? GetRecipeById(int id)
+ {
+ Recipe? recipe = this.ToList().Find(r => r.Id == id);
+
+ if (recipe == null) throw new ArgumentException("No _recipes match the given id.");
+ return recipe;
+ }
+
+ ///
+ /// Utility to find a recipe by his _name.
+ ///
+ /// The string for the search
+ /// A collection of Recipe where their Title contain the string.
+ public RecipeCollection ResearchByName(string str)
+ {
+ if (string.IsNullOrEmpty(str))
+ return this;
+
+ return new RecipeCollection(
+ description: $"Results of the research: {str}",
+ recipes: this.ToList().FindAll(x => x.Title.ToLower().Contains(str.ToLower())).ToArray());
+ }
+
+ public virtual bool Equals(RecipeCollection? other)
+ {
+ if (other == null) return false;
+ if (other == this) return true;
+ return this.Description.Equals(other.Description);
+ }
+
+ public override bool Equals(object? obj)
+ {
+ var item = obj as RecipeCollection;
+ if (item == null) return false;
+ return Equals(obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Description.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder($"[RecipeCollection] - {Description}:\n");
+ foreach (Recipe r in this)
+ {
+ sb.AppendFormat("\t - {0}\n", r.ToString());
+ }
+ return sb.ToString();
}
public object Clone()
@@ -113,6 +113,6 @@ namespace Model
description: this.Description,
recipes: this.ToArray());
}
- #endregion
- }
-}
+ #endregion
+ }
+}
diff --git a/MCTG/Views/Home.xaml b/MCTG/Views/Home.xaml
index 2a7b048..7326778 100644
--- a/MCTG/Views/Home.xaml
+++ b/MCTG/Views/Home.xaml
@@ -15,11 +15,9 @@
-
+
+
+ Style="{StaticResource button1}"
+ Clicked="Plats_Clicked"/>
+ Style="{StaticResource button1}"
+ Clicked="Desserts_Clicked"/>
diff --git a/MCTG/Views/Home.xaml.cs b/MCTG/Views/Home.xaml.cs
index a1400e2..b546df2 100644
--- a/MCTG/Views/Home.xaml.cs
+++ b/MCTG/Views/Home.xaml.cs
@@ -57,6 +57,7 @@ namespace Views
private void ModifyRecipesDisplayed(RecipeCollection recipes)
{
_recipesDisplayed.Clear();
+ _recipesDisplayed.Description = recipes.Description;
foreach (Recipe recipe in recipes)
{
_recipesDisplayed.Add(recipe);
@@ -76,7 +77,22 @@ namespace Views
private void Entrees_Clicked(object sender, EventArgs e)
{
- return;
+ ModifyRecipesDisplayed(new RecipeCollection("Entrées", AllRecipe.ToList().FindAll(r => r.Type == RecipeType.Starter).ToArray()));
+ }
+
+ private void Plats_Clicked(object sender, EventArgs e)
+ {
+ ModifyRecipesDisplayed(new RecipeCollection("Plats", AllRecipe.ToList().FindAll(r => r.Type == RecipeType.Dish).ToArray()));
+ }
+
+ private void Desserts_Clicked(object sender, EventArgs e)
+ {
+ ModifyRecipesDisplayed(new RecipeCollection("Desserts", AllRecipe.ToList().FindAll(r => r.Type == RecipeType.Dessert).ToArray()));
+ }
+
+ private void AllRecipes_Clicked(object sender, EventArgs e)
+ {
+ ModifyRecipesDisplayed(AllRecipe);
}
}
}