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.
95 lines
2.2 KiB
95 lines
2.2 KiB
using Microsoft.Maui.Controls.PlatformConfiguration;
|
|
using MusiLib.Model;
|
|
using System.Diagnostics;
|
|
|
|
namespace MusiLib.Views;
|
|
|
|
|
|
public partial class Partition : ContentPage
|
|
{
|
|
|
|
public Manager MyManager => (App.Current as App).MyManager;
|
|
|
|
public int IdTab { get; set; }
|
|
|
|
|
|
public Partition()
|
|
{
|
|
InitializeComponent();
|
|
BindingContext = MyManager;
|
|
}
|
|
|
|
public Partition(int id)
|
|
{
|
|
InitializeComponent();
|
|
IdTab = id;
|
|
Part.BindingContext = MyManager.partitions[IdTab];
|
|
Part2.BindingContext = MyManager;
|
|
}
|
|
|
|
private void Play_Music(object sender, EventArgs e)
|
|
{
|
|
Button button = (Button)sender;
|
|
if (!IPlayMusic.isMusicBeginning)
|
|
{
|
|
IPlayMusic.beginMusic(MyManager.partitions[IdTab].Son);
|
|
button.Text = "Pause";
|
|
}
|
|
else if(!IPlayMusic.isMusicPlaying)
|
|
{
|
|
IPlayMusic.playMusic();
|
|
button.Text = "Pause";
|
|
}
|
|
else
|
|
{
|
|
IPlayMusic.pauseMusic();
|
|
button.Text = "Jouer";
|
|
}
|
|
}
|
|
|
|
private void Stop_Music(object sender, EventArgs e)
|
|
{
|
|
IPlayMusic.stopMusic();
|
|
Button button = (Button)FindByName("play_music_button");
|
|
button.Text = "Jouer";
|
|
}
|
|
|
|
protected override bool OnBackButtonPressed()
|
|
{
|
|
IPlayMusic.stopMusic();
|
|
return base.OnBackButtonPressed();
|
|
}
|
|
|
|
protected override void OnDisappearing()
|
|
{
|
|
base.OnDisappearing();
|
|
IPlayMusic.stopMusic();
|
|
}
|
|
|
|
protected override void OnAppearing()
|
|
{
|
|
base.OnAppearing();
|
|
Shell.Current.Navigating += Shell_Navigating;
|
|
}
|
|
|
|
private void Shell_Navigating(object sender, ShellNavigatingEventArgs e)
|
|
{
|
|
if (e.Source == ShellNavigationSource.ShellItemChanged)
|
|
{
|
|
IPlayMusic.stopMusic();
|
|
}
|
|
}
|
|
|
|
private void AddFavoriButton(object sender, EventArgs e)
|
|
{
|
|
if (!Utilisateur.Favoris.Contains(MyManager.partitions[IdTab]))
|
|
{
|
|
Utilisateur.Favoris.Add(MyManager.partitions[IdTab]);
|
|
}
|
|
else
|
|
{
|
|
Utilisateur.Favoris.Remove(MyManager.partitions[IdTab]);
|
|
}
|
|
}
|
|
}
|