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.

72 lines
2.2 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
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);
}
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 = "Enter your pseudo",
BackgroundColor = (Color)Application.Current.Resources["SkyBlueColor"]
};
NameList.Children.Add(e);
}
else
{
NameList.Children.RemoveAt(NameList.Children.Count-1);
}
}
}
}
}