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 listNbPlayer = new List { 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 playersNames = new List(); 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(myFrame); } else { NameList.Children.RemoveAt(NameList.Children.Count-1); } } } } }