using System;
using System.ComponentModel;
using System.Windows.Forms;
using FastReport.Utils;
namespace FastReport.Dialog
{
///
/// Uses a mask to distinguish between proper and improper user input.
/// Wraps the control.
///
public partial class MaskedTextBoxControl : DataFilterBaseControl
{
private MaskedTextBox maskedTextBox;
#region Properties
///
/// Gets an internal MaskedTextBox.
///
[Browsable(false)]
public MaskedTextBox MaskedTextBox
{
get { return maskedTextBox; }
}
///
/// Gets or sets the input mask to use at run time.
/// Wraps the property.
///
[Category("Data")]
public string Mask
{
get { return MaskedTextBox.Mask; }
set { MaskedTextBox.Mask = value; }
}
///
/// Gets or sets a value indicating whether the user is allowed to reenter literal values.
/// Wraps the property.
///
[DefaultValue(true)]
[Category("Behavior")]
public bool SkipLiterals
{
get { return MaskedTextBox.SkipLiterals; }
set { MaskedTextBox.SkipLiterals = value; }
}
///
/// Gets or sets how text is aligned in a masked text box control.
/// Wraps the property.
///
[DefaultValue(HorizontalAlignment.Left)]
[Category("Appearance")]
public HorizontalAlignment TextAlign
{
get { return MaskedTextBox.TextAlign; }
set { MaskedTextBox.TextAlign = value; }
}
#endregion
#region Protected Methods
///
protected override object GetValue()
{
return Text;
}
#endregion
#region Public Methods
///
public override void Serialize(FRWriter writer)
{
MaskedTextBoxControl c = writer.DiffObject as MaskedTextBoxControl;
base.Serialize(writer);
if (Mask != c.Mask)
writer.WriteStr("Mask", Mask);
if (SkipLiterals != c.SkipLiterals)
writer.WriteBool("SkipLiterals", SkipLiterals);
if (TextAlign != c.TextAlign)
writer.WriteValue("TextAlign", TextAlign);
}
///
public override void OnLeave(EventArgs e)
{
base.OnLeave(e);
OnFilterChanged();
}
#endregion
///
/// Initializes a new instance of the MaskedTextBoxControl class with default settings.
///
public MaskedTextBoxControl()
{
maskedTextBox = new MaskedTextBox();
Control = maskedTextBox;
BindableProperty = this.GetType().GetProperty("Text");
}
}
}