Add picker cartes + remise en place des composants graphique sur la gamepage preparation

master
Baptiste ARNAUD 5 years ago
parent c6c0aa4f29
commit ff20723cf3

@ -11,6 +11,7 @@ namespace TheGameExtreme.IO
static string pathPlayers = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NbPlayers.xml");
static string pathGameModeValue = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "GameModeValue.xml");
static string pathNbStacks = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NbStacks.xml");
static string pathNbCards = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NbCards.xml");
public static void SaveParamaterGamePreparationNbPlayers(int nbPlayers)
{
@ -87,5 +88,30 @@ namespace TheGameExtreme.IO
return 0;
}
}
public static void SaveParameterGamePreparationNbCards(int nbCard)
{
XmlSerializer xs = new XmlSerializer(typeof(int));
TextWriter tw = new StreamWriter(pathNbCards);
xs.Serialize(tw, nbCard);
tw.Close();
}
public static int LoadParameterGamePreparationNbCards()
{
XmlSerializer xs = new XmlSerializer(typeof(int));
try
{
using (FileStream fs = new FileStream(pathNbCards, FileMode.Open))
{
int nbCards = (int)xs.Deserialize(fs);
return nbCards;
}
}
catch
{
return 0;
}
}
}
}

@ -12,9 +12,10 @@
<Grid.RowDefinitions>
<RowDefinition Height="10*" />
<RowDefinition Height="90*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
@ -99,8 +100,9 @@
</StackLayout>
<StackLayout
Grid.Row="2"
Margin="0,0,10,0">
Grid.Row="0"
Grid.Column="2"
Margin="0,0,20,0">
<Label Text="Nombre de pile en jeu :"
TextColor="{DynamicResource WhiteColor}"
@ -117,6 +119,26 @@
VerticalOptions="Center"/>
</StackLayout>
<StackLayout
Grid.Row="1"
Grid.Column="2"
Margin="0,0,20,0">
<Label Text="Nombre de cartes:"
TextColor="{DynamicResource WhiteColor}"
FontSize="16"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"/>
<Picker x:Name="SelectNbCard"
BackgroundColor="{DynamicResource SkyBlueColor}"
Margin="0,0,10,0"
MinimumWidthRequest="30"
WidthRequest="100"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</StackLayout>
</Grid>
@ -147,13 +169,14 @@
FontSize="16"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"/>
<Entry
BackgroundColor="{DynamicResource SkyBlueColor}"
Placeholder="Pseudo"
HorizontalOptions="Center"
MinimumWidthRequest="50"
WidthRequest="200"/>
</StackLayout>

@ -10,6 +10,7 @@ namespace TheGameExtreme.view
public List<int> listNbPlayer = new List<int> { 1, 2, 3, 4, 5 };
public List<string> listGameMode = new List<string> { "entières", "relatives", "décimales", "dizaines", "centaines", "millièmes", "fractionnées" };
public List<int> listNbStack = new List<int> { 4, 6, 8 };
public List<int> listNbCard = new List<int> { 100, 80, 60, 40 };
public GamePreparationPage()
@ -26,6 +27,9 @@ namespace TheGameExtreme.view
SelectNbStack.ItemsSource = listNbStack;
LoadParameterNbStacksGamePreparation();
SelectNbCard.ItemsSource = listNbCard;
LoadParameterNbCardsGamePreparation();
}
@ -35,6 +39,7 @@ namespace TheGameExtreme.view
IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex);
await Navigation.PopAsync();
}
protected override bool OnBackButtonPressed()
@ -42,6 +47,7 @@ namespace TheGameExtreme.view
IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex);
return base.OnBackButtonPressed();
}
@ -62,6 +68,7 @@ namespace TheGameExtreme.view
IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex);
IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex);
await Navigation.PushAsync(new MainPage(playersNames, (int)SelectNbStack.SelectedItem, (int)SelectMode.SelectedIndex));
}
@ -108,6 +115,11 @@ namespace TheGameExtreme.view
int nbStackSer = IOGamePreparation.LoadParamaterGamePreparationNbStacks();
SelectNbStack.SelectedIndex = nbStackSer;
}
public void LoadParameterNbCardsGamePreparation()
{
int nbCards = IOGamePreparation.LoadParameterGamePreparationNbCards();
SelectNbCard.SelectedIndex = nbCards;
}

Loading…
Cancel
Save