/// <summary> /// Constructeur générique liste de recettes /// </summary> /// <param name="tab">Liste des recettes</param> /// <param name="isCommanding">Afficher l'interface de commande?</param> public RecipeList(string[] tab, bool isCommanding) { //création de la grille quantite = new TextBlock[tab.Length]; Grid grille = new Grid(); recettes = new RecipeContainer[tab.Length]; for (int i = 0; i < tab.Length; i++) { RowDefinition ligne = new RowDefinition(); ligne.Height = new GridLength(0, GridUnitType.Auto); grille.RowDefinitions.Add(ligne); } //remplissage des cases for (int i = 0; i < tab.Length; i++) { recettes[i] = new RecipeContainer(tab[i].Split(new string[] { "§" }, StringSplitOptions.RemoveEmptyEntries), isCommanding); Grid.SetRow(recettes[i].Grille, i); grille.Children.Add(recettes[i].Grille); Border bordure = new Border(); bordure.BorderThickness = new Thickness(1, 1, 1, 1); bordure.BorderBrush = System.Windows.Media.Brushes.DarkGray; bordure.Margin = new Thickness(4, 2, 4, 2); Grid.SetRow(bordure, i); grille.Children.Add(bordure); quantite[i] = recettes[i].quantite; } scroll = new ScrollViewer(); scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroll.Content = grille; }
public CommandeContainer(string infos) { //On récupère les infos sur la commande string[] info = infos.Split(new string[] { "§" }, StringSplitOptions.RemoveEmptyEntries); //On récupère les recettes List <string> liste = CookingCore_Alexandre_FORESTIER_Charlotte_PELLERIN.Commande.getRecettes(info[0]); //On met les infos de la commande dans une entête ItemContainer item = new ItemContainer(info, false, 1); grille = new Grid(); for (int i = 0; i < liste.Count + 1; i++) { RowDefinition ligne = new RowDefinition(); ligne.Height = new GridLength(1, GridUnitType.Auto); grille.RowDefinitions.Add(ligne); if (i == 0) { //C'est la première ligne il faut rajouter l'entête généréé précédemment grille.Children.Add(item.grille); } else { //Sinon il s'agis de recettes on les affiches string[] vals = liste[i - 1].Split(new string[] { "§" }, StringSplitOptions.RemoveEmptyEntries); RecipeContainer recette = new RecipeContainer(CookingCore_Alexandre_FORESTIER_Charlotte_PELLERIN.Recette.GetRecipe(vals[0]).Split(new string[] { "§" }, StringSplitOptions.RemoveEmptyEntries), false, Convert.ToInt32(vals[1])); Grid.SetRow(recette.Grille, i); grille.Children.Add(recette.Grille); } } }