diff --git a/source/Trek-12/Models/Game/Player.cs b/source/Trek-12/Models/Game/Player.cs index f363eb4..97940d4 100644 --- a/source/Trek-12/Models/Game/Player.cs +++ b/source/Trek-12/Models/Game/Player.cs @@ -1,15 +1,37 @@ -namespace Models.Game +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace Models.Game { /// /// Represents a player in the game. /// - public class Player + public class Player : INotifyPropertyChanged { + + public event PropertyChangedEventHandler? PropertyChanged; + + void OnPropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + /// /// It is he pseudo of the player. /// - public string Pseudo { get; private set; } + private string _pseudo; + public string Pseudo + { + get => _pseudo; + set + { + if (_pseudo == value) + return; + _pseudo = value; + OnPropertyChanged(); + } + } + private int hairCount; /// /// It is the profile picture of the player. @@ -46,6 +68,7 @@ ProfilePicture = profilePicture; } + /// /// Chooses the operation for the player. /// diff --git a/source/Trek-12/Stub/Stub.cs b/source/Trek-12/Stub/Stub.cs new file mode 100644 index 0000000..46a4511 --- /dev/null +++ b/source/Trek-12/Stub/Stub.cs @@ -0,0 +1,51 @@ +using System.Collections.ObjectModel; +using System.Data; +using System.Numerics; +using Models.Game; + +namespace Stub +{ + public class Stub + { + public ReadOnlyObservableCollection ListPlayer { get; private set; } + private readonly ObservableCollection listplayer = new ObservableCollection(); + + public Stub() + { + LoadPlayer(); + ListPlayer = new ReadOnlyObservableCollection(listplayer); + } + + public void LoadPlayer() + { + + listplayer.Add(new Player()); + listplayer.Add(new Player("Lucas", "profile.jpg")); + listplayer.Add(new Player("relavergne", "profile.jpg")); + listplayer.Add(new Player("reneveu", "profile.jpg")); + + } + + public void Add(string pseudo, string profilePicture) + { + listplayer.Add(new Player(pseudo, profilePicture)); + } + + public void Pop(string pseudo, string profilePicture) + { + listplayer.Remove(new Player(pseudo, profilePicture)); + } + public bool Modify(string pseudo, string newpseudo) + { + foreach(var index in listplayer) + { + if (index.Pseudo == pseudo) + { + index.Pseudo = newpseudo; + return true; + } + } + return false; + } + } +} diff --git a/source/Trek-12/Stub/Stub.csproj b/source/Trek-12/Stub/Stub.csproj new file mode 100644 index 0000000..8dcc508 --- /dev/null +++ b/source/Trek-12/Stub/Stub.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/source/Trek-12/Trek-12.sln b/source/Trek-12/Trek-12.sln index fda4705..4ce1243 100644 --- a/source/Trek-12/Trek-12.sln +++ b/source/Trek-12/Trek-12.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataContractPersistence", "DataContractPersistence\DataContractPersistence.csproj", "{FC6A23C3-A1E3-4BF4-85B0-404D8574E190}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stub", "Stub\Stub.csproj", "{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,10 @@ Global {FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Release|Any CPU.Build.0 = Release|Any CPU + {49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/source/Trek-12/Trek-12/Trek-12.csproj b/source/Trek-12/Trek-12/Trek-12.csproj index 51d65e3..6fa80dd 100644 --- a/source/Trek-12/Trek-12/Trek-12.csproj +++ b/source/Trek-12/Trek-12/Trek-12.csproj @@ -63,6 +63,11 @@ + + + + + PageLeaderBoard.xaml @@ -82,9 +87,6 @@ MSBuild:Compile - - MSBuild:Compile - diff --git a/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml b/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml index 3b15b2c..474f88c 100644 --- a/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml +++ b/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml @@ -1,7 +1,8 @@ + x:Class="Trek_12.Views.Components.viewsProfils" + x:Name="this"> - - diff --git a/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml.cs b/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml.cs index 330b631..a203e56 100644 --- a/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml.cs +++ b/source/Trek-12/Trek-12/Views/Components/viewsProfils.xaml.cs @@ -6,4 +6,23 @@ public partial class viewsProfils : ContentView { InitializeComponent(); } + + public static readonly BindableProperty PseudoProperty = + BindableProperty.Create("Pseudo", typeof(string), typeof(ContentLeaderBoard), "Profile n°*"); + + public string Pseudo + { + get => (string)GetValue(PseudoProperty); + set => SetValue(PseudoProperty, value); + } + + + public static readonly BindableProperty ProfilePictureProperty = + BindableProperty.Create("ProfilePicture", typeof(string), typeof(ContentLeaderBoard), "profile.jpg"); + + public string ProfilePicture + { + get => (string)GetValue(ProfilePictureProperty); + set => SetValue(ProfilePictureProperty, value); + } } \ No newline at end of file diff --git a/source/Trek-12/Trek-12/Views/PageLeaderBoard.xaml b/source/Trek-12/Trek-12/Views/PageLeaderBoard.xaml index fb1dff7..2dd8ff3 100644 --- a/source/Trek-12/Trek-12/Views/PageLeaderBoard.xaml +++ b/source/Trek-12/Trek-12/Views/PageLeaderBoard.xaml @@ -1,43 +1,43 @@ - - - - - - - - - - - - - - - -