Exemple #1
0
        public IFormElement Render()
        {
            IFormElement element;

            switch (Type)
            {
            case FormElementType.Entry:
                element = new EntryElement();
                break;

            case FormElementType.Address:
                element = new AddressElement();
                break;

            case FormElementType.DatePicker:
                element = new DatePickerElement();
                break;

            case FormElementType.Picker:
                element = new PickerElement();
                break;

            case FormElementType.Editor:
                element = new EditorElement();
                break;

            case FormElementType.Switch:
                element = new SwitchElement();
                break;

            case FormElementType.CheckboxList:
                element = new CheckboxListElement();
                break;

            case FormElementType.Hidden:
                element = new HiddenElement();
                break;

            case FormElementType.Button:
                element = new ButtonElement();
                break;

            case FormElementType.Label:
                element = new LabelElement();
                break;

            default:
                element = new EntryElement();
                break;
            }
            element.Label         = this.Label;
            element.Key           = Key;
            element.Keyboard      = Keyboard;
            element.HeightRequest = HeightRequest;
            element.Options       = Options;
            element.Required      = Required;
            element.Attributes    = Attributes;
            element.AutoPostBack  = AutoPostBack;

            if (!string.IsNullOrWhiteSpace(ElementBackgroundColor))
            {
                element.ElementBackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(ElementBackgroundColor);
            }

            if (!string.IsNullOrWhiteSpace(ElementTextColor))
            {
                element.ElementTextColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(ElementTextColor);
            }

            element.Render();
            if (!string.IsNullOrWhiteSpace(Value))
            {
                element.Value = Value;
            }

            return(element);
        }