Example #1
0
        public SField(string name, string label, int index, SInputType inputType, object data)
        {
            Name       = name;
            Label      = label;
            _InputType = inputType;
            Label      = label;
            Name       = name;
            _Index     = index;

            switch (_InputType)
            {
            case SInputType.String:
            {
                _InputCtrl = new TextBox();
                break;
            }

            case SInputType.Decimal:
            {
                _InputCtrl = new TextBox();
                break;
            }

            case SInputType.Combo:
            {
                _InputCtrl = new ComboBox();
                break;
            }

            case SInputType.Date:
            {
                _InputCtrl = new SCtrls.SDateTimePicker();
                break;
            }

            case SInputType.Image:
            {
                _InputCtrl = new PictureBox();
                break;
            }
            }
        }
Example #2
0
        private void InitSFieldDic()
        {
            // 获取输入枚举列表
            List <string> enumNameList = new List <string>(typeof(SInputType).GetEnumNames());

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "FormCfg.xml");
            XmlNode node = xmlDoc.SelectSingleNode(string.Format("/Forms/{0}/SFields", _FormName));

            foreach (XmlNode subNode in node.ChildNodes)
            {
                string     name         = subNode.Attributes["Name"].Value;
                bool       hasLabel     = subNode.Attributes["HasLabel"].Value == "true";
                string     strInputType = subNode.Attributes["InputType"].Value;
                object     data         = subNode.Attributes["Data"].Value;
                int        indexEnum    = enumNameList.IndexOf(strInputType);
                SInputType inputType    = (SInputType)indexEnum;

                int startRowIndex = int.Parse(subNode.Attributes["StartRowIndex"].Value);
                int startColIndex = int.Parse(subNode.Attributes["StartColIndex"].Value);
                int rowSpan       = int.Parse(subNode.Attributes["RowSpan"].Value);
                int colSpan       = int.Parse(subNode.Attributes["ColSpan"].Value);

                SField sField = new SField(_FormInfo, name, _SFieldDic.Count, hasLabel, inputType, data);
                sField.StartRowIndex = startRowIndex;
                sField.StartColIndex = startColIndex;
                sField.RowSpan       = rowSpan;
                sField.ColSpan       = colSpan;
                if (hasLabel)
                {
                    sField.Label = subNode.Attributes["Label"].Value;
                }
                _SFieldDic.Add(name, sField);
            }
        }
Example #3
0
        public SField(FormCfgInfo formCfgInfo, string name, int index, bool hasLabel, SInputType inputType, object data)
        {
            _FormCfgInfo = formCfgInfo;
            Name         = name;
            _HasLabel    = hasLabel;
            if (_HasLabel)
            {
                _LabelCtrl           = new Label();
                _LabelCtrl.AutoSize  = false;
                _LabelCtrl.TextAlign = ContentAlignment.MiddleLeft;
            }
            _InputType = inputType;
            Name       = name;
            _Index     = index;

            switch (_InputType)
            {
            case SInputType.String:
            {
                TextBox textBox = new TextBox();
                textBox.Text = data as string;
                _InputCtrl   = textBox;
                break;
            }

            case SInputType.MultiLine:
            {
                TextBox textBox = new TextBox();
                textBox.Text      = data as string;
                textBox.Multiline = true;
                _InputCtrl        = textBox;
                break;
            }

            case SInputType.Decimal:
            {
                TextBox textBox = new TextBox();
                textBox.Text = data as string;
                _InputCtrl   = textBox;
                break;
            }

            case SInputType.Combo:
            {
                ComboBox comboBox = new ComboBox();
                comboBox.DataSource = data;
                _InputCtrl          = comboBox;
                break;
            }

            case SInputType.Date:
            {
                ForKids.UI.SCtrls.SDateTimePicker sDateTimePicker = new ForKids.UI.SCtrls.SDateTimePicker();
                sDateTimePicker.Text = (data == null ? DateTime.Now.ToString() : data as string);
                _InputCtrl           = sDateTimePicker;
                break;
            }

            case SInputType.Image:
            {
                PictureBox picBox = new PictureBox();
                picBox.SizeMode = PictureBoxSizeMode.StretchImage;
                picBox.Image    = data as Image;
                _InputCtrl      = picBox;
                break;
            }
            }
            if (_InputType != SInputType.Image)
            {
                _InputCtrl.AutoSize = false;
            }
        }
Example #4
0
        public SField(FormCfgInfo formCfgInfo, string name, int index, bool hasLabel, SInputType inputType, object data)
        {
            _FormCfgInfo = formCfgInfo;
            Name         = name;
            _HasLabel    = hasLabel;
            if (_HasLabel)
            {
                _LabelCtrl           = new Label();
                _LabelCtrl.AutoSize  = false;
                _LabelCtrl.TextAlign = ContentAlignment.MiddleLeft;
            }
            _InputType = inputType;
            Name       = name;
            _Index     = index;

            switch (_InputType)
            {
            case SInputType.String:
            case SInputType.Decimal:
            case SInputType.Int:
            case SInputType.Double:
            {
                TextBox textBox = new TextBox();
                textBox.Text = data as string;
                _InputCtrl   = textBox;
                break;
            }

            case SInputType.MultiLine:
            {
                TextBox textBox = new TextBox();
                textBox.Text      = data as string;
                textBox.Multiline = true;
                _InputCtrl        = textBox;
                break;
            }

            case SInputType.Boolean:
            case SInputType.Combo:
            {
                ComboBox comboBox = new ComboBox();
                comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                if (data != null)
                {
                    string[] items = data.ToString().Split(';');
                    foreach (string item in items)
                    {
                        comboBox.Items.Add(item);
                    }
                }
                _InputCtrl = comboBox;
                break;
            }

            case SInputType.Date:
            {
                ForKids.UI.SCtrls.SDateTimePicker sDateTimePicker = new ForKids.UI.SCtrls.SDateTimePicker();
                sDateTimePicker.Text = (data == null ? DateTime.Now.ToString() : data as string);
                _InputCtrl           = sDateTimePicker;
                break;
            }

            case SInputType.Image:
            {
                PictureBox picBox = new PictureBox();
                picBox.SizeMode          = PictureBoxSizeMode.Zoom;
                picBox.BackColor         = Color.FromKnownColor(KnownColor.AppWorkspace);
                picBox.Image             = data as Image;
                _InputCtrl               = picBox;
                picBox.MouseDoubleClick += new MouseEventHandler(picBox_MouseDoubleClick);
                break;
            }
            }
            if (_InputType != SInputType.Image)
            {
                _InputCtrl.AutoSize = false;
            }
        }