diff --git a/Ooui/FormControl.cs b/Ooui/FormControl.cs index 055b471..e98607e 100644 --- a/Ooui/FormControl.cs +++ b/Ooui/FormControl.cs @@ -10,6 +10,12 @@ namespace Ooui set => SetProperty (ref name, value, "name"); } + bool isDisabled = false; + public bool IsDisabled { + get => isDisabled; + set => SetProperty (ref isDisabled, value, "disabled"); + } + public FormControl (string tagName) : base (tagName) { diff --git a/Ooui/Input.cs b/Ooui/Input.cs new file mode 100644 index 0000000..74a73d7 --- /dev/null +++ b/Ooui/Input.cs @@ -0,0 +1,92 @@ +using System; + +namespace Ooui +{ + public class Input : FormControl + { + InputType typ = InputType.Text; + public InputType Type { + get => typ; + set => SetProperty (ref typ, value, "type"); + } + + string val = ""; + public string Value { + get => val; + set => SetProperty (ref val, value ?? "", "value"); + } + + public double NumberValue { + get { + double v; + double.TryParse (Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.CurrentUICulture, out v); + return v; + } + set { + Value = value.ToString (System.Globalization.CultureInfo.CurrentUICulture); + } + } + + bool isChecked = false; + public bool IsChecked { + get => isChecked; + set => SetProperty (ref isChecked, value, "checked"); + } + + double minimum = 0; + public double Minimum { + get => minimum; + set => SetProperty (ref minimum, value, "min"); + } + + double maximum = 100; + public double Maximum { + get => maximum; + set => SetProperty (ref maximum, value, "max"); + } + + double step = 100; + public double Step { + get => step; + set => SetProperty (ref step, value, "step"); + } + + public Input () + : base ("input") + { + } + + public Input (InputType type) + : this () + { + Type = type; + } + } + + public enum InputType + { + Text, + Date, + Week, + Datetime, + DatetimeLocal, + Time, + Month, + Range, + Number, + Hidden, + Search, + Email, + Tel, + Url, + Password, + Color, + Checkbox, + Radio, + File, + Submit, + Reset, + Image, + Button, + } +}