This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
gwen-dotnet/Gwen/Control/TextBoxPassword.cs

42 lines
1.1 KiB
C#
Raw Normal View History

using System;
namespace Gwen.Control
{
/// <summary>
/// Text box with masked text.
/// </summary>
/// <remarks>
/// This class doesn't prevent programatic access to the text in any way.
/// </remarks>
public class TextBoxPassword : TextBox
{
private String m_Mask;
private char m_MaskCharacter;
/// <summary>
/// Character used in place of actual characters for display.
/// </summary>
public char MaskCharacter { get { return m_MaskCharacter; } set { m_MaskCharacter = value; } }
/// <summary>
/// Initializes a new instance of the <see cref="TextBoxPassword"/> class.
/// </summary>
/// <param name="parent">Parent control.</param>
public TextBoxPassword(Base parent)
: base(parent)
{
m_MaskCharacter = '*';
}
/// <summary>
/// Handler for text changed event.
/// </summary>
protected override void OnTextChanged()
{
m_Mask = new string(MaskCharacter, Text.Length);
TextOverride = m_Mask;
base.OnTextChanged();
}
}
}