📄 postview.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;using System.Web.UI;using CommunityServer.Components;
using CommunityServer.Discussions.Components;
using CommunityServer.Discussions.Controls.PostDisplay;namespace CommunityServer.Discussions.Controls
{
// *********************************************************************
// PostView
//
/// <summary>
/// This server control is used to display a Post
/// </summary>
///
// ********************************************************************/
public class PostView : Control, INamingContainer
{
ForumPost post;
CSContext csContext = CSContext.Current;
// *********************************************************************
// CreateChildControls
//
/// <summary>
/// Initializes the user control loaded in CreateChildControls. Initialization
/// consists of finding well known control names and wiring up any necessary events.
/// </summary>
///
// ********************************************************************/
protected override void CreateChildControls()
{
TextPost textPost;
// What kind of post are we working with
//
switch (this.Post.PostType)
{
// Post is formatted with BBCode
//
case PostType.BBCode:
textPost = new TextPost();
textPost.Post = Post;
Controls.Add(textPost);
break;
// Post is formatted with HTML
//
case PostType.HTML:
textPost = new TextPost();
textPost.Post = Post;
Controls.Add(textPost);
break;
// Post is a vote
//
case PostType.Poll:
PollPost pollPost = new PollPost(this.Post);
if (csContext.User.IsAnonymous)
pollPost.Enabled = false;
else {
if (Permissions.ValidatePermissions(post.Section,Permission.Vote,csContext.User))
pollPost.Enabled = true;
}
Controls.Add(pollPost);
break;
}
}
public ForumPost Post
{
get
{
if ( post == null )
{
Object state = ViewState["Post"];
if ( state != null )
{
Int32 postID = (Int32)state;
post = Posts.GetPost( postID, CSContext.Current.User.UserID, false );
}
}
return post;
}
set
{
post = value;
if ( post != null )
{
ViewState[ "Post" ] = post.PostID;
}
else
{
ViewState.Remove( "Post" );
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -