From c6387c4070d60bdd58bc0cf5cdb7bea07b7bfdbf Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Thu, 15 Jun 2017 22:33:12 -0700 Subject: [PATCH] Add Input --- Ooui/FormControl.cs | 6 +++ Ooui/Input.cs | 92 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 Ooui/Input.cs 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, + } +}