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

using System;
using System.Web.UI.WebControls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using FormLabel = CommunityServer.ControlPanel.Controls.FormLabel;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;

namespace CommunityServer.ControlPanel.Photos.Options
{
	/// <summary>
	/// Summary description for SyndicationOptionsPage.
	/// </summary>
	public class SyndicationOptionsPage : BaseGalleryPage
	{

		#region Child Controls

        protected CheckBox EnableRss;
        protected CheckBox EnableAtom;
		protected CheckBox EnableRssComments;
		protected FormLabel FormLabel1;
		protected FormLabel FormLabel2;
		protected FormLabel FormLabel3;
		protected MPContent DescriptionRegion;
		protected MPContent TaskRegion;
		protected StatusMessage Status;
		protected ResourceLinkButton SaveButton;
		protected ResourceControl Resourcecontrol1;
		protected ResourceControl Resourcecontrol2;
		protected MPContainer MPContainer;

		#endregion
	
		private void Page_Load(object sender, EventArgs e)
		{
			if(!IsPostBack)
			{
				EnableRss.Checked = this.CurrentGallery.EnableRss;
				EnableRssComments.Checked = this.CurrentGallery.EnableRssCommentsDefault;

				if (CurrentGallery.EnableCommentsDefault == false)
				{
					EnableRssComments.Checked = EnableRssComments.Enabled = false;
				}
			}
		}

		#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.SaveButton.Click += new EventHandler(SaveButton_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 System.EventHandler(this.Page_Load);

		}
		#endregion

        private void SaveButton_Click(object sender, EventArgs e)
        {
            if(Page.IsValid)
            {
                
                CurrentGallery.EnableRss = EnableRss.Checked;
				CurrentGallery.EnableRssCommentsDefault = EnableRssComments.Checked;

            	CommunityServer.Galleries.Galleries.Update(CurrentGallery);
				
				Status.Success = true;
				// Status.Text = "Your changes have been saved successfully";
				Status.Visible = true;
            }
        }
	}
}
