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

📄 gallery.cs

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

using System;
using CommunityServer.Components;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// This class defines the properties that are used for Galleries.  It inherits from the base class <see cref="CommunityServer.Components.Section"/>.
	/// </summary>
	public class Gallery : CommunityServer.Components.Section
	{

		public Gallery() : base()
		{
			this.EnablePostStatistics = false;
		}

		#region Permissions

        public override PermissionBase DefaultRolePermission
        {
            get
            {
                return new GalleryPermission();
            }
        }

        public override AccessCheckDelegate AccessCheck
        {
            get
            {
                return new AccessCheckDelegate(GalleryPermission.AccessCheck);
            }
        }

        public override ValidatePermissionsDelegate ValidatePermissions
        {
            get
            {
                return new ValidatePermissionsDelegate(GalleryPermission.Validate);
            }
        }

        GalleryPermission ownerPermission = null;
	    public override PermissionBase OwnerPermission
	    {
            get
            {
                if(ownerPermission == null)
                {
                    ownerPermission = new GalleryPermission();
                    ownerPermission.SetBit(Permission.Post,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.Reply,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.View,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.Vote,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.Delete,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.Moderate,AccessControlEntry.Allow);
                    ownerPermission.SetBit(Permission.Edit,AccessControlEntry.Allow);
					ownerPermission.SetBit(Permission.Administer,AccessControlEntry.Allow);
                }

                return ownerPermission;

            }
	    }

	    #endregion

        #region ExifProperty
		private ExifProperty[] displayExifProperties = null;

        
		/// <summary>
		/// This property defines the different <see cref="ExifProperty"/> attributes that are displayed when viewing a picture
		/// in this <see cref="Gallery"/>
		/// </summary>
		public ExifProperty[] DisplayExifProperties
		{
			get
			{
				if(displayExifProperties == null)
				{
					if(GetExtendedAttribute( "DisplayExifProperties" ) != string.Empty)
					{
						string[] parts = GetExtendedAttribute( "DisplayExifProperties" ).Split(',');
						displayExifProperties = new ExifProperty[parts.Length];
						for(int i = 0 ; i < displayExifProperties.Length ; i++)
							displayExifProperties[i] = (ExifProperty)int.Parse(parts[i]);
					}
					else
					{
						displayExifProperties = new ExifProperty[5];
						displayExifProperties[0] = ExifProperty.Model;
						displayExifProperties[1] = ExifProperty.DateTime;
						displayExifProperties[2] = ExifProperty.ExposureTime;
						displayExifProperties[3] = ExifProperty.Flash;
						displayExifProperties[4] = ExifProperty.FocalLength;
					}
				}
				return displayExifProperties;
			}
			set
			{
				displayExifProperties = value;
				string allparts = "";
				for(int i = 0 ; i < value.Length ; i++)
					allparts += ((int)value[i]).ToString() + ",";
				SetExtendedAttribute( "DisplayExifProperties", allparts.TrimEnd( new char[] { ',' } ) );
			}
		}

		#endregion

		#region Extended Attributes

		/// <summary>
		/// This property defines the number of columns that are displayed when viewing a listing of <see cref="PostCategory"/> items
		/// </summary>
		public int CategoryListingColumns
		{
			get
			{
				string val = GetExtendedAttribute( "CategoryListingColumns" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 2;
			}
			set
			{
				if(value < 1)
					SetExtendedAttribute( "CategoryListingColumns", "1" );
				else
					SetExtendedAttribute( "CategoryListingColumns", value.ToString() );
			}
		}

		/// <summary>
		/// This property defines the number of rows that are displayed when viewing a listing of <see cref="PostCategory"/> items
		/// </summary>
		public int CategoryListingRows
		{
			get
			{
				string val = GetExtendedAttribute( "CategoryListingRows" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 3;
			}
			set
			{
				if(value < 1)
					SetExtendedAttribute( "CategoryListingRows", "1" );
				else
					SetExtendedAttribute( "CategoryListingRows", value.ToString() );
			}
		}

		public GalleryCategoriesSortBy CategorySortBy
		{
			get
			{
				string val = GetExtendedAttribute( "CategorySortBy" );
				if(val != string.Empty)
					return (GalleryCategoriesSortBy)Enum.Parse(typeof(GalleryCategoriesSortBy), val);
				else
					return GalleryCategoriesSortBy.Name;
			}
			set
			{
				SetExtendedAttribute( "CategorySortBy", value.ToString() );
			}
		}

		/// <summary>
		/// This property defines the number of columns that are displayed when viewing a listing of <see cref="Picture"/> items
		/// </summary>
		public int PictureListingColumns
		{
			get
			{
				string val = GetExtendedAttribute( "PictureListingColumns" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 4;
			}
			set
			{
				if(value < 1)
					SetExtendedAttribute( "PictureListingColumns", "1" );
				else
					SetExtendedAttribute( "PictureListingColumns", value.ToString() );
			}
		}

		/// <summary>
		/// This property defines the number of rows that are displayed when viewing a listing of <see cref="Picture"/> items
		/// </summary>
		public int PictureListingRows
		{
			get
			{
				string val = GetExtendedAttribute( "PictureListingRows" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 4;
			}
			set
			{
				if(value < 1)
					SetExtendedAttribute( "PictureListingRows", "1" );
				else
					SetExtendedAttribute( "PictureListingRows", value.ToString() );
			}
		}

		public GalleryThreadSortBy ThreadSortBy
		{
			get
			{
				string val = GetExtendedAttribute( "ThreadSortBy" );
				if(val != string.Empty)
					return (GalleryThreadSortBy)Enum.Parse(typeof(GalleryThreadSortBy), val);
				else
					return GalleryThreadSortBy.PictureDate;
			}
			set
			{
				SetExtendedAttribute( "ThreadSortBy", value.ToString() );
			}
		}

		public SortOrder ThreadSortOrder
		{
			get
			{
				string val = GetExtendedAttribute( "ThreadSortOrder" );
				if(val != string.Empty)
					return (SortOrder)Enum.Parse(typeof(SortOrder), val);
				else
					return CommunityServer.Components.SortOrder.Ascending;
			}
			set
			{
				SetExtendedAttribute( "ThreadSortOrder", value.ToString() );
			}
		}

		/// <summary>
		/// This property defines the width of thumbnail images
		/// </summary>
		public int ThumbnailX
		{
			get
			{
				string val = GetExtendedAttribute( "ThumbnailX" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 100;
			}
			set { SetExtendedAttribute( "ThumbnailX", value.ToString() ); }
		}

		/// <summary>
		/// This property defines the height of thumbnail images
		/// </summary>
		public int ThumbnailY
		{
			get
			{
				string val = GetExtendedAttribute( "ThumbnailY" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 87;
			}
			set { SetExtendedAttribute( "ThumbnailY", value.ToString() ); }
		}

		/// <summary>
		/// This property defines the quality percentage of thumbnail images
		/// </summary>
		public int ThumbnailQuality
		{
			get
			{
				string val = GetExtendedAttribute( "ThumbnailQuality" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return 70;
			}
			set { SetExtendedAttribute( "ThumbnailQuality", value.ToString() ); }
		}

		/// <summary>
		/// This property defines the brightness of thumbnail images (0-200, -1 to disable changing the brightness)
		/// </summary>
		public int ThumbnailBrightness
		{
			get
			{
				string val = GetExtendedAttribute( "ThumbnailBrightness" );
				if(val != string.Empty)
					return int.Parse(val);
				else
					return -1;
			}
			set
			{
				if(value < 0)
					SetExtendedAttribute( "ThumbnailBrightness", "-1" );

⌨️ 快捷键说明

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