using System; namespace Gwen.Control { /// /// Progress bar. /// public class ProgressBar : Label { private bool m_Horizontal; private bool m_AutoLabel; private float m_Progress; /// /// Determines whether the control is horizontal. /// public bool IsHorizontal { get { return m_Horizontal; } set { m_Horizontal = value; } } /// /// Progress value (0-1). /// public float Value { get { return m_Progress; } set { if (value < 0) value = 0; if (value > 1) value = 1; m_Progress = value; if (m_AutoLabel) { int displayVal = (int)(m_Progress * 100); Text = displayVal.ToString() + "%"; } } } /// /// Determines whether the label text is autogenerated from value. /// public bool AutoLabel { get { return m_AutoLabel; } set { m_AutoLabel = value; } } /// /// Initializes a new instance of the class. /// /// Parent control. public ProgressBar(Base parent) : base(parent) { MouseInputEnabled = false; // [omeg] what? was true SetSize(128, 32); TextPadding = Padding.Three; IsHorizontal = true; Alignment = Pos.Center; m_Progress = 0; m_AutoLabel = true; } /// /// Renders the control using specified skin. /// /// Skin to use. protected override void Render(Skin.Base skin) { skin.DrawProgressBar(this, m_Horizontal, m_Progress); } } }