using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace CK.SCP.Common { public partial class CktSwitchButton : UserControl { public CktSwitchButton() { InitializeComponent(); switchValue.Width = Width - Lbl.Width - 3; } public string LblText { get { return Lbl.Text; } set { Lbl.Text = value; // using (var g = this.CreateGraphics()) // { // var strSize = g.MeasureString(Caption.Text, Caption.Font); // Caption.Width = (int)strSize.Width + 6; // } } } [DefaultValue(false)] public bool Value { get { return switchValue.Value; } set { switchValue.Value = value; } } public override string Text { get { return switchValue.Text; } set { switchValue.Text = value; } } public int BoxWidth { get; set; } // get { return txtValue.Width; } // set { txtValue.Width = value; } public int LblWidth { get { return Lbl.Width; } set { Lbl.Width = value; switchValue.Width = Width - Lbl.Width - 3; } } public Boolean IsReadOnly { get { return switchValue.IsReadOnly; } set { switchValue.IsReadOnly = value; } } public override bool Focused => switchValue.Focused; public StringAlignment LblTextAlign { get { return Lbl.TextAlignment; } set { Lbl.TextAlignment = value; } } public new bool Enabled { get { return switchValue.Enabled; } set { switchValue.Enabled = value; } } private void UcLabelTextBox_SizeChanged(object sender, EventArgs e) { switchValue.Width = Width - Lbl.Width - 3; } // public delegate void TextChangedHandler(object sender, System.EventArgs e); // public event TextChangedHandler TxtTextChanged; // private void txtValue_TextChanged(object sender, EventArgs e) // { // try // { // TxtTextChanged?.Invoke(sender, e); // } // catch // { // // ignored // } // } } }