using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using TheGameExtreme.IO;
using Xamarin.Forms;

namespace TheGameExtreme.view
{
    [Serializable]
    public partial class Settings : ContentPage 
        
    {
        
        public Settings()
        {            
            InitializeComponent();
            
            NavigationPage.SetHasNavigationBar(this, false);
            if(pageContentSetting.BackgroundColor == Color.Black)
            {              
                swTheme.IsToggled = false;
                
            }
            else
            {
                swTheme.IsToggled = true;
                
            }

        }

        /*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;
                               
            }
            else
            {
                Application.Current.Resources["BlackColor"] = Color.White;
                Application.Current.Resources["WhiteColor"] = Color.Black;
                
            }
        }

        private async void SettingToHomePage(object sender, EventArgs e)
        {
            IOOptions.SaveOptionParameter(swTheme.IsToggled);

            //serialisationSwitch();
            await Navigation.PopAsync();
        }

        protected override bool OnBackButtonPressed()
        {
            IOOptions.SaveOptionParameter(swTheme.IsToggled);
            return base.OnBackButtonPressed();
        }
    }
}
