⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emailnotificationdropdownlist.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

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

namespace CommunityServer.Discussions.Controls
{
    /// <summary>
    /// This server control displays a list of Date formatting options.
    /// </summary>
	public class EmailNotificationDropDownList : DropDownList
	{
    	CSContext csContext = CSContext.Current;
        Label label = new Label();

        /// <remarks>
        /// Public constructor, internally populates the list of date formats.
        /// </remarks>
		public EmailNotificationDropDownList()
		{
            // Set the default text
            //
            //label.Text  = ResourceManager.GetString("EmailNotificationDropDownList_When");

            // Add datetime formats
            //
			Items.Add(new ListItem(ResourceManager.GetString("EmailNotificationDropDownList_NeverSend"), ((int)EmailSubscriptionType.None).ToString()));
			Items.Add(new ListItem(ResourceManager.GetString("EmailNotificationDropDownList_NewThreads"), ((int)EmailSubscriptionType.Thread).ToString()));
			Items.Add(new ListItem(ResourceManager.GetString("EmailNotificationDropDownList_NewPosts"), ((int)EmailSubscriptionType.Post).ToString()));

            // Set the selected index
            //
			ListItem item = Items.FindByValue(((int)ThreadTracking.GetSectionSubscriptionType(csContext.SectionID) & 7).ToString());
			if(item != null)
				Items.FindByValue(((int)ThreadTracking.GetSectionSubscriptionType(csContext.SectionID) & 7).ToString()).Selected = true;
			else
				Items.FindByValue(((int)ThreadTracking.GetSectionSubscriptionType(csContext.SectionID) & 3).ToString()).Selected = true;
            SelectedIndexChanged += new EventHandler(Subscription_Change);
        }

		protected override void Render(HtmlTextWriter writer)
		{
            // If the user is already authenticated we have no work to do
            if (!Page.Request.IsAuthenticated)
                return;

            label.RenderControl(writer);
            base.Render (writer);
        }


        // *********************************************************************
        //  Subscription_Change
        //
        /// <summary>
        /// User wants to change their subscription method
        /// </summary>
        /// 
        // ********************************************************************/ 
		private void Subscription_Change (Object sender, EventArgs e)
		{
			int subscriptionType = (int)ThreadTracking.GetSectionSubscriptionType(csContext.SectionID);
			subscriptionType &= ~7;
			subscriptionType |= int.Parse(SelectedItem.Value);
			ThreadTracking.SetSectionSubscriptionType(csContext.SectionID, (EmailSubscriptionType)subscriptionType);
        }

		public string Text
		{
			get { return label.Text; }
			set { label.Text = value; }
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -