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

📄 managesectionadmin.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

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

namespace CommunityServer.Controls
{
    /// <summary>
    /// Base control class for managing Groups and Sections. Each application will likely
    /// derrive from this control and create it's own implementation
    /// </summary>
    public abstract class ManageSectionAdmin : TemplatedWebControl 
    {

        #region Child Controls

    	Repeater GroupRepeater;

        #endregion

        #region Core
        protected override void OnLoad(EventArgs e) 
        {
            if ( !Page.IsPostBack ) 
            {
                DataBind();
            }
            base.OnLoad( e );
        }

		private bool _isEdit = false;
		protected virtual Boolean IsEdit 
		{
			get 
			{
				return _isEdit;
			}
			set 
			{
				_isEdit = value;
			}
		}


        protected override void AttachChildControls() 
        {
            this.GroupRepeater = (Repeater)FindControl( "GroupRepeater" );
            this.GroupRepeater.ItemCreated += new RepeaterItemEventHandler(GroupRepeater_ItemCreated);
            this.GroupRepeater.ItemCommand += new RepeaterCommandEventHandler(GroupRepeater_ItemCommand);

            ResourceLabel DescriptionLabel = FindControl( "DescriptionLabel" ) as ResourceLabel;
            if(DescriptionLabel != null)
                DescriptionLabel.ResourceName = TitleResourceName;
        }

        public override void DataBind()
        {
            base.DataBind();

            DataBindGroups();
        }

        protected void DataBindGroups() 
        {

            GroupRepeater.DataSource = GetGroups();
            GroupRepeater.DataBind();
        }
        #endregion

        #region Abstract Properties/Methods

        /// <summary>
        /// Sets the Title of the Control
        /// </summary>
        protected abstract string TitleResourceName{get;}

        /// <summary>
        /// Returns a list of Groups
        /// </summary>
        /// <returns></returns>
        protected abstract ArrayList GetGroups();
       

        /// <summary>
        /// Sets the mode of the control (only used in forums)
        /// </summary>
        protected abstract ControlUserMode GetMode{get;}

        /// <summary>
        /// Sets the current application type
        /// </summary>
        protected abstract ApplicationType ApplicationType{get;}

        /// <summary>
        /// The link to edit Groups
        /// </summary>
        protected abstract string GetAdminGroupLink(int groupID);

        /// <summary>
        /// Text for the New Group button
        /// </summary>
        /// <returns></returns>
        protected abstract string GetNewGroupText();

        /// <summary>
        /// Test for the new Group Button
        /// </summary>
        /// <returns></returns>
        protected abstract string GroupButtonText();

        /// <summary>
        /// Link to edit a section
        /// </summary>
        protected abstract string GetAdminSectionLink(int SectionID);

        /// <summary>
        /// Returns an instantiated instance of Section. Used to create new Sections since Section
        /// is abstract
        /// </summary>
        protected abstract Section CreateBlankSection{ get;}


        protected virtual string FormatSubSectionAdmin(Section s)
        {
            return string.Empty;
        }
        #endregion


        #region GroupRepeater_ItemCreated
        private void GroupRepeater_ItemCreated( Object sender, RepeaterItemEventArgs e ) 
        {
            switch ( e.Item.ItemType ) 
            {
                case ListItemType.Item:
                case ListItemType.AlternatingItem:
                case ListItemType.SelectedItem:
                    SectionRepeater sectionRepeater = e.Item.FindControl( "SectionList" ) as SectionRepeater;
                    sectionRepeater.Mode = GetMode;
					sectionRepeater.FlushSections = IsEdit;
                    sectionRepeater.DataBinding += new EventHandler( SectionList_DataBinding );
                    sectionRepeater.ItemCreated += new RepeaterItemEventHandler(SectionList_ItemCreated);
                    sectionRepeater.ItemCommand += new RepeaterCommandEventHandler(SectionList_ItemCommand);

                    HyperLink SectionGroupAdminLink = (HyperLink)e.Item.FindControl( "GroupAdminLink" );
                    SectionGroupAdminLink.DataBinding += new EventHandler(SectionGroupAdminLink_DataBinding);

                    ImageButton MoveGroupUp = (ImageButton)e.Item.FindControl( "MoveGroupUp" );
                    MoveGroupUp.DataBinding += new EventHandler(MoveGroupUp_DataBinding);

                    ImageButton MoveGroupDown = (ImageButton)e.Item.FindControl( "MoveGroupDown" );
                    MoveGroupDown.DataBinding += new EventHandler(MoveGroupDown_DataBinding);

                    Button CreateNewSection = (Button)e.Item.FindControl( "CreateNewSection" );
                    CreateNewSection.DataBinding += new EventHandler(CreateNewSection_DataBinding);
			
                    break;
                case ListItemType.Footer:
                    Button CreateNewSectionGroup = (Button)e.Item.FindControl( "CreateNewSectionGroup" );
                    CreateNewSectionGroup.DataBinding += new EventHandler(CreateNewSectionGroup_DataBinding);
                    break;
            }
        }
        #endregion


        #region GroupRepeater Controls DataBinding

        private void SectionList_DataBinding( Object sender, EventArgs e ) 
        {
            SectionRepeater SectionList = sender as SectionRepeater;
            RepeaterItem container = (RepeaterItem)SectionList.NamingContainer;
            SectionList.GroupID = Convert.ToInt32( DataBinder.Eval( container.DataItem, "GroupID" ) );
        }

        private void SectionGroupAdminLink_DataBinding(object sender, EventArgs e) 
        {
            HyperLink SectionGroupAdminLink = (HyperLink)sender;
            RepeaterItem container = (RepeaterItem)SectionGroupAdminLink.NamingContainer;
            SectionGroupAdminLink.Text = Convert.ToString( DataBinder.Eval( container.DataItem, "Name" ) );
            SectionGroupAdminLink.NavigateUrl = GetAdminGroupLink( (int)DataBinder.Eval( container.DataItem, "GroupID" ) );
        }

        private void MoveGroupUp_DataBinding(object sender, EventArgs e) 
        {
            ImageButton MoveGroupUp = (ImageButton)sender;
            RepeaterItem container = (RepeaterItem)MoveGroupUp.NamingContainer;
            MoveGroupUp.CommandName = "MoveGroupUp";
            MoveGroupUp.CommandArgument = Convert.ToString( DataBinder.Eval( container.DataItem, "GroupID" ) );
        }

        private void MoveGroupDown_DataBinding(object sender, EventArgs e) 
        {
            ImageButton MoveGroupDown = (ImageButton)sender;
            RepeaterItem container = (RepeaterItem)MoveGroupDown.NamingContainer;
            MoveGroupDown.CommandName = "MoveGroupDown";
            MoveGroupDown.CommandArgument = Convert.ToString( DataBinder.Eval( container.DataItem, "GroupID" ) );
        }

        private void CreateNewSection_DataBinding(object sender, EventArgs e) 
        {
            Button CreateNewSection = (Button)sender;
            RepeaterItem container = (RepeaterItem)CreateNewSection.NamingContainer;
            CreateNewSection.CommandName = "CreateNewSection";
            CreateNewSection.CommandArgument = Convert.ToString( DataBinder.Eval( container.DataItem, "GroupID" ) );
            CreateNewSection.Text = GetNewGroupText();
        }

        private void CreateNewSectionGroup_DataBinding(object sender, EventArgs e) 
        {
            Button CreateNewSectionGroup = (Button)sender;
            CreateNewSectionGroup.CommandName = "CreateNewSectionGroup";
            CreateNewSectionGroup.Text = GroupButtonText();
        }

        #endregion

        #region SectionList_ItemCreated
        private void SectionList_ItemCreated(object sender, RepeaterItemEventArgs e) 

⌨️ 快捷键说明

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