|
|
|
@ -1,7 +1,12 @@
|
|
|
|
|
using CommunityToolkit.Maui.Core.Primitives;
|
|
|
|
|
using CommunityToolkit.Maui.Views;
|
|
|
|
|
using Microsoft.Maui.Controls;
|
|
|
|
|
using Microsoft.Maui.Platform;
|
|
|
|
|
using Model;
|
|
|
|
|
using Model.Stub;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace Linaris;
|
|
|
|
|
|
|
|
|
@ -87,11 +92,15 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sender is Button button)
|
|
|
|
|
foreach (var result in results)
|
|
|
|
|
{
|
|
|
|
|
foreach (var result in results)
|
|
|
|
|
string path = Path.Combine(FileSystem.Current.AppDataDirectory, "customs");
|
|
|
|
|
if (!Path.Exists(path)) Directory.CreateDirectory(path);
|
|
|
|
|
string fullPath = Path.Combine(path, result.FileName);
|
|
|
|
|
if (!File.Exists(fullPath))
|
|
|
|
|
{
|
|
|
|
|
CustomTitle custom = new (result.FileName, "none.png", "", result.FullPath);
|
|
|
|
|
File.Copy(result.FullPath, fullPath);
|
|
|
|
|
CustomTitle custom = new(result.FileName, "none.png", "", fullPath);
|
|
|
|
|
if (!IsCustomTitleInCollection(custom))
|
|
|
|
|
{
|
|
|
|
|
AddCustomTitle(custom);
|
|
|
|
@ -149,6 +158,7 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
(Application.Current as App).Manager.RemoveCustomTitle(titleToRemove);
|
|
|
|
|
customTitles.Remove(titleToRemove);
|
|
|
|
|
File.Delete(titleToRemove.Path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -156,22 +166,20 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
|
|
|
|
|
// Show methods
|
|
|
|
|
|
|
|
|
|
void ShowSubMenu(object sender, EventArgs e)
|
|
|
|
|
async void ShowSubMenu(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is Image image)
|
|
|
|
|
if (sender is Image image && image.BindingContext is CustomTitle customTitle)
|
|
|
|
|
{
|
|
|
|
|
if (image.BindingContext is CustomTitle customTitle)
|
|
|
|
|
if (!customTitle.IsSubMenuVisible)
|
|
|
|
|
{
|
|
|
|
|
if (!customTitle.IsSubMenuVisible)
|
|
|
|
|
{
|
|
|
|
|
ResetAll(sender, e);
|
|
|
|
|
customTitle.IsSubMenuVisible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ResetSubMenus(sender, e);
|
|
|
|
|
}
|
|
|
|
|
ResetAll(sender, e);
|
|
|
|
|
customTitle.IsSubMenuVisible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ResetSubMenus(sender, e);
|
|
|
|
|
}
|
|
|
|
|
await MainScrollView.ScrollToAsync(image, ScrollToPosition.Center, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -254,9 +262,16 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnAppearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnAppearing();
|
|
|
|
|
GetFooterData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDisappearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnDisappearing();
|
|
|
|
|
SetFooterData();
|
|
|
|
|
ContentView footer = this.FindByName<ContentView>("Footer");
|
|
|
|
|
var musicElement = footer?.FindByName<MediaElement>("music");
|
|
|
|
|
if (musicElement != null)
|
|
|
|
@ -265,6 +280,52 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetFooterData()
|
|
|
|
|
{
|
|
|
|
|
FooterPage FooterPage = (Application.Current as App).FooterPage;
|
|
|
|
|
Footer.CurrentPlaying = FooterPage.CurrentPlaying;
|
|
|
|
|
Footer.PlayImage = FooterPage.PlayImage;
|
|
|
|
|
Footer.LoopImage = FooterPage.LoopImage;
|
|
|
|
|
Footer.ShuffleImage = FooterPage.ShuffleImage;
|
|
|
|
|
Footer.Volume = FooterPage.Volume;
|
|
|
|
|
Footer.Position = FooterPage.Position;
|
|
|
|
|
Footer.Duration = FooterPage.Duration;
|
|
|
|
|
Footer.SliderPosition = FooterPage.SliderPosition;
|
|
|
|
|
|
|
|
|
|
// Place l'index de lecture de la musique à la position du slider
|
|
|
|
|
var musicElement = Footer?.FindByName<MediaElement>("music");
|
|
|
|
|
musicElement.Dispatcher.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
|
|
|
|
|
{
|
|
|
|
|
musicElement.SeekTo((Application.Current as App).MusicPosition);
|
|
|
|
|
if ((Application.Current as App).MediaState == MediaElementState.Playing)
|
|
|
|
|
{
|
|
|
|
|
musicElement.Play();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
musicElement.Pause();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetFooterData()
|
|
|
|
|
{
|
|
|
|
|
FooterPage FooterPage = (Application.Current as App).FooterPage;
|
|
|
|
|
FooterPage.CurrentPlaying = (Application.Current as App).Manager.CurrentPlaying;
|
|
|
|
|
FooterPage.PlayImage = Footer.PlayImage;
|
|
|
|
|
FooterPage.LoopImage = Footer.LoopImage;
|
|
|
|
|
FooterPage.ShuffleImage = Footer.ShuffleImage;
|
|
|
|
|
FooterPage.Volume = Footer.Volume;
|
|
|
|
|
FooterPage.Position = Footer.Position;
|
|
|
|
|
FooterPage.Duration = Footer.Duration;
|
|
|
|
|
FooterPage.SliderPosition = Footer.SliderPosition;
|
|
|
|
|
|
|
|
|
|
var musicElement = Footer?.FindByName<MediaElement>("music");
|
|
|
|
|
(Application.Current as App).MusicPosition = musicElement.Position;
|
|
|
|
|
(Application.Current as App).MediaState = musicElement.CurrentState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Others
|
|
|
|
|
|
|
|
|
@ -278,11 +339,15 @@ public partial class LocalFilesPage : ContentPage
|
|
|
|
|
if (musicElement != null)
|
|
|
|
|
{
|
|
|
|
|
musicElement.Source = customTitle.Path;
|
|
|
|
|
musicElement.SeekTo(TimeSpan.FromSeconds(0));
|
|
|
|
|
musicElement.Play();
|
|
|
|
|
}
|
|
|
|
|
if (footer is FooterPage footerPage)
|
|
|
|
|
{
|
|
|
|
|
footerPage.CurrentPlaying = customTitle;
|
|
|
|
|
}
|
|
|
|
|
(Application.Current as App).Manager.CurrentPlaylist = null;
|
|
|
|
|
(Application.Current as App).Manager.CurrentPlaying = customTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|