📄 manageads.aspx.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;
using FormLabel = CommunityServer.ControlPanel.Controls.FormLabel;
using HelpIcon = CommunityServer.ControlPanel.Controls.HelpIcon;
namespace CommunityServer.ControlPanel.Tools
{
/// <summary>
/// Summary description for ManageArticles.
/// </summary>
public class ManageAds : BaseToolsPage
{
#region Members
protected CheckBox enableAds;
protected CheckBox enableInline;
protected CheckBoxList rolelist;
protected ResourceLinkButton SaveButton;
protected ConfigOKStatusMessage Status;
protected FileOnlyStatusMessage FOStatus;
protected ControlPanelSelectedNavigation SelectedNavigation1;
protected ResourceControl RegionTitle;
protected MPContent DescriptionRegion;
protected ResourceControl Resourcecontrol1;
protected HelpIcon Helpicon1;
protected FormLabel Formlabel3;
protected HelpIcon Helpicon3;
protected FormLabel Formlabel2;
protected HelpIcon Helpicon2;
protected FormLabel Formlabel1;
protected MPContent TaskRegion;
protected MPContainer MPContainer;
protected PlaceHolder OptionHolder;
#endregion
override protected void OnInit(EventArgs e)
{
this.Load += new EventHandler(this.Page_Load);
InitializeComponent();
base.OnInit(e);
}
private void Page_Load(object sender, EventArgs e)
{
if ( !Page.IsPostBack )
{
AdsConfiguration config = AdsConfiguration.Instance(false);
if(config.FileOnly)
{
FOStatus.Visible = true;
OptionHolder.Visible = false;
}
else
{
enableAds.Checked = config.Enabled;
enableInline.Checked = config.AllowInlineControl;
string[] roles = Roles.GetRoleNames();
foreach(string role in roles)
{
ListItem li = new ListItem(role,role.ToLower());
rolelist.Items.Add(li);
}
if(config.Roles != null)
{
foreach(string role in config.Roles)
{
ListItem li = rolelist.Items.FindByValue(role.ToLower());
if(li != null)
li.Selected = true;
}
}
}
}
}
private void InitializeComponent()
{
SaveButton.Click +=new EventHandler(SaveButton_Click);
}
private void SaveButton_Click(object sender, EventArgs e)
{
AdsConfiguration config = AdsConfiguration.Instance(false);
if(!config.FileOnly)
{
config.Enabled = enableAds.Checked;
config.AllowInlineControl = enableInline.Checked;
ArrayList list = new ArrayList();
foreach(ListItem li in rolelist.Items)
{
if(li.Selected)
{
list.Add(li.Value);
}
}
config.Roles = (string[])list.ToArray(typeof(string));
Status.Visible = true;
config.Save();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -