You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.6 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Xamarin.Forms;
using System.Diagnostics;
using TheGameExtreme.IO;
using Rg.Plugins.Popup.Pages;
using Rg.Plugins.Popup.Extensions;
using TheGameExtreme.Resx;
namespace TheGameExtreme.view
{
public partial class HomePage : ContentPage
{
public HomePage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
SetTheme();
LoadParameterOptionOnHomepage();
}
private async void OpenGame(object sender, EventArgs args)
{
await Navigation.PushAsync(new GamePreparationPage());
}
private async void OpenMultiPlayerMode(object sender, EventArgs args)
{
await DisplayAlert("Mode en cours de développement", "Ce mode n'est pas encore implémenté !", "Fermer");
//await Navigation.PushAsync(new MultiPlayerMode());
}
private async void Rules_Clicked(object sender, EventArgs e)
{
await DisplayAlert(AppResources.StrTitleRules, AppResources.StrRules, AppResources.StrCloseWind);
}
public void LoadParameterOptionOnHomepage()
{
bool b = IOOptions.LoadOptionsParameter();
if (!b)
{
Application.Current.Resources["BlackColor"] = Color.Black;
Application.Current.Resources["WhiteColor"] = Color.White;
imageButton.Source = "SoleilThemes.png";
}
else
{
Application.Current.Resources["BlackColor"] = Color.White;
Application.Current.Resources["WhiteColor"] = Color.Black;
imageButton.Source = "LuneSombreTheme.png";
}
}
private void Theme_Clicked(object sender, EventArgs e)
{
bool b;
ButtonGrid.Children.Remove(imageButton);
System.Diagnostics.Debug.WriteLine("Source : " + imageButton.Source);
if(homepageT.BackgroundColor == Color.Black)
{
b = true;
Application.Current.Resources["BlackColor"] = Color.White;
Application.Current.Resources["WhiteColor"] = Color.Black;
imageButton = new ImageButton()
{
BackgroundColor = (Color)Application.Current.Resources["BlackColor"]
};
imageButton.Source = "LuneSombreTheme.png";
}
else
{
b = false;
Application.Current.Resources["BlackColor"] = Color.Black;
Application.Current.Resources["WhiteColor"] = Color.White;
imageButton = new ImageButton()
{
BackgroundColor = (Color)Application.Current.Resources["BlackColor"]
};
imageButton.Source = "SoleilThemes.png";
}
ButtonGrid.Children.Add(imageButton, 1, 1);
imageButton.Clicked += Theme_Clicked;
IOOptions.SaveOptionParameter(b);
}
private void SetTheme()
{
if (homepageT.BackgroundColor == Color.Black)
{
imageButton.Source = "SoleilThemes.png";
}
if(homepageT.BackgroundColor == Color.White)
{
imageButton.Source = "LuneSombreTheme";
}
}
}
}