From e88eb58e70035996a583f3d173a7df35643e337e Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Fri, 26 May 2023 12:03:14 +0200 Subject: [PATCH 1/2] big probleme with the bindable property TITLE. --- MCTG/DataPersistence/Stubs.cs | 3 ++- MCTG/Model/Recipes/Recipe.cs | 24 +++++++++++++----------- MCTG/Views/App.xaml.cs | 21 +++++++++++++++++++-- MCTG/Views/Home.xaml | 5 +++-- MCTG/Views/Home.xaml.cs | 12 ++++++++++-- MCTG/Views/MiniHeader.xaml | 2 +- MCTG/Views/MiniHeader.xaml.cs | 6 +++--- MCTG/Views/ViewRecette.xaml | 6 +++--- MCTG/Views/ViewRecette.xaml.cs | 32 ++++++++++++++++++++------------ 9 files changed, 74 insertions(+), 37 deletions(-) diff --git a/MCTG/DataPersistence/Stubs.cs b/MCTG/DataPersistence/Stubs.cs index 87e62b9..a6fece1 100644 --- a/MCTG/DataPersistence/Stubs.cs +++ b/MCTG/DataPersistence/Stubs.cs @@ -38,7 +38,8 @@ namespace DataPersistence }), new Recipe( authorMail: "admin@mctg.fr", - title: "Cookies au chocolat", id: null, + title: "Cookies au chocolat", + id: null, preparationSteps: new[] { new PreparationStep(1, "Moulinez la pâte."), diff --git a/MCTG/Model/Recipes/Recipe.cs b/MCTG/Model/Recipes/Recipe.cs index dc5cf2c..9f220ca 100644 --- a/MCTG/Model/Recipes/Recipe.cs +++ b/MCTG/Model/Recipes/Recipe.cs @@ -40,6 +40,8 @@ namespace Model [DataMember(Name = "authorMail")] public string? AuthorMail { get; private set; } + public string Toto { get; set; } = "Coucou"; + /// /// The Title of the recipe.
/// Set to "No title." when the value passed is null, empty or contain white spaces. @@ -144,17 +146,17 @@ namespace Model { } - ///// - ///// - ///// - ///// The title of the recipe. - ///// The id of the recipe. If not given, get a new id. - ///// Image that reppresent the recipe. - ///// The steps of the preparation of the meal. - //public Recipe(string title, int? id, string picture, params PreparationStep[] preparationSteps) - // : this(title, id, null, picture, new List(), new List(), preparationSteps) - //{ - //} + /// + /// + /// + /// The title of the recipe. + /// The id of the recipe. If not given, get a new id. + /// Image that reppresent the recipe. + /// The steps of the preparation of the meal. + public Recipe() + : this("", null, null, null, new List(), new List(),new PreparationStep[0]) + { + } #endregion diff --git a/MCTG/Views/App.xaml.cs b/MCTG/Views/App.xaml.cs index c0c7f97..4743f76 100644 --- a/MCTG/Views/App.xaml.cs +++ b/MCTG/Views/App.xaml.cs @@ -8,6 +8,10 @@ using DataPersistence; using Model; using System.Collections.ObjectModel; using Model.Managers; +using Microsoft.Maui.Controls; +using System.Linq; +using System.ComponentModel; +using System.Runtime.CompilerServices; namespace Views { @@ -15,9 +19,21 @@ namespace Views { //Point d'entrée de l'application public MasterManager MasterMgr { get; private set; } = new MasterManager(new Stubs()); - //L'utilisateur courant de l'application public User CurrentUser { get; set; } + private Recipe currentRecipe { get; set; } + public Recipe CurrentRecipe + { + get => currentRecipe; + set + { + currentRecipe = value; + OnPropertyChanged(nameof(CurrentRecipe)); + } + + + + } //collection de recette de l'application public RecipeCollection AllRecipes { get; set; } @@ -29,7 +45,7 @@ namespace Views { CurrentUser = MasterMgr.DataMgr.GetUsers().Last(); AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes"); - + CurrentRecipe = MasterMgr.DataMgr.GetRecipes().First(); InitializeComponent(); // Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) => @@ -51,5 +67,6 @@ namespace Views MainPage = new Home(); //MainPage = new MyPosts(); } + } } diff --git a/MCTG/Views/Home.xaml b/MCTG/Views/Home.xaml index 45dad31..be4773b 100644 --- a/MCTG/Views/Home.xaml +++ b/MCTG/Views/Home.xaml @@ -68,9 +68,10 @@ CaseImageSource="room_service_icon.png" Title="{Binding Title}"/>--> - + Source="{Binding Image}" + Clicked="OnImageClicked"/>