From 8416ffa323ce1bf9c4a8452e3bde408be10ce0e4 Mon Sep 17 00:00:00 2001 From: Baptiste ARNAUD Date: Thu, 12 Dec 2019 16:53:17 +0100 Subject: [PATCH] mise en place desslider --- .../Resources/Resource.designer.cs | 8 +- TheGameExtreme/Resx/AppResources.en-US.resx | 2 +- TheGameExtreme/Resx/AppResources.en.resx | 2 +- TheGameExtreme/view/GamePreparationPage.xaml | 59 +++++-- .../view/GamePreparationPage.xaml.cs | 151 +++++++++++++----- 5 files changed, 162 insertions(+), 60 deletions(-) diff --git a/TheGameExtreme.Android/Resources/Resource.designer.cs b/TheGameExtreme.Android/Resources/Resource.designer.cs index 66d6375..4d79f6d 100644 --- a/TheGameExtreme.Android/Resources/Resource.designer.cs +++ b/TheGameExtreme.Android/Resources/Resource.designer.cs @@ -1,11 +1,11 @@ #pragma warning disable 1591 //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ diff --git a/TheGameExtreme/Resx/AppResources.en-US.resx b/TheGameExtreme/Resx/AppResources.en-US.resx index 00b5a67..597ce71 100644 --- a/TheGameExtreme/Resx/AppResources.en-US.resx +++ b/TheGameExtreme/Resx/AppResources.en-US.resx @@ -262,7 +262,7 @@ There is therefore no maximum card limit to play per round. However, it is advis tenth - + thousandth diff --git a/TheGameExtreme/Resx/AppResources.en.resx b/TheGameExtreme/Resx/AppResources.en.resx index 6d2ec6e..23bf229 100644 --- a/TheGameExtreme/Resx/AppResources.en.resx +++ b/TheGameExtreme/Resx/AppResources.en.resx @@ -262,7 +262,7 @@ There is therefore no maximum card limit to play per round. However, it is advis tenth - + thousandth diff --git a/TheGameExtreme/view/GamePreparationPage.xaml b/TheGameExtreme/view/GamePreparationPage.xaml index f7895da..03571d3 100644 --- a/TheGameExtreme/view/GamePreparationPage.xaml +++ b/TheGameExtreme/view/GamePreparationPage.xaml @@ -71,13 +71,25 @@ FontSize="16" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"/> - + + + + WidthRequest="150" + Value="1"/> - + + + VerticalOptions="Center" + WidthRequest="150" + Value="4"/> - + + VerticalOptions="Center" + WidthRequest="150" + Value="100"/> diff --git a/TheGameExtreme/view/GamePreparationPage.xaml.cs b/TheGameExtreme/view/GamePreparationPage.xaml.cs index b100345..09d9ed0 100644 --- a/TheGameExtreme/view/GamePreparationPage.xaml.cs +++ b/TheGameExtreme/view/GamePreparationPage.xaml.cs @@ -8,9 +8,9 @@ namespace TheGameExtreme.view { public partial class GamePreparationPage : ContentPage { - public List listNbPlayer = new List { 1, 2, 3, 4, 5 }; - public List listGameMode = new List { AppResources.TypeValueWhole, AppResources.TypeValueRelative, AppResources.TypeValueTenthFract, AppResources.TypeValueHundredthFract, AppResources.TypeValueThousandthFract, AppResources.TypeValuefractionated, AppResources.TypeValueTenth, AppResources.TypeValueHundredth }; - public List listNbStack = new List { 4, 6, 8 }; + + public List listGameMode = new List { AppResources.TypeValueWhole, AppResources.TypeValueRelative, AppResources.TypeValueTenth, AppResources.TypeValueHundredth, AppResources.TypeValueThousandthFract, AppResources.TypeValuefractionated }; + //public List listNbStack = new List { 4, 6, 8 }; public List listNbCard = new List { 100, 80, 60, 40 }; @@ -21,17 +21,24 @@ namespace TheGameExtreme.view NavigationPage.SetHasNavigationBar(this, false); LoadParameterName(); + + nbPlayersChoose.SetBinding(Label.TextProperty, new Binding("Value", source: PlayerSelecter)); + nbstacks.SetBinding(Label.TextProperty, new Binding("Value", source: SelectNbStack)); + nbCard.SetBinding(Label.TextProperty, new Binding("Value", source: SelectNbCard)); + + + + - PlayerSelecter.ItemsSource = listNbPlayer; LoadParameterNbPlayerGamePreparation(); SelectMode.ItemsSource = listGameMode; LoadParameterGameModeValueGamePreparation(); - SelectNbStack.ItemsSource = listNbStack; + //SelectNbStack.ItemsSource = listNbStack; LoadParameterNbStacksGamePreparation(); - SelectNbCard.ItemsSource = listNbCard; + //SelectNbCard.ItemsSource = listNbCard; LoadParameterNbCardsGamePreparation(); } @@ -39,11 +46,11 @@ namespace TheGameExtreme.view private async void Back(object sender, EventArgs e) { - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); + IOGamePreparation.SaveParamaterGamePreparationNbPlayers((int)PlayerSelecter.Value); IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); - if ((int)PlayerSelecter.SelectedItem == 1) + IOGamePreparation.SaveParameterGamePreparationNbStacks((int)SelectNbStack.Value); + IOGamePreparation.SaveParameterGamePreparationNbCards((int)SelectNbCard.Value); + if ((int)PlayerSelecter.Value == 1) { IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); } @@ -52,11 +59,11 @@ namespace TheGameExtreme.view protected override bool OnBackButtonPressed() { - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); + IOGamePreparation.SaveParamaterGamePreparationNbPlayers((int)PlayerSelecter.Value); IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); - if ((int)PlayerSelecter.SelectedItem == 1) + IOGamePreparation.SaveParameterGamePreparationNbStacks((int)SelectNbStack.Value); + IOGamePreparation.SaveParameterGamePreparationNbCards((int)SelectNbCard.Value); + if ((int)PlayerSelecter.Value == 1) { IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); } @@ -77,53 +84,113 @@ namespace TheGameExtreme.view return; } } - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); + IOGamePreparation.SaveParamaterGamePreparationNbPlayers((int)PlayerSelecter.Value); IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); + IOGamePreparation.SaveParameterGamePreparationNbStacks((int)SelectNbStack.Value); + IOGamePreparation.SaveParameterGamePreparationNbCards((int)SelectNbCard.Value); IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); - await Navigation.PushAsync(new MainPage(playersNames, (int)SelectNbStack.SelectedItem, (int)SelectMode.SelectedIndex, (int)SelectNbCard.SelectedItem)); + await Navigation.PushAsync(new MainPage(playersNames, (int)SelectNbStack.Value, (int)SelectMode.SelectedIndex, (int)SelectNbCard.Value)); } + private bool canModif = true; private void ChangedPseudo(object sender, EventArgs args) { - if ((int)PlayerSelecter.SelectedItem == 1) + if (canModif) { - LoadParameterName(); + canModif = false; + PlayerSelecter.Value = Math.Round(PlayerSelecter.Value); + + if ((int)PlayerSelecter.Value == 1) + { + LoadParameterName(); + } + else + { + FirstEntry.Text = ""; + } + + while (NameList.Children.Count - 1 != (int)PlayerSelecter.Value) + { + if (NameList.Children.Count - 1 < (int)PlayerSelecter.Value) + { + + Entry e = new Entry + { + Placeholder = "Pseudo", + BackgroundColor = (Color)Application.Current.Resources["Gold"], + WidthRequest = 200, + MinimumWidthRequest = 50, + HorizontalOptions = LayoutOptions.Center, + MaxLength = 18, + IsTextPredictionEnabled = false + }; + + NameList.Children.Add(e); + + } + else + { + NameList.Children.RemoveAt(NameList.Children.Count - 1); + } + + } + canModif = true; } - else + } + + private void ChangedStacks(object sender, EventArgs args) + { + if (canModif) { - FirstEntry.Text = ""; + canModif = false; + + if (SelectNbStack.Value < 5) + { + SelectNbStack.Value = 4; + } + else if (SelectNbStack.Value < 7) + { + SelectNbStack.Value = 6; + } + else + { + SelectNbStack.Value = 8; + } + + canModif = true; } - while (NameList.Children.Count - 1 != (int)PlayerSelecter.SelectedItem) + } + + private void ChangedNbCards(object sender, EventArgs args) + { + if (canModif) { - if (NameList.Children.Count - 1 < (int)PlayerSelecter.SelectedItem) - { + canModif = false; - Entry e = new Entry - { - Placeholder = "Pseudo", - BackgroundColor = (Color)Application.Current.Resources["Gold"], - WidthRequest = 150, - MinimumWidthRequest = 50, - HorizontalOptions = LayoutOptions.Center, - MaxLength = 18, - IsTextPredictionEnabled = false - }; - - - NameList.Children.Add(e); + if (SelectNbCard.Value < 50) + { + SelectNbCard.Value = 40; + } + else if (SelectNbCard.Value < 70) + { + SelectNbCard.Value = 60; + } + else if (SelectNbCard.Value < 90) + { + SelectNbCard.Value = 80; } else { - NameList.Children.RemoveAt(NameList.Children.Count - 1); + SelectNbCard.Value = 100; } + canModif = true; } } + public void LoadParameterNbPlayerGamePreparation() { int nbJoueurs = IOGamePreparation.LoadParameterGamePreparationNbPlayers(); - PlayerSelecter.SelectedIndex = nbJoueurs; + PlayerSelecter.Value = nbJoueurs; } public void LoadParameterGameModeValueGamePreparation() @@ -135,12 +202,12 @@ namespace TheGameExtreme.view public void LoadParameterNbStacksGamePreparation() { int nbStackSer = IOGamePreparation.LoadParamaterGamePreparationNbStacks(); - SelectNbStack.SelectedIndex = nbStackSer; + SelectNbStack.Value = nbStackSer; } public void LoadParameterNbCardsGamePreparation() { int nbCards = IOGamePreparation.LoadParameterGamePreparationNbCards(); - SelectNbCard.SelectedIndex = nbCards; + SelectNbCard.Value = nbCards; } public void LoadParameterName() {