Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a form element from a given field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="tabIdx"></param>
        /// <returns></returns>
        private XDataFieldControl CreateField(Field field, int tabIdx)
        {
            XDataFieldControl m_DataControl;
            //			panelFields.SuspendLayout();

            FieldType m_Type = field.Type;
            string lbl;
            switch (m_Type)
            {
                case FieldType.Hidden:
                    m_DataControl = new XDataHidden();
                    ((XDataHidden) m_DataControl).Value		= field.GetValue();

                    break;
                case FieldType.Fixed:
                    m_DataControl = new XDataLabel();

                    ((XDataLabel) m_DataControl).Value		= field.GetValue();

                    break;
                case FieldType.Boolean:
                    m_DataControl = new XDataCheckBox();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataCheckBox) m_DataControl).Text	= lbl;
                    ((XDataCheckBox) m_DataControl).Value	= field.GetValueBool();

                    break;
                case FieldType.Text_Private:
                    m_DataControl = new XDataTextBox();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataTextBox) m_DataControl).Text			= lbl;
                    ((XDataTextBox) m_DataControl).Value		= field.GetValue();
                    ((XDataTextBox) m_DataControl).IsPrivate	= true;

                    break;
                case FieldType.Text_Single:
                    m_DataControl = new XDataTextBox();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataTextBox) m_DataControl).Text			= lbl;
                    ((XDataTextBox) m_DataControl).Value		= field.GetValue();

                    break;
                case FieldType.Text_Multi:
                    m_DataControl = new XDataTextBox();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataTextBox) m_DataControl).Text			= lbl;
                    ((XDataTextBox) m_DataControl).Multiline	= true;
                    ((XDataTextBox) m_DataControl).Lines		= field.GetValues();

                    break;
                case FieldType.List_Single:
                    m_DataControl = new XDataListSingle();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataListSingle) m_DataControl).Text		= lbl;

                    foreach(Option o in field.GetOptions())
                    {
                        ((XDataListSingle) m_DataControl).AddValue(o.GetValue(), o.Label);
                    }
                    ((XDataListSingle) m_DataControl).Value		= field.GetValue();

                    break;
                case FieldType.List_Multi:
                    m_DataControl = new XDataListMulti();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataListMulti) m_DataControl).Text		= lbl;

                    foreach(Option o in field.GetOptions())
                    {
                        string optionValue = o.GetValue();
                        CheckState chk;
                        if (field.HasValue(optionValue))
                            chk = CheckState.Checked;
                        else
                            chk = CheckState.Unchecked;

                        ((XDataListMulti) m_DataControl).AddValue(optionValue, o.Label, chk);
                    }

                    break;
                case FieldType.Jid_Single:
                    m_DataControl = new XDataJidSingle();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataJidSingle) m_DataControl).Text	= lbl;
                    ((XDataJidSingle) m_DataControl).Value	= field.Value;
                    break;
                case FieldType.Jid_Multi:
                    m_DataControl = new XDataJidMulti();

                    lbl = field.Label;
                    if (lbl == null)
                        lbl = field.Var;

                    ((XDataJidMulti) m_DataControl).Text	= lbl;
                    ((XDataJidMulti) m_DataControl).Lines	= field.GetValues();

                    break;
                default:
                    m_DataControl = new XDataLabel();

                    break;
            }
            m_DataControl.IsRequired	= field.IsRequired;
            m_DataControl.m_Var			= field.Var;
            m_DataControl.Parent		= panelFields;
            m_DataControl.Location		= new Point(0, 0);
            m_DataControl.Width			= panelFields.Width;
            m_DataControl.Dock			= DockStyle.Top;

            if (m_Type != FieldType.Hidden &&
                m_Type != FieldType.Fixed)
            {
                m_DataControl.TabIndex	= tabIdx;
                m_DataControl.Focus();
            }

            panelFields.Controls.Add(m_DataControl);

            //			panelFields.ResumeLayout();
            lbl = null;
            return m_DataControl;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a form element from a given field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="tabIdx"></param>
        /// <returns></returns>
        private XDataFieldControl CreateField(Field field, int tabIdx)
        {
            XDataFieldControl m_DataControl;
//			panelFields.SuspendLayout();

            FieldType m_Type = field.Type;
            string    lbl;

            switch (m_Type)
            {
            case FieldType.Hidden:
                m_DataControl = new XDataHidden();
                ((XDataHidden)m_DataControl).Value = field.GetValue();

                break;

            case FieldType.Fixed:
                m_DataControl = new XDataLabel();

                ((XDataLabel)m_DataControl).Value = field.GetValue();

                break;

            case FieldType.Boolean:
                m_DataControl = new XDataCheckBox();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataCheckBox)m_DataControl).Text  = lbl;
                ((XDataCheckBox)m_DataControl).Value = field.GetValueBool();

                break;

            case FieldType.Text_Private:
                m_DataControl = new XDataTextBox();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataTextBox)m_DataControl).Text      = lbl;
                ((XDataTextBox)m_DataControl).Value     = field.GetValue();
                ((XDataTextBox)m_DataControl).IsPrivate = true;

                break;

            case FieldType.Text_Single:
                m_DataControl = new XDataTextBox();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataTextBox)m_DataControl).Text  = lbl;
                ((XDataTextBox)m_DataControl).Value = field.GetValue();

                break;

            case FieldType.Text_Multi:
                m_DataControl = new XDataTextBox();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataTextBox)m_DataControl).Text      = lbl;
                ((XDataTextBox)m_DataControl).Multiline = true;
                ((XDataTextBox)m_DataControl).Lines     = field.GetValues();

                break;

            case FieldType.List_Single:
                m_DataControl = new XDataListSingle();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataListSingle)m_DataControl).Text = lbl;

                foreach (Option o in field.GetOptions())
                {
                    ((XDataListSingle)m_DataControl).AddValue(o.GetValue(), o.Label);
                }
                ((XDataListSingle)m_DataControl).Value = field.GetValue();

                break;

            case FieldType.List_Multi:
                m_DataControl = new XDataListMulti();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataListMulti)m_DataControl).Text = lbl;

                foreach (Option o in field.GetOptions())
                {
                    string     optionValue = o.GetValue();
                    CheckState chk;
                    if (field.HasValue(optionValue))
                    {
                        chk = CheckState.Checked;
                    }
                    else
                    {
                        chk = CheckState.Unchecked;
                    }

                    ((XDataListMulti)m_DataControl).AddValue(optionValue, o.Label, chk);
                }

                break;

            case FieldType.Jid_Single:
                m_DataControl = new XDataJidSingle();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataJidSingle)m_DataControl).Text  = lbl;
                ((XDataJidSingle)m_DataControl).Value = field.Value;
                break;

            case FieldType.Jid_Multi:
                m_DataControl = new XDataJidMulti();

                lbl = field.Label;
                if (lbl == null)
                {
                    lbl = field.Var;
                }

                ((XDataJidMulti)m_DataControl).Text  = lbl;
                ((XDataJidMulti)m_DataControl).Lines = field.GetValues();

                break;

            default:
                m_DataControl = new XDataLabel();

                break;
            }
            m_DataControl.IsRequired = field.IsRequired;
            m_DataControl.m_Var      = field.Var;
            m_DataControl.Parent     = panelFields;
            m_DataControl.Location   = new Point(0, 0);
            m_DataControl.Width      = panelFields.Width;
            m_DataControl.Dock       = DockStyle.Top;

            if (m_Type != FieldType.Hidden &&
                m_Type != FieldType.Fixed)
            {
                m_DataControl.TabIndex = tabIdx;
                m_DataControl.Focus();
            }


            panelFields.Controls.Add(m_DataControl);

//			panelFields.ResumeLayout();
            lbl = null;
            return(m_DataControl);
        }