private void Layout(Panel Container, JidMultiField Field, DataForm Form)
        {
            TextBox TextBox = this.LayoutTextBox(Container, Field);

            TextBox.TextChanged  += new TextChangedEventHandler(TextBox_TextChanged);
            TextBox.AcceptsReturn = true;
            TextBox.AcceptsTab    = true;
            TextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
        }
Beispiel #2
0
        private Control Layout(Panel Container, JidMultiField Field, DataForm _)
        {
            TextBox TextBox = this.LayoutTextBox(Container, Field);

            TextBox.TextChanged  += this.TextBox_TextChanged;
            TextBox.AcceptsReturn = true;
            TextBox.AcceptsTab    = true;
            TextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

            return(TextBox);
        }
Beispiel #3
0
        private Field ParseField(XmlElement E)
        {
            string        Label        = XML.Attribute(E, "label");
            string        Type         = XML.Attribute(E, "type");
            string        Var          = XML.Attribute(E, "var");
            List <string> ValueStrings = null;
            List <KeyValuePair <string, string> > OptionStrings = null;
            string           Description      = string.Empty;
            string           DataTypeName     = null;
            DataType         DataType         = null;
            ValidationMethod ValidationMethod = null;
            Media            Media            = null;
            Field            Field;
            string           Error    = null;
            bool             Required = false;
            bool             PostBack = false;
            bool             ReadOnly = false;
            bool             NotSame  = false;

            foreach (XmlNode N2 in E.ChildNodes)
            {
                switch (N2.LocalName)
                {
                case "desc":
                    Description = N2.InnerText;
                    break;

                case "required":
                    Required = true;
                    break;

                case "value":
                    if (ValueStrings == null)
                    {
                        ValueStrings = new List <string>();
                    }

                    ValueStrings.Add(N2.InnerText);
                    break;

                case "option":
                    if (OptionStrings == null)
                    {
                        OptionStrings = new List <KeyValuePair <string, string> >();
                    }

                    string OptionLabel = XML.Attribute((XmlElement)N2, "label");
                    string OptionValue = string.Empty;

                    foreach (XmlNode N3 in N2.ChildNodes)
                    {
                        if (N3.LocalName == "value")
                        {
                            OptionValue = N3.InnerText;
                            break;
                        }
                    }

                    OptionStrings.Add(new KeyValuePair <string, string>(OptionLabel, OptionValue));
                    break;

                case "validate":
                    DataTypeName = XML.Attribute((XmlElement)N2, "datatype");

                    foreach (XmlNode N3 in N2.ChildNodes)
                    {
                        switch (N3.LocalName)
                        {
                        case "basic":
                            ValidationMethod = new BasicValidation();
                            break;

                        case "open":
                            ValidationMethod = new OpenValidation();
                            break;

                        case "range":
                            XmlElement E3 = (XmlElement)N3;

                            ValidationMethod = new RangeValidation(
                                XML.Attribute(E3, "min"),
                                XML.Attribute(E3, "max"));
                            break;

                        case "regex":
                            ValidationMethod = new RegexValidation(N3.InnerText);
                            break;

                        case "list-range":
                            E3 = (XmlElement)N3;

                            ValidationMethod = new ListRangeValidation(ValidationMethod,
                                                                       XML.Attribute(E3, "min", 0),
                                                                       XML.Attribute(E3, "max", int.MaxValue));
                            break;
                        }
                    }
                    break;

                case "media":
                    Media = new Media((XmlElement)N2);
                    break;

                case "postBack":
                    PostBack = true;
                    break;

                case "readOnly":
                    ReadOnly = true;
                    break;

                case "notSame":
                    NotSame = true;
                    break;

                case "error":
                    Error = N2.InnerText;
                    break;
                }
            }

            if (string.IsNullOrEmpty(DataTypeName))
            {
                if (Type == "boolean")
                {
                    DataTypeName = "xs:boolean";
                }
                else
                {
                    DataTypeName = "xs:string";
                }
            }

            switch (DataTypeName.ToLower())
            {
            case "xs:boolean":
                DataType = BooleanDataType.Instance;
                break;

            case "xs:string":
            default:
                DataType = StringDataType.Instance;
                break;

            case "anyuri":
                DataType = AnyUriDataType.Instance;
                break;

            case "xs:byte":
                DataType = ByteDataType.Instance;
                break;

            case "xs:date":
                DataType = DateDataType.Instance;
                break;

            case "xs:datetime":
                DataType = DateTimeDataType.Instance;
                break;

            case "xs:decimal":
                DataType = DecimalDataType.Instance;
                break;

            case "xs:double":
                DataType = DoubleDataType.Instance;
                break;

            case "xs:int":
                DataType = IntDataType.Instance;
                break;

            case "xs:integer":
                DataType = IntegerDataType.Instance;
                break;

            case "xs:language":
                DataType = LanguageDataType.Instance;
                break;

            case "xs:long":
                DataType = LongDataType.Instance;
                break;

            case "xs:short":
                DataType = ShortDataType.Instance;
                break;

            case "xs:time":
                DataType = TimeDataType.Instance;
                break;

            case "xdc:Color":
                DataType = ColorDataType.Instance;
                break;

            case "xdc:ColorAlpha":
                DataType = ColorAlphaDataType.Instance;
                break;
            }

            if (ValidationMethod == null)
            {
                ValidationMethod = new BasicValidation();
            }

            switch (Type)
            {
            case "boolean":
                Field = new BooleanField(this, Var, Label, Required,
                                         ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                         Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "fixed":
                Field = new FixedField(this, Var, Label, Required,
                                       ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                       Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "hidden":
                Field = new HiddenField(this, Var, Label, Required,
                                        ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                        Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "jid-multi":
                Field = new JidMultiField(this, Var, Label, Required,
                                          ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                          Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "jid-single":
                Field = new JidSingleField(this, Var, Label, Required,
                                           ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                           Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "list-multi":
                Field = new ListMultiField(this, Var, Label, Required,
                                           ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                           Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "list-single":
                Field = new ListSingleField(this, Var, Label, Required,
                                            ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                            Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "text-multi":
                Field = new TextMultiField(this, Var, Label, Required,
                                           ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                           Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "text-private":
                Field = new TextPrivateField(this, Var, Label, Required,
                                             ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                             Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            case "text-single":
                Field = new TextSingleField(this, Var, Label, Required,
                                            ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                            Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                break;

            default:
                if (Media == null)
                {
                    Field = new TextSingleField(this, Var, Label, Required,
                                                ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                                Description, DataType, ValidationMethod, Error, PostBack, ReadOnly, NotSame);
                }
                else
                {
                    Field = new MediaField(this, Var, Label, Required,
                                           ValueStrings?.ToArray(), OptionStrings?.ToArray(),
                                           Description, DataType, ValidationMethod, Media, Error, PostBack, ReadOnly, NotSame);
                }
                break;
            }

            return(Field);
        }