1 using System.Globalization;
2 using System.Windows.Forms;
4 namespace LibCECTray.settings
7 /// A setting of type ushort that can be persisted in the registry
9 class CECSettingUShort : CECSettingString
11 public CECSettingUShort(string keyName, string friendlyName, ushort defaultValue, SettingChangedHandler changedHandler) :
12 base(CECSettingType.UShort, keyName, friendlyName, string.Format("{0,4:X}", defaultValue), changedHandler)
16 public new ushort Value
21 return base.Value != null && ushort.TryParse(base.Value, NumberStyles.AllowHexSpecifier, null, out iValue) ? iValue : ushort.MinValue;
25 base.Value = string.Format("{0,4:X}", value);
27 Form.SetControlText(ValueControl, base.Value);
31 public new ushort DefaultValue
36 return base.DefaultValue != null && ushort.TryParse(base.DefaultValue, NumberStyles.AllowHexSpecifier, null, out iValue) ? iValue : ushort.MinValue;
38 set { base.DefaultValue = string.Format("{0,4:X}", value); }
41 public new Control ValueControl
45 if (BaseValueControl == null)
47 TextBox control = new TextBox
50 Size = new System.Drawing.Size(100, 20),
51 Enabled = InitialEnabledValue,
52 Text = string.Format("{0,4:X}", Value)
54 control.TextChanged += delegate
58 !ushort.TryParse(control.Text, NumberStyles.AllowHexSpecifier, null,
60 iValue = DefaultValue;
63 BaseValueControl = control;
65 return BaseValueControl;