📄 searchoptions.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;using System.Web.UI;using System.Web.UI.WebControls;using CommunityServer.Components;using CommunityServer.Controls;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls.Search
{
// *********************************************************************
// SearchOptions
//
/// <summary>
/// This server control renders and handles the search UI for the user.
/// </summary>
// ***********************************************************************/
public class SearchOptions : SkinnedWebControl
{
string skinFilename = "Skin-SearchOptions.ascx";
DropDownList forumList;
DropDownList searchType;
DropDownList matchType;
Button searchButton;
// *********************************************************************
// SearchOptions
//
/// <summary>
/// Constructor
/// </summary>
// ***********************************************************************/
public SearchOptions() : base()
{
// Assign a default template name
if (SkinFilename == null)
SkinFilename = skinFilename;
}
// *********************************************************************
// Initializeskin
//
/// <summary>
/// Initialize the control template and populate the control with values
/// </summary>
// ***********************************************************************/
override protected void InitializeSkin(Control skin)
{
// Find the forum list control
forumList = (DropDownList) skin.FindControl("forumList");
if (null != forumList)
{
forumList.DataSource = Forums.GetForums();
forumList.DataTextField = "Name";
forumList.DataValueField = "ForumID";
forumList.DataBind();
// Add the "All Forums" option if the user is allowed to search all forums
if (AllowSearchAllForums)
forumList.Items.Insert(0, new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_AllForums"), "-1"));
}
// What are we searching for posts or users?
searchType = (DropDownList) skin.FindControl("SearchType");
if (null != searchType)
{
searchType.Items.Add(new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_Posts"), "0"));
searchType.Items.Add(new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_PostedBy"), "1"));
}
matchType = (DropDownList) skin.FindControl("MatchType");
if (null != matchType)
{
matchType.Items.Add(new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_MatchAll"), "0"));
matchType.Items.Add(new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_MatchAny"), "1"));
matchType.Items.Add(new ListItem(CommunityServer.Components.ResourceManager.GetString("Search_SearchOptions_MatchExact"), "2"));
}
searchButton = (Button) skin.FindControl("Search_Button");
if (null != searchButton)
{
searchButton.Text = ResourceManager.GetString("Search");
searchButton.Click += new EventHandler(SearchButton_Click);
}
}
// *********************************************************************
// SearchButton_Click
//
/// <summary>
/// This event handler is called when the user clicks on the submit button,
/// firing off the search. It resets the DataGrid's CurrentPageIndex to 0
/// and Displays the Search Results.
/// </summary>
// ***********************************************************************/
private void SearchButton_Click(Object sender, EventArgs e)
{
// Exit if the page is invalid
if (!Page.IsValid)
return;
}
/// <summary>
/// Does the control allow the searching of all forums
/// </summary>
[
System.ComponentModel.DefaultValue( true ),
]
public virtual Boolean AllowSearchAllForums
{
get
{
Object state = ViewState["AllowSearchAllForums"];
if ( state != null )
{
return (Boolean)state;
}
return true;
}
set
{
ViewState["AllowSearchAllForums"] = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -