using System; namespace Gwen.Control.Property { /// /// Checkable property. /// public class Check : Base { protected readonly Control.CheckBox m_CheckBox; /// /// Initializes a new instance of the class. /// /// Parent control. public Check(Control.Base parent) : base(parent) { m_CheckBox = new Control.CheckBox(this); m_CheckBox.ShouldDrawBackground = false; m_CheckBox.CheckChanged += OnValueChanged; m_CheckBox.IsTabable = true; m_CheckBox.KeyboardInputEnabled = true; m_CheckBox.SetPosition(2, 1); Height = 18; } /// /// Property value. /// public override string Value { get { return m_CheckBox.IsChecked ? "1" : "0"; } set { base.Value = value; } } /// /// Sets the property value. /// /// Value to set. /// Determines whether to fire "value changed" event. public override void SetValue(string value, bool fireEvents = false) { if (value == "1" || value.ToLower() == "true" || value.ToLower() == "yes") { m_CheckBox.IsChecked = true; } else { m_CheckBox.IsChecked = false; } } /// /// Indicates whether the property value is being edited. /// public override bool IsEditing { get { return m_CheckBox.HasFocus; } } /// /// Indicates whether the control is hovered by mouse pointer. /// public override bool IsHovered { get { return base.IsHovered || m_CheckBox.IsHovered; } } } }