• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

A Horizontal Percentage Gauge Class

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 14次 | 进入软件测试论坛讨论

领测软件测试网 <%
  Dim sl_gauge
  Set sl_gauge = new Slgauge
  sl_gauge.BgColor = "#FFFFFF"
  sl_gauge.FgColor = "#990000"
  sl_gauge.Width = 78
  sl_gauge.Height = 5
  sl_gauge.MinVal = 0
  sl_gauge.MaxVal = 100
  sl_gauge.CurVal = iTestScore  ‘’87% in our example
%>
<!-- Display the gauge -->
<table cellpadding=0 cellspacing=2>
  <tr>
     <td>0</td>
     <td><% = sl_gauge.RenderHtml %></td>
     <td>100%</td>
</tr>
</table>

<%
‘’ Handy class for displaying a horizontal percentage gauge.
%>
<%
class Slgauge
  ‘’ Colors.
  public BgColor
  public FgColor

  ‘’ Dimensions.
  public Width
  public Height

  ‘’ Values.
  public MinVal
  public MaxVal
  public CurVal

  ‘’ Render this into HTML as a table.
  function RenderHtml
      ‘’ Normalize the properties.
      if MinVal > MaxVal then
          Dim temp_val
          temp_val = MinVal
          MinVal = MaxVal
          MaxVal = temp_val
      end if

      if CurVal < MinVal then
          CurVal = MinVal
      elseif CurVal > MaxVal then
          CurVal = MaxVal
      end if

      ‘’ Figure out the percentage that the CurVal is
      ‘’ within MinVal and MaxVal.
      Dim percentage_val
      percentage_val = (CurVal - MinVal) / (MaxVal - MinVal)

      ‘’ Compute the first and second widths.
      Dim fg_width
      fg_width = Round(Width * percentage_val)
      Dim bg_width
      bg_width = Width - fg_width

      RenderHtml = "<table cellspacing=0 cellpadding=0 width=" & _
                   Width & " height=" & Height & ">" _
                   & "<tr>"
      if fg_width > 0 then
          RenderHtml = RenderHtml _
                      & "<td width=" & fg_width & " height=" & _
                      Height & " bgcolor=" & FgColor & _
                      "><img src=/demos/Images/" & _
                      "1_pix_trans.gif></td>"
      end if
      if bg_width > 0 then
          RenderHtml = RenderHtml _
                          & "<td width=" & bg_width & " height=" & _
                          Height & " bgcolor=" & BgColor & _
                          "><img src=/demos/Images/" & _
                          "1_pix_trans.gif></td>"
      end if
      RenderHtml = RenderHtml _
                      & "</tr>" _
                      & "</table>"
  end function
end class
%>

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网