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

using System;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;

namespace CommunityServer.ControlPanel.PhotoAdmin
{
	/// <summary>
	/// Summary description for GroupForm.
	/// </summary>
	public class GroupForm : BaseGalleryAdminPage
	{
		protected ResourceLinkButton Save;
		protected MPContent bcr;

		protected GroupEditControl GroupEditControl1;

		private bool IsNew
		{
			get{return GroupEditControl1.GroupID == -1;}
		}

		private void Page_Load(object sender, EventArgs e)
		{
			CSContext context = CSContext.Current;
			context.GroupID = GroupEditControl1.GroupID = context.GetIntFromQueryString("GroupID", -1);
			GroupEditControl1.ApplicationType = ApplicationType.Gallery;

			if(IsNew)
				Head.AddTitle("New Group", this.Context);
			else
				Head.AddTitle("Group Editor", this.Context);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
			this.Save.Click += new EventHandler(Save_Click);
		}

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new EventHandler(this.Page_Load);

		}
		#endregion

		private void Save_Click(object sender, EventArgs e)
		{
			if(Page.IsValid)
			{
				if(GroupEditControl1.Save())
					Modal.ClosePage(Page) ;
			}
		}


	}
}
