You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.1 KiB
97 lines
2.1 KiB
using MusiLib.Model;
|
|
using System.Diagnostics;
|
|
|
|
namespace MusiLib.Views;
|
|
|
|
|
|
public partial class Favoris : ContentPage, IAllowClick
|
|
{
|
|
|
|
public Manager MyManager => (App.Current as App).MyManager;
|
|
|
|
|
|
public Favoris()
|
|
{
|
|
InitializeComponent();
|
|
chargerFavoris();
|
|
}
|
|
|
|
|
|
private void GoToAccueilByLogoButton(object sender, EventArgs e)
|
|
{
|
|
if (!IAllowClick.AllowTap) return;
|
|
else IAllowClick.AllowTap = false;
|
|
|
|
Navigation.PopAsync();
|
|
|
|
IAllowClick.ResumeTap();
|
|
}
|
|
|
|
|
|
private void GoToPartitionButton(object sender, EventArgs e)
|
|
{
|
|
if (!IAllowClick.AllowTap) return;
|
|
else IAllowClick.AllowTap = false;
|
|
|
|
var button = (ImageButton)sender;
|
|
var idAutomation = button.AutomationId;
|
|
|
|
if (int.TryParse(idAutomation, out int id))
|
|
{
|
|
Navigation.PushAsync(new Partition(id));
|
|
}
|
|
|
|
IAllowClick.ResumeTap();
|
|
}
|
|
|
|
|
|
private void chargerFavoris()
|
|
{
|
|
int imagesParLigne = 3;
|
|
int indice = 0;
|
|
|
|
for (int i = 0; i < Utilisateur.Favoris.Count; i++)
|
|
{
|
|
Model.Partition favoris = Utilisateur.Favoris[i];
|
|
|
|
ImageButton imageButton = new ImageButton
|
|
{
|
|
Source = favoris.Image[0],
|
|
WidthRequest = 175,
|
|
HeightRequest = 175,
|
|
AutomationId = indice.ToString(),
|
|
};
|
|
|
|
imageButton.Clicked += GoToPartitionButton;
|
|
|
|
int ligne = 1 + (indice / imagesParLigne);
|
|
int colonne = indice % imagesParLigne;
|
|
|
|
imageButton.Margin = GetImageButtonMargin(colonne);
|
|
|
|
Grid.SetRow(imageButton, ligne);
|
|
Grid.SetColumn(imageButton, colonne);
|
|
grille.Children.Add(imageButton);
|
|
|
|
indice++;
|
|
}
|
|
}
|
|
|
|
private Thickness GetImageButtonMargin(int colonne)
|
|
{
|
|
if (colonne == 0)
|
|
{
|
|
return new Thickness(30, 0, 0, 0);
|
|
}
|
|
else if (colonne == 1)
|
|
{
|
|
return new Thickness(90, 0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
return new Thickness(150, 0, 0, 0);
|
|
}
|
|
}
|
|
|
|
|
|
} |