diff --git a/Sources/Linaris/App.xaml.cs b/Sources/Linaris/App.xaml.cs index 26240a2..e31dc70 100644 --- a/Sources/Linaris/App.xaml.cs +++ b/Sources/Linaris/App.xaml.cs @@ -6,55 +6,19 @@ namespace Linaris; public partial class App : Application { - private Manager manager = new(new LinqXmlSerialization(FileSystem.Current.AppDataDirectory)); + public Manager Manager { get; set; } = new(new LinqXmlSerialization(FileSystem.Current.AppDataDirectory)); - public Manager Manager - { - get => manager; - set - { - manager = value; - } - } - - private FooterPage footerPage; - - public FooterPage FooterPage - { - get => footerPage; - set - { - footerPage = value; - } - } + public FooterPage FooterPage { get; set; } - private TimeSpan musicPosition = TimeSpan.FromSeconds(0); + public TimeSpan MusicPosition { get; set; } = TimeSpan.FromSeconds(0); - public TimeSpan MusicPosition - { - get => musicPosition; - set - { - musicPosition = value; - } - } - - private MediaElementState mediaState = MediaElementState.Paused; - - public MediaElementState MediaState - { - get => mediaState; - set - { - mediaState = value; - } - } + public MediaElementState MediaState { get; set; } = MediaElementState.Paused; public App() { InitializeComponent(); - footerPage = new FooterPage(); + FooterPage = new FooterPage(); MainPage = new AppShell(); } diff --git a/Sources/Linaris/Converters.cs b/Sources/Linaris/Converters.cs index f4e0f12..2189d2c 100644 --- a/Sources/Linaris/Converters.cs +++ b/Sources/Linaris/Converters.cs @@ -16,11 +16,6 @@ public class InverseBooleanConverter : IValueConverter public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - if (value is bool boolValue) - { - return !boolValue; - } - - return value; + return Convert(value, targetType, parameter, culture); } } \ No newline at end of file diff --git a/Sources/Linaris/EditPlaylistPage.xaml.cs b/Sources/Linaris/EditPlaylistPage.xaml.cs index 2b52ba4..2a456af 100644 --- a/Sources/Linaris/EditPlaylistPage.xaml.cs +++ b/Sources/Linaris/EditPlaylistPage.xaml.cs @@ -38,12 +38,9 @@ public partial class EditPlaylistPage : ContentPage return; } - if (sender is Image image) + if (sender is Image image && image.BindingContext is Playlist p) { - if (image.BindingContext is Playlist playlist) - { - playlist.ImageURL = result.FullPath; - } + p.ImageURL = result.FullPath; } } diff --git a/Sources/Linaris/MainPage.xaml.cs b/Sources/Linaris/MainPage.xaml.cs index c28d47d..0c3f141 100644 --- a/Sources/Linaris/MainPage.xaml.cs +++ b/Sources/Linaris/MainPage.xaml.cs @@ -23,13 +23,10 @@ public partial class MainPage : ContentPage async void GoToAlbum(object sender, EventArgs e) { - if (sender is Image image) + if (sender is Image image && image.BindingContext is Album album) { - if (image.BindingContext is Album album) - { - (Application.Current as App).Manager.CurrentAlbum = album; - await Navigation.PushAsync(new AlbumPage()); - } + (Application.Current as App).Manager.CurrentAlbum = album; + await Navigation.PushAsync(new AlbumPage()); } } diff --git a/Sources/Linaris/SearchBarView.xaml.cs b/Sources/Linaris/SearchBarView.xaml.cs index 8d711e7..d5a81d5 100644 --- a/Sources/Linaris/SearchBarView.xaml.cs +++ b/Sources/Linaris/SearchBarView.xaml.cs @@ -11,38 +11,11 @@ public partial class SearchBarView : ContentView { Manager Manager { get; set; } = (Application.Current as App).Manager; - private ObservableCollection albums = new ObservableCollection(); + public ObservableCollection Albums { get; set; } = new(); - public ObservableCollection Albums - { - get => albums; - set - { - albums = value; - } - } + public ObservableCollection InfoTitles { get; set; } = new(); - private ObservableCollection infoTitles = new ObservableCollection(); - - public ObservableCollection InfoTitles - { - get => infoTitles; - set - { - infoTitles = value; - } - } - - private ObservableCollection playlists = new ObservableCollection(); - - public ObservableCollection Playlists - { - get => playlists; - set - { - playlists = value; - } - } + public ObservableCollection Playlists { get; set; } = new(); public SearchBarView() { diff --git a/Sources/Model/Album.cs b/Sources/Model/Album.cs index 15cdca4..e8c5bd8 100644 --- a/Sources/Model/Album.cs +++ b/Sources/Model/Album.cs @@ -7,7 +7,7 @@ namespace Model { private static long nbAlbum = 0; - private long id; + private readonly long id; public long ID { @@ -85,21 +85,12 @@ namespace Model private string information = Manager.DEFAULT_DESC; - public ObservableCollection InfoTitles - { - get => infoTitles; - set - { - infoTitles = value; - } - } - - private ObservableCollection infoTitles = new ObservableCollection(); + public ObservableCollection InfoTitles { get; set; } = new(); public Album(string name, string imageURL, Artist artist, string description, string information) { id = nbAlbum; - nbAlbum++; + IncrementNbAlbum(); Name = name; ImageURL = imageURL; Artist = artist; @@ -110,6 +101,12 @@ namespace Model public Album() { Artist = new Artist(Manager.DEFAULT_NAME); + IncrementNbAlbum(); + } + + public static void IncrementNbAlbum() + { + nbAlbum++; } public void AddTitle(InfoTitle title) diff --git a/Sources/Model/CustomTitle.cs b/Sources/Model/CustomTitle.cs index a940115..04356ea 100644 --- a/Sources/Model/CustomTitle.cs +++ b/Sources/Model/CustomTitle.cs @@ -1,10 +1,8 @@ using Model.Stub; -using System.ComponentModel; -using System.Runtime.CompilerServices; namespace Model; -public class CustomTitle : Title, INotifyPropertyChanged +public class CustomTitle : Title, IEquatable { public string Path diff --git a/Sources/Model/InfoTitle.cs b/Sources/Model/InfoTitle.cs index fd4ea14..2342e53 100644 --- a/Sources/Model/InfoTitle.cs +++ b/Sources/Model/InfoTitle.cs @@ -32,16 +32,7 @@ public class InfoTitle : Title public Genre Genre { get; set; } - private long albumID; - - public long AlbumID - { - get => albumID; - set - { - albumID = value; - } - } + public long AlbumID { get; set; } public InfoTitle(string name, string imageURL, string information, string description, Genre genre, long albumID) : base(name,imageURL,information) { diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index 6909238..02df06f 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -118,27 +118,9 @@ public class Manager : INotifyPropertyChanged } } - private Dictionary> albumsFromArtist; + public Dictionary> AlbumsFromArtist { get; set; } - public Dictionary> AlbumsFromArtist - { - get => albumsFromArtist; - set - { - albumsFromArtist = value; - } - } - - private Dictionary> infoTitlesFromArtist; - - public Dictionary> InfoTitlesFromArtist - { - get => infoTitlesFromArtist; - set - { - infoTitlesFromArtist = value; - } - } + public Dictionary> InfoTitlesFromArtist { get; set; } public Manager(IDataManager dataManager) { diff --git a/Sources/Model/Serialization/LINQ_XML_Serialization.cs b/Sources/Model/Serialization/LINQ_XML_Serialization.cs index 15e88d8..5a7a03b 100644 --- a/Sources/Model/Serialization/LINQ_XML_Serialization.cs +++ b/Sources/Model/Serialization/LINQ_XML_Serialization.cs @@ -7,14 +7,13 @@ namespace Model.Serialization; public class LinqXmlSerialization : IDataManager { - private string XMLPATH; + private readonly string XMLPATH; - private string XMLFILEPLAYLISTS; + private readonly string XMLFILEPLAYLISTS; - private string XMLFILECUSTOMS; + private readonly string XMLFILECUSTOMS; - - private StubInfoTitle stubInfoTitle = new(); + private readonly StubInfoTitle stubInfoTitle = new(); public StubInfoTitle StubInfoTitle { @@ -275,7 +274,7 @@ public class LinqXmlSerialization : IDataManager artists = StubInfoTitle.StubAlbum.StubArtist.GetArtists(); } - public void SaveArtists() + public static void SaveArtists() { // Don't do anything because it's static data } @@ -347,7 +346,7 @@ public class LinqXmlSerialization : IDataManager albums = StubInfoTitle.StubAlbum.GetAlbums(); } - public void SaveAlbums() + public static void SaveAlbums() { // Don't do anything because it's static data } @@ -361,7 +360,7 @@ public class LinqXmlSerialization : IDataManager } } - public void SaveInfoTitles() + public static void SaveInfoTitles() { // Don't do anything because it's static data }