using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
	protected override void OnPreInit(EventArgs e)
	{		
		this.Theme = Profile.Theme;
		base.OnPreInit(e);
	}

    protected void Page_Load(object sender, EventArgs e)
    {
		lbl_bienvenue.Text = Profile.MessageDeBienvenue;
		int delai = Profile.Securite.DelaiDeconnexion;

		if (Profile.PenseeDuJour != null)
		{			
			int max = Profile.PenseeDuJour.Count - 1;
			if (max >= 0)
			{
				Random r = new Random(DateTime.Now.Second);
				int pi = r.Next(max);
				lbl_pensee.Text = Profile.PenseeDuJour[pi];
			}
			else
				lbl_pensee.Text = "";
		}

		if (!IsPostBack)
		{
			txt_bienvenue.Text = Profile.MessageDeBienvenue;
			switch (Profile.Theme)
			{
				default:
				case "blanc":
					lst_theme.SelectedIndex = 0;
					break;

				case "bleu":
					lst_theme.SelectedIndex = 1;
					break;
			}
		}
    }
	protected void cmd_change_profil_Click(object sender, EventArgs e)
	{
		Profile.MessageDeBienvenue = txt_bienvenue.Text;
		Profile.Theme = lst_theme.SelectedValue;
		if (Profile.PenseeDuJour == null)
			Profile.PenseeDuJour = new ListString();

		if (txt_pensee.Text != "")
		{
			Profile.PenseeDuJour.Add(txt_pensee.Text);
			Profile.Save(); // parfois nécessaire
		}
	}
}
