📄 progressbar.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.ComponentModel;using System.Web.UI;using System.Web.UI.WebControls;using CommunityServer.Components;namespace CommunityServer.Discussions.Controls.PostDisplay
{
/// <summary>
/// Progress bar control is used for multiple purposes to
/// display the progress or status of a particular action
/// for example, it can be used as bars in the voting control
/// </summary>
[
DefaultProperty("Text"),
]
public class ProgressBar : Control, INamingContainer
{
// Member variables
//
int maxWidth = 250;
float progress = 0; // Percentage out of 100
// Set the percentage of progress
//
public float PercentageOfProgress
{
get
{
return progress;
}
set
{
// Ensure it falls in the correct bounds
//
if (value > 100) // Greater than 100 is still 100
progress = 1;
else if (value < 0) // Less than 0 is stil 0
progress = 0;
progress = ((float) value) / 100;
}
}
public int Width
{
get
{
return (int) (PercentageOfProgress * (float) maxWidth);
}
}
// Render the progress bar
//
protected override void Render(HtmlTextWriter output)
{
Image start = new Image();
Image mid = new Image();
Image end = new Image();
Image noneMid = new Image();
Image noneEnd = new Image();
start.ImageUrl = Globals.GetSkinPath() + "/images/poll_a_start.gif";
start.Height = 19;
mid.ImageUrl = Globals.GetSkinPath() + "/images/poll_a_mid.gif";
mid.Height = 19;
noneMid.ImageUrl = Globals.GetSkinPath() + "/images/poll_none_mid.gif";
noneMid.Height = 19;
end.ImageUrl = Globals.GetSkinPath() + "/images/poll_a_end.gif";
end.Height = 19;
noneEnd.ImageUrl = Globals.GetSkinPath() + "/images/poll_none_end.gif";
noneEnd.Height = 19;
start.RenderControl(output);
if (PercentageOfProgress > 0)
{
mid.Width = Width;
noneMid.Width = (maxWidth - Width);
mid.RenderControl(output);
end.RenderControl(output);
noneMid.RenderControl(output);
}
else
{
noneMid.Width = maxWidth + 7;
noneMid.RenderControl(output);
}
noneEnd.RenderControl(output);
/*
// Create 20 cells
for (int i = 0; i < 20; i++ ) {
TableCell td = new TableCell();
td.Width = 5;
td.Height = 16;
// How should we fill this table?
//
if (i < percentOfProgress)
td.BackColor = this.ForeColor;
else
td.BackColor = this.BackColor;
// Add cell to row
//
row.Cells.Add(td);
}
this.Controls.Add(table);
table.RenderControl(output);
*/
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -