Ejemplo n.º 1
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;
        }
Ejemplo 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);
        }