using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; using Xamarin.Forms; namespace TheGameExtreme.view { [Serializable] public partial class Settings : ContentPage { private bool bSwitchSerialisation; public Settings() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); if(pageContentSetting.BackgroundColor == Color.Black) { swTheme.IsToggled = false; bSwitchSerialisation = swTheme.IsToggled; } else { swTheme.IsToggled = true; bSwitchSerialisation = swTheme.IsToggled; } } private void CBBr_CheckedChanged(object sender, CheckedChangedEventArgs e) { if (CBBr.IsChecked == true) { CBFr.IsChecked = false; } else if(CBBr.IsChecked == false) { CBFr.IsChecked = true; } } private void CBFr_CheckedChanged(object sender, CheckedChangedEventArgs e) { if (CBFr.IsChecked == true) { CBBr.IsChecked = false; } else if (CBFr.IsChecked == false) { CBBr.IsChecked = true; } } private void Switch_Toggled_Theme(object sender, ToggledEventArgs e)//Change le background color de settings en noir et swap la couleur des labels en blanc { if (swTheme.IsToggled == false) { Application.Current.Resources["BlackColor"] = Color.Black; Application.Current.Resources["WhiteColor"] = Color.White; Application.Current.Resources["SkyBlueColor"] = Color.SkyBlue; } else { Application.Current.Resources["BlackColor"] = Color.White; Application.Current.Resources["WhiteColor"] = Color.Black; Application.Current.Resources["BlueSkyColor"] = Color.SkyBlue; } } private async void SettingToHomePage(object sender, EventArgs e) { string path = @"\Documents\theme.txt"; FileStream fs = File.Create(path); byte[] info = new UTF8Encoding(true).GetBytes(bSwitchSerialisation.ToString()); fs.Write(info, 0, info.Length); await Navigation.PopAsync(); } } }