//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Web.UI;
using CommunityServer.Components;

namespace CommunityServer.Controls
{
	/// <summary>
	/// Summary description for LoginView.
	/// </summary>
	[
	ParseChildren( true ),
	PersistChildren( false ),
	]
	public class LoginView : Control
	{
		public LoginView()
		{

		}

		protected override void CreateChildControls() 
		{
			this.Controls.Clear();
			ITemplate template  = null;

			if(CSContext.Current.User.IsAnonymous)
			{
				template = AnonymousTemplate;
			}
			else
			{
				template = LoggedInTemplate;				
			}

			if(template != null)
			{
				Control cntrl = new Control();
				template.InstantiateIn(cntrl);
				this.Controls.Add(cntrl);
			}

		}

		
		[
		Browsable( false ),
		DefaultValue( null ),
			Description( "TODO SkinTemplate Description" ),
		PersistenceMode( PersistenceMode.InnerProperty ),
		]
		public ITemplate AnonymousTemplate 
		{
			get {return _anonymousTemplate;}
			set {_anonymousTemplate = value;}
		}
		private ITemplate _anonymousTemplate;


		[
		Browsable( false ),
		DefaultValue( null ),
		Description( "TODO SkinTemplate Description" ),
		PersistenceMode( PersistenceMode.InnerProperty ),
		]
		public ITemplate LoggedInTemplate 
		{
			get {return _loggedInTemplate;}
			set {_loggedInTemplate = value;}
		}
		private ITemplate _loggedInTemplate;



	}

}
