进度条的生成和打印效果代码
2017-02-26 16:01:56 访问(1355) 赞(0) 踩(0)
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using SlowX.Functions.Common;
namespace SlowX.Functions.Functions
{
/// <summary>
/// 中文相关的方法
/// </summary>
public class ProgressBarSlowXFunctions
{
/// <summary>
/// 进度条的初始化
/// </summary>
/// <param name="msg">最开始显示的信息</param>
public static void HProgressBarStart( string msg)
{
HProgressBarStart(System.Web.HttpContext.Current.Response, msg);
}
/// <summary>
/// 进度条的初始化
/// </summary>
/// <param name="r"></param>
/// <param name="msg"></param>
public static void HProgressBarStart(HttpResponse r, string msg)
{
StringBuilder theResult = new StringBuilder();
theResult.AppendLine("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<title></title>");
theResult.AppendLine("<style>body {text-align:center;margin-top: 50px;}#ProgressBarSide {height:25px;border:1px #2F2F2F;width:65%;background:#EEFAFF;}</style>");
theResult.AppendLine("<script language=\"javascript\">");
theResult.AppendLine("function SetPorgressBar(msg, pos)");
theResult.AppendLine("{");
theResult.AppendLine("document.getElementById('ProgressBar').style.width = pos + \"%\";");
theResult.AppendLine("WriteText('Msg1',msg + \" 已完成\" + pos + \"%\");");
theResult.AppendLine("}");
theResult.AppendLine("function SetCompleted(msg)\r\n{\r\nif(msg==\"\")\r\nWriteText(\"Msg1\",\"完成。\");");
theResult.AppendLine("else\r\nWriteText(\"Msg1\",msg);\r\n}");
theResult.AppendLine("function WriteText(id, str)");
theResult.AppendLine("{");
theResult.AppendLine("var strTag = '<span style=\"font-family:Verdana, Arial, Helvetica;font-size=11.5px;color:#DD5800\">' + str + '</span>';");
theResult.AppendLine("document.getElementById(id).innerHTML = strTag;");
theResult.AppendLine("}");
theResult.AppendLine("</script>\r\n</head>\r\n<body>");
theResult.AppendLine("<div id=\"Msg1\"><span style=\"font-family:Verdana, Arial, Helvetica;font-size=11.5px;color:#DD5800\">" + msg + "</span></div>");
theResult.AppendLine("<div id=\"ProgressBarSide\" align=\"left\" style=\"color:Silver;border-width:1px;border-style:Solid;\">");
theResult.AppendLine("<div id=\"ProgressBar\" style=\"background-color:#008BCE; height:25px; width:0%;color:#fff;\"></div>");
theResult.AppendLine("</div>\r\n</body>\r\n</html>");
r.Write(theResult.ToString());
r.Flush();
}
/// <summary>
/// 滚动进度条
/// </summary>
/// <param name="Msg">在进度条上方显示的信息</param>
/// <param name="Pos">显示进度的百分比数字</param>
public static void HProgressBarRoll(string Msg, int Pos)
{
string jsBlock = "<script language=\"javascript\">SetPorgressBar('" + Msg + "'," + Pos + ");</script>";
System.Web.HttpContext.Current.Response.Write(jsBlock);
System.Web.HttpContext.Current.Response.Flush();
}
/// <summary>
/// 滚动进度条
/// </summary>
/// <param name="r"></param>
/// <param name="Msg">在进度条上方显示的信息</param>
/// <param name="Pos">显示进度的百分比数字</param>
public static void HProgressBarRoll(HttpResponse r, string Msg, int Pos)
{
string jsBlock = "<script language=\"javascript\">SetPorgressBar('" + Msg + "'," + Pos + ");</script>";
r.Write(jsBlock);
r.Flush();
}
}
}
标签:
进度条的生成和打印效果代码 


上一条:
下一条:
相关评论
发表评论