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

📄 picturedetails.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 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.Galleries.Components;

namespace CommunityServer.Galleries.Controls
{

	public class PictureDetails : GalleryThemedControl
	{

		#region Child Controls

		private Literal Name;
		private Literal Description;
		private GalleryImage detailsImage;
		private Literal PostAuthor;
		private Literal ViewCount;
		private Literal TotalComments;

		private HyperLink OriginalLink;
		private HyperLink OrderLink;

		private PagingControl pagination;

		#endregion

		#region Public Properties

		private Picture dataSource;
		public Picture DataSource
		{
			get { return dataSource; }
			set { dataSource = value; }
		}

		#endregion

		#region Skin

		protected override void AttachChildControls()
		{
			Name = (Literal)FindControl( "Name" );
			Description = (Literal)FindControl( "Description" );
			detailsImage = (GalleryImage)FindControl( "detailsImage" );
			PostAuthor = FindControl("PostAuthor") as Literal;
			ViewCount = (Literal)FindControl( "ViewCount" );
			TotalComments = (Literal)FindControl( "TotalComments" );
			OriginalLink = (HyperLink)FindControl( "OriginalLink" );
			OrderLink = (HyperLink)FindControl( "OrderLink" );
			pagination = (PagingControl)FindControl( "Pagination" );

			pagination.PageChanged += new EventHandler(pagination_PageChanged);
		}

		#endregion

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

			if(DataSource == null)
				DataSource = Pictures.GetPicture(CSContext.Current.PostID); //return;

			Views.AddWebCount(DataSource.PostID);

			// Setup the pagination
			GalleryThreadQuery query = new GalleryThreadQuery();
			GalleryUserCookie userCookie = new GalleryUserCookie(CSContext.Current.User);
			query.SectionID = CurrentGallery.SectionID;
			query.CategoryID = CSContext.Current.CategoryID;
			query.SortBy = userCookie.ThreadSortBy;
			query.SortOrder = userCookie.ThreadSortOrder;

			pagination.CurrentPage = Pictures.GetPictureSortOrder(CSContext.Current.PostID, query);
			if(CSContext.Current.CategoryID != -1)
			{
				PostCategory category = PostCategories.GetCategory(CSContext.Current.CategoryID, CategoryType.GalleryPicture, CurrentGallery.SectionID);
				pagination.TotalPages = category.TotalThreads;
			}
			else
				pagination.TotalPages = CurrentGallery.TotalThreads;
			pagination.UseClickEvent = true;
			pagination.DataBind();

			// Main information
			Name.Text = DataSource.Subject;
			Description.Text = DataSource.FormattedBody.Replace("\n", "<br/>");

			// Set visibility of statistic properties based on what is enabled/disabled for the gallery
			TotalComments.Visible = DataSource.EnableComments;

			// Statistic properties
			if(PostAuthor != null)
			{
				User author = Users.GetUser(DataSource.AuthorID, false);
				if(author.IsAnonymous)
					PostAuthor.Text = DataSource.Username;
				else
					PostAuthor.Text = "<a href='" + Globals.GetSiteUrls().UserProfile(author.UserID) + "'>" + author.Username + "</a>";
			}
			ViewCount.Text = DataSource.Views.ToString();
			TotalComments.Text = DataSource.Replies.ToString();

            // Links from this page
			detailsImage.NavigateUrl = GalleryUrls.Instance().PictureUrl(CurrentGallery.ApplicationKey, DataSource.PostID);
			OriginalLink.NavigateUrl = detailsImage.NavigateUrl;

			// Resource text
			OriginalLink.Text = ResourceManager.GetString( "Gallery_PictureDetails_OriginalPicture" );

			// Enable Order Prints
			if(CurrentGallery.EnableOrderPrints)
			{
				OrderLink.Text = ResourceManager.GetString( "Gallery_PictureDetails_OrderPrints" );
				OrderLink.NavigateUrl = "javascript:void(0);";
				OrderLink.Attributes.Add("onclick", "javascript:window.open('" + GalleryUrls.Instance().ViewOrderPrints(CurrentGallery.ApplicationKey, DataSource.PostID, DataSource.Width, DataSource.Height, 140, 150) + "', '_blank', '');");
				OrderLink.Visible = true;
			}
			else
				OrderLink.Visible = false;
		}

		private void pagination_PageChanged(object sender, EventArgs e)
		{
			string url = null;

			GalleryThreadQuery query = new GalleryThreadQuery();
			query.SectionID = CurrentGallery.SectionID;
			query.CategoryID = CSContext.Current.CategoryID;
			query.PageIndex = pagination.SelectedPage-1;
			query.PageSize = 1;

			ArrayList pictures = Pictures.GetPictures(query).Threads;
			if(pictures.Count > 0)
			{
				if(CSContext.Current.CategoryID == -1)
					url = GalleryUrls.Instance().ViewPicture(CurrentGallery.ApplicationKey, ((Picture)pictures[0]));
				else
					url = GalleryUrls.Instance().ViewPicture(CurrentGallery.ApplicationKey, CSContext.Current.CategoryID, ((Picture)pictures[0]));
			}

			if(url != null)
				Page.Response.Redirect(url, true);
		}
	}
}

⌨️ 快捷键说明

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