public override Field GetResult()
        {
            Field field = new Field( Field.Var, null, Field.Type );
            field.SetValueBool( ( bool ) _checkBox.IsChecked ) ;

            return field ;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the XData Response Element from the entered Data in the GUI Form
        /// </summary>
        /// <returns></returns>
        public Data CreateResponse()
        {
            Data data = new Data(XDataFormType.submit);
            foreach(XDataFieldControl ctl in panelFields.Controls)
            {
                Type type = ctl.GetType();

                if ( type == typeof(XDataTextBox) )
                {
                    Field f;
                    XDataTextBox txt = ctl as XDataTextBox;
                    if (txt.Multiline == true)
                    {
                        f = new Field(FieldType.Text_Multi);
                    }
                    else
                    {
                        if (txt.IsPrivate)
                            f = new Field(FieldType.Text_Private);
                        else
                            f = new Field(FieldType.Text_Single);

                    }
                    f.AddValues(txt.Values);
                    f.Var = txt.Var;
                    data.AddField(f);

                }
                else if ( type == typeof(XDataHidden) )
                {
                    Field f;
                    XDataHidden hidden = ctl as XDataHidden;

                    f = new Field(FieldType.Hidden);

                    f.AddValue(hidden.Value);
                    f.Var = hidden.Var;

                    data.AddField(f);
                }
                else if ( type == typeof(XDataJidSingle) )
                {
                    XDataJidSingle jids = ctl as XDataJidSingle;
                    Field f = new Field(FieldType.Jid_Single);
                    f.SetValue(jids.Value);
                    f.Var = jids.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataJidMulti) )
                {
                    XDataJidMulti jidm = ctl as XDataJidMulti;
                    Field f = new Field(FieldType.Jid_Multi);
                    f.AddValues(jidm.Values);
                    f.Var = jidm.Var;
                    data.AddField(f);

                }
                else if ( type == typeof(XDataCheckBox) )
                {
                    XDataCheckBox chk = ctl as XDataCheckBox;
                    Field f = new Field(FieldType.Boolean);
                    f.SetValueBool(chk.Value);
                    f.Var = chk.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataListMulti) )
                {
                    XDataListMulti listm = ctl as XDataListMulti;
                    Field f = new Field(FieldType.List_Multi);
                    f.AddValues(listm.Values);
                    f.Var = listm.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataListSingle) )
                {
                    XDataListSingle lists = ctl as XDataListSingle;
                    Field f = new Field(FieldType.List_Single);
                    f.SetValue(lists.Value);
                    f.Var = lists.Var;
                    data.AddField(f);
                }
            }

            return data;
        }