Boutons fonctionnels dans pageProfils
continuous-integration/drone/push Build is passing Details

pull/94/head
Remi NEVEU 11 months ago
parent 43877415f9
commit 0ff2da324f

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Models.Game
{
@ -8,10 +9,29 @@ namespace Models.Game
/// </summary>
public class Player : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary>
/// It is he pseudo of the player.
/// </summary>
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;
/// <summary>
/// It is the profile picture of the player.
@ -48,15 +68,6 @@ namespace Models.Game
ProfilePicture = profilePicture;
}
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
/// <summary>
/// Chooses the operation for the player.

@ -21,9 +21,31 @@ namespace Stub
listplayer.Add(new Player());
listplayer.Add(new Player("Lucas", "profile.jpg"));
listplayer.Add(new Player("relavergne"));
listplayer.Add(new Player("reneveu"));
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;
}
}
}

@ -27,9 +27,9 @@
</CollectionView>
<HorizontalStackLayout Grid.Row="2" HorizontalOptions="Center" Spacing="50">
<Button Text="Modifier" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Créer" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Supprimer" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Modifier" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedModify"/>
<Button Text="Créer" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedAdd"/>
<Button Text="Supprimer" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedPop"/>
</HorizontalStackLayout>
</Grid>

@ -1,5 +1,8 @@
namespace Trek_12.Views;
using Stub;
using System.Diagnostics;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
public partial class PageProfils : ContentPage
{
@ -10,4 +13,54 @@ public partial class PageProfils : ContentPage
InitializeComponent();
BindingContext = MyStub;
}
}
async void Button_ClickedAdd(System.Object sender, System.EventArgs e)
{
string result = await DisplayPromptAsync("Info", $"Choose a name : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
{
Debug.WriteLine("bam, added");
MyStub.Add(result, "profile.jpg");
}
}
async void Button_ClickedPop(System.Object sender, System.EventArgs e)
{
string result = await DisplayPromptAsync("Info", $"Choose a name to delete : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
{
Debug.WriteLine("bam, deleted");
MyStub.Pop(result, "profile.jpg");
}
else Debug.WriteLine("Pseudo not found");
}
async void Button_ClickedModify(System.Object sender, System.EventArgs e)
{
string result = await DisplayPromptAsync("Info", $"Choose a name to modify : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
{
string tomodify = await DisplayPromptAsync("Info", $"How will you rename it ?: ", "Ok");
Debug.WriteLine("Answer: " + tomodify);
if (tomodify != null)
{
Debug.WriteLine("bam, modified");
bool ismodified = MyStub.Modify(result, tomodify);
if (ismodified)
{
Debug.WriteLine("Modified");
}
else Debug.WriteLine("Player not found");
}
}
else Debug.WriteLine("Did not found");
}
}

Loading…
Cancel
Save