ProgressBarClass.cs :  » Game » Killer-Instinct » KillerInstinct » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » Killer Instinct 
Killer Instinct » KillerInstinct » ProgressBarClass.cs
using System;
using System.Drawing;
using Microsoft.DirectX.DirectDraw;
using DebugGlobal.Debug;
using Global.GlobalClass;
using KillerInstinct.DirectX;

namespace KillerInstinct{
  public class ProgressBarClass
  {
    private int      m_range;
    private int      m_currentValue;
    private int      m_width;
    private int      m_height;
    private Color    m_borderColor;
    private Color    m_barColor;
    private Color    m_backColor;
    // this controls how much of the progress bar is filled in
    public int CurrentValue
    {
      set
      { m_currentValue = value; }
    }
    public Color BarColor
    {
      get
      { return m_barColor; }
    }
    // allow maximum (range) to be changed
    public int Max
    {
      set
      { m_range = value; }
    }
    public ProgressBarClass(int width, int height, int curValue, int range, Color borderColor, Color barColor, Color backColor)
    {
      global.dbg.Out(Debug.DBG2, "ProgressBarClass called, width=[" + width + "] height=[" + height + "] curVal=[" + curValue + "] range=[" + range + "] borderColor=[" + borderColor + "] barColor=[" + barColor + "] backColor=[" + backColor + "]");
      m_borderColor  = borderColor;  // progress bar's color
      m_barColor    = barColor;    // color of how much of the bar is filled (background)
      m_backColor    = backColor;  // behind bar color
      m_currentValue  = curValue;    // current position in the progress bar
      m_range      = range;    // maximum range of this progress bar
      m_width      = width;    // width (in pixels) of bar
      m_height    = height;    // height (in pixels) of bar
      if (range <= 0)
        global.dbg.Out(Debug.ERR, "ProgressBarClass range is invalid [" + range + "].");
    }
    public void Draw(int x, int y, int curValue)
    {
      Draw(x, y, curValue, Color.Empty);
    }
    public void Draw(int x, int y, int curValue, Color barColor)
    {
      if (m_range <= 0)
      {
        global.dbg.Out(Debug.ERR, "ProgressBarClass.Draw:: range is invalid [" + m_range + "].");
        return;
      }
      try
      {
        Color drawColor = barColor;
        // don't allow to over-step maximum value
        if (curValue <= m_range)
        {
          // if a color was NOT specified, use the default set in constructor
          if (barColor == Color.Empty)
            drawColor = m_barColor;
          m_currentValue = curValue;
          // right, // bottom //rw, //rh
          //dest.DrawRoundedBox(m_x, m_y, m_x+30, m_y+10, 0, 0);
          // draw entire progress bar (empty)
          global.DC.DrawBox(x, y, m_width, m_height, m_borderColor, m_backColor);
          // draw filled in portion of the bar
          // curVal(60) / range(100) = 0.67 * 100 = diff(67) x width(50) = 3350 / 100 = 33.5
          float diff = (m_currentValue*100) / m_range;
          float width = (diff * (m_width-1)) / 100;
          // only draw if something to draw
          if ((int)width > 1)
            global.DC.DrawBox(x+1, y+1, (int)width, m_height-2, drawColor, drawColor);
        }
      }
      catch( Exception e )
      {
        global.dbg.Out(Debug.ERR, "ProgressBarClass.Draw exception: " + e);
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.