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.

88 lines
2.8 KiB

using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace TheGameExtreme.view
{
public partial class GamePreparationPage : ContentPage
{
private string instructionText;
public string InstructionText
{
get { return instructionText; }
set
{
instructionText = value;
OnPropertyChanged("InstructionText");
}
}
public List<int> listNbPlayer = new List<int> { 1, 2, 3, 4, 5 };
public GamePreparationPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
Instruction.SetBinding(Label.TextProperty, new Binding("InstructionText", source: this));
InstructionText = AppRessource.StrPlayerSelection;
PlayerSelecter.ItemsSource = listNbPlayer;
PlayerSelecter.SelectedIndex = 0;
}
private async void Back(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
private async void Play(object sender, EventArgs args)
{
List<string> playersNames = new List<string>();
for (int i = 0; i < NameList.Children.Count; i++)
{
playersNames.Add(((Entry)NameList.Children[i]).Text);
if (string.IsNullOrWhiteSpace(playersNames[playersNames.Count - 1]))
{
await DisplayAlert("Erreur pseudo", AppRessource.StrEnterPseudo, "OK");
return;
}
}
await Navigation.PushAsync(new MainPage(playersNames));
}
private void ChangedPseudo(object sender, EventArgs args)
{
while (NameList.Children.Count != (int)PlayerSelecter.SelectedItem)
{
if (NameList.Children.Count < (int)PlayerSelecter.SelectedItem)
{
Entry e = new Entry
{
Placeholder = "Pseudo",
BackgroundColor = (Color)Application.Current.Resources["SkyBlueColor"]
};
//Frame myFrame = new Frame
//{
// BackgroundColor = (Color)Application.Current.Resources["SkyBlueColor"],
// HeightRequest = 45,
// VerticalOptions = LayoutOptions.Center,
// HorizontalOptions = LayoutOptions.Center,
// WidthRequest = 120,
// CornerRadius = 10,
// Content = e
//};
NameList.Children.Add(e);
}
else
{
NameList.Children.RemoveAt(NameList.Children.Count - 1);
}
}
}
}
}