randompicture.cs
来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 111 行
CS
111 行
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using CommunityServer.Components;
using CommunityServer.Galleries.Components;
namespace CommunityServer.Galleries.Controls
{
/// <summary>
/// Summary description for SidePortal.
/// </summary>
public class RandomPicture : GalleryImage
{
#region Public Properties
[DefaultValue( -1 )]
public virtual int SectionID
{
get
{
Object state = ViewState["SectionID"];
if(state != null)
return (int)state;
return -1;
}
set { ViewState["SectionID"] = value; }
}
[DefaultValue("")]
private string applicationKey;
public string ApplicationKey
{
get { return applicationKey; }
set { applicationKey = value; }
}
[DefaultValue( -1 )]
public virtual int CategoryID
{
get
{
Object state = ViewState["CategoryID"];
if(state != null)
return (int)state;
return -1;
}
set { ViewState["CategoryID"] = value; }
}
[DefaultValue( true )]
public virtual bool UseLink
{
get
{
Object state = ViewState["UseLink"];
if(state != null)
return (bool)state;
return true;
}
set { ViewState["UseLink"] = value; }
}
[DefaultValue( true )]
public virtual bool LinkToPicture
{
get
{
Object state = ViewState["LinkToPicture"];
if(state != null)
return (bool)state;
return true;
}
set { ViewState["LinkToPicture"] = value; }
}
#endregion
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ApplicationKey = CSContext.Current.ApplicationKey;
CategoryID = CSContext.Current.CategoryID;
// Use a different prefix for the img id attribute than the default "SmallThumb" so there won't
// be duplicate id's if a PictureListing control containing the random image is on the same page.
imageIDprefix = "RandomPicture";
}
protected override void LoadPicture()
{
if((SectionID == -1) && (ApplicationKey != ""))
SectionID = Galleries.GetGalleryID( ApplicationKey );
else if(SectionID == -1)
{
Gallery gallery = Galleries.GetRandomGallery();
if(gallery == null)
return;
SectionID = gallery.SectionID;
}
Picture = Pictures.GetRandomPicture(SectionID, CategoryID);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?