Пример #1
0
        //加载配置的列信息
        private void loadCfgColumn(string xmlConfigFile)
        {
            if (xmlConfigFile == null)
            {
                return;
            }
            XmlDocument xmlDoc = new XmlDocument();

            try {
                xmlDoc.Load(xmlConfigFile);
            }
            catch (Exception ex) {
                MessageBox.Show(string.Format("加载XML 文件{0} 出错。", xmlConfigFile) + ex.Message, "操作提示");
                return;
            }
            if (xmlDoc == null)
            {
                return;
            }
            XmlNodeList nodeList = xmlDoc.SelectNodes(COLUMN_CONFIG_NODE);

            if (nodeList == null || nodeList.Count == 0)
            {
                return;
            }
            if (_ColumnXmlCfgs == null)
            {
                _ColumnXmlCfgs = new Dictionary <string, DesignColumnXmlCfgInfo>();
            }
            else
            {
                _ColumnXmlCfgs.Clear();
            }

            foreach (XmlNode node in nodeList)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                string name = node.Attributes["Name"].Value;
                string desc = name;

                if (node.Attributes["Description"] != null)
                {
                    desc = node.Attributes["Description"].Value;
                }

                DesignColumnXmlCfgInfo cfgInfo = new DesignColumnXmlCfgInfo(name, desc);

                _ColumnXmlCfgs.Add(name, cfgInfo);
            }
        }
Пример #2
0
        public void SetAdvanceDataBinding(Control ctl, DesignColumnXmlCfgInfo column)
        {
            if (column == null)
            {
                return;
            }

            if (_DataBindings.ContainsKey(ctl))
            {
                _DataBindings[ctl] = column;
            }
            else
            {
                _DataBindings.Add(ctl, column);
            }
            string ctlName = ctl.GetType().Name;

            if (Array.IndexOf <string>(INCLUDE_TAG_TEXT_CTLS, ctlName) >= 0)
            {
                ctl.Text  = "@" + column.ColumnDescription;
                ctl.Width = ctl.Width < DEFAULT_EDIT_CTL_WIDTH ? DEFAULT_EDIT_CTL_WIDTH : ctl.Width;
            }
            else if (ctl is Label)
            {
                ctl.Text   = column.ColumnDescription + ":";
                ctl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                (ctl as Label).TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

                //ctl.ForeColor = column.Nullable?System.Drawing.Color.Black : System.Drawing.Color.Red;

                //if (column.IsKey)
                //    ctl.Font = new System.Drawing.Font(ctl.Font, System.Drawing.FontStyle.Bold);
            }
            else if (ctl is CheckBox)
            {
                ctl.Text = column.ColumnDescription;
            }
            else if (ctl is DateTimePicker)
            {
                ctl.Width = DEFAULT_EDIT_CTL_WIDTH;
            }
            else
            {
            }
        }