switch changement de theme

master
Baptiste ARNAUD 6 years ago
parent 49cf2d006b
commit 17093b2a7b

@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="TheGameExtreme.App"> <Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="TheGameExtreme.App">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<Style x:Key="MyBackGroundColorStyle" TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="Black"></Setter>
</Style>
<Style x:Key="MyBackGroundColorStyle1" TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="Red"></Setter>
</Style>
<Style x:Key="MyBackGroundColorStyle2" TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="White"></Setter>
</Style>
</ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ContentPage Visual="Material" <ContentPage
BackgroundColor="#4d4c4a" Style="{StaticResource Key=MyBackGroundColorStyle}"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TheGameExtreme.view.HomePage"> x:Class="TheGameExtreme.view.HomePage">
@ -21,10 +21,10 @@
<Label Text="THE GAME" TextColor="Black" <Label Text="THE GAME" TextColor="White"
Grid.Row="0" Grid.Column="1" Grid.Row="0" Grid.Column="1"
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
FontSize="28" FontSize="35"
VerticalTextAlignment="Center"/> VerticalTextAlignment="Center"/>
<ImageButton Source="EngrenageV1.jpeg" <ImageButton Source="EngrenageV1.jpeg"

@ -26,5 +26,6 @@ namespace TheGameExtreme.view
{ {
await Navigation.PushAsync(new Settings()); await Navigation.PushAsync(new Settings());
} }
} }
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ContentPage <ContentPage BackgroundColor="#4d4c4a"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TheGameExtreme.view.MultiPlayerMode"> x:Class="TheGameExtreme.view.MultiPlayerMode">

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ContentPage BackgroundColor="#4d4c4a" <ContentPage Style="{StaticResource Key=MyBackGroundColorStyle2}" x:Name="pageContentSetting"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TheGameExtreme.view.Settings"> x:Class="TheGameExtreme.view.Settings">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -18,14 +21,18 @@
<Label HorizontalTextAlignment="Start" Text="langage" Grid.Column="0" Grid.Row="0" FontSize="25" TextColor="Black"/> <Label HorizontalTextAlignment="Start" Text="langage" Grid.Column="0" Grid.Row="0" FontSize="25" TextColor="Black"/>
<Label Text="English" Grid.Column="1" Grid.Row="0" FontSize="25" TextColor="Black"/> <Label Text="English" Grid.Column="1" Grid.Row="0" FontSize="25" TextColor="Black"/>
<CheckBox IsChecked="False" Grid.Column="1" Grid.Row="0" x:Name="CBBr"/> <CheckBox IsChecked="False" Grid.Column="1" Grid.Row="0" x:Name="CBBr" CheckedChanged="CBBr_CheckedChanged"/>
<Label Text="Français" Grid.Column="2" Grid.Row="0" FontSize="25" TextColor="Black"/> <Label Text="Français" Grid.Column="2" Grid.Row="0" FontSize="25" TextColor="Black"/>
<CheckBox IsChecked="False" Grid.Column="2" Grid.Row="0" x:Name="CBFr"/> <CheckBox IsChecked="True" Grid.Column="2" Grid.Row="0" x:Name="CBFr" CheckedChanged="CBFr_CheckedChanged"/>
<Label HorizontalTextAlignment="Start" Text="Sound" Grid.Column="0" Grid.Row="1" TextColor="Black" FontSize="25"/> <Label HorizontalTextAlignment="Start" Text="Son" Grid.Column="0" Grid.Row="1" TextColor="Black" FontSize="25"/>
<Switch IsToggled="true" Grid.Column="1" Grid.Row="1" /> <Switch IsToggled="true" Grid.Column="1" Grid.Row="1" />
<Label HorizontalTextAlignment="Start" Text="Mode Extreme" Grid.Column="0" Grid.Row="2" TextColor="Black" FontSize="25"/> <Label HorizontalTextAlignment="Start" Text="Mode Extreme" Grid.Column="0" Grid.Row="2" TextColor="Black" FontSize="25"/>
<Switch IsToggled="True" Grid.Column="1" Grid.Row="2" /> <Switch IsToggled="True" Grid.Column="1" Grid.Row="2" />
</Grid>
<Label Text="Thème sombre" Grid.Column="0" Grid.Row="3" FontSize="25" TextColor="Black"/>
<Switch IsToggled="True" Grid.Column="1" Grid.Row="3" Toggled="Switch_Toggled_Theme" x:Name="swTheme"/>
</Grid>
</ContentPage> </ContentPage>

@ -11,12 +11,37 @@ namespace TheGameExtreme.view
public Settings() public Settings()
{ {
InitializeComponent(); InitializeComponent();
}
private void CBBr_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if(CBBr.IsChecked == true)
{
CBFr.IsChecked = !CBBr.IsChecked;
}
}
private void CBFr_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if(CBFr.IsChecked == true) if(CBFr.IsChecked == true)
{ {
CBBr.IsChecked = !CBBr.IsChecked;
} }
} }
private void Switch_Toggled_Theme(object sender, ToggledEventArgs e)
{
if(swTheme.IsToggled == false)
{
pageContentSetting.Style = Application.Current.Resources["MyBackGroundColorStyle1"] as Style;
}
else
{
pageContentSetting.Style = Application.Current.Resources["MyBackGroundColorStyle2"] as Style;
}
}
} }
} }

Loading…
Cancel
Save