galleryrepeater.cs

来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 109 行

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

using System;
using System.Collections;
using System.ComponentModel;
using CommunityServer.Controls;
using CommunityServer.Galleries.Components;

namespace CommunityServer.Galleries.Controls
{
    /// <summary>
    /// Provides the Gallery implementation of SectionRepeater
    /// </summary>
    public class GalleryRepeater : SectionRepeater
    {
		
		#region Public Properties

		[DefaultValue( 1 )]
		public virtual Int32 CurrentPage
		{
			get
			{
				Object state = ViewState["CurrentPage"];
				if(state != null)
					return (Int32)state;
				return 1;
			}
			set
			{ ViewState["CurrentPage"] = value; }
		}

		[DefaultValue( 10 )]
		public virtual Int32 ItemsPerPage
		{
			get
			{
				Object state = ViewState["ItemsPerPage"];
				if(state != null)
					return (Int32)state;
				return 10;
			}
			set
			{ ViewState["ItemsPerPage"] = value; }
		}

		[DefaultValue( 0 )]
		public virtual Int32 TotalGalleries
		{
			get
			{
				Object state = ViewState["TotalGalleries"];
				if(state != null)
					return (Int32)state;
				return 0;
			}
			set
			{ ViewState["TotalGalleries"] = value; }
		}

		[DefaultValue( false )]
		public virtual bool Paginate
		{
			get
			{
				Object state = ViewState["Paginate"];
				if(state != null)
					return (bool)state;
				return false;
			}
			set
			{ ViewState["Paginate"] = value; }
		}

		#endregion


        /// <summary>
        /// Returns the Galleries for the current GroupID
        /// </summary>
        /// <returns></returns>
        protected override ArrayList GetSections()
        {
			ArrayList galleries = Galleries.GetGalleriesByGroupID(GroupID, IgnorePermissions, true, FlushSections);

			if(Paginate)
			{
				// Calculate pagination
				TotalGalleries = galleries.Count;
				int pageCount = galleries.Count;
				pageCount -= (CurrentPage-1)*ItemsPerPage;
				if(pageCount > ItemsPerPage)
					pageCount = ItemsPerPage;

				// Grab the items for the current page
				Gallery[] pageItems = new Gallery[pageCount];
				galleries.CopyTo((CurrentPage-1)*ItemsPerPage, pageItems, 0, pageCount);
				return new ArrayList(pageItems);
			}
			else
				return galleries;
        }

    }
}

⌨️ 快捷键说明

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