Esempio n. 1
0
        /// <summary>
        /// 为指定源绑定指定事件
        /// </summary>
        /// <param name="ctrl"></param>
        /// <param name="handler"></param>
        private static void BindEventHandler(BaseCtrl ctrl)
        {
            //TODO:区分不同的控件类型绑定
            //BaseCtrl ctrlClass = UtilClass.GetControlFromXml(XmlPath, ctrl);

            if (ctrl == null || ctrl._FrmControl == null)
            {
                if (IsCommentShow)
                {
                    MessageBox.Show("没有找到名为" + ctrl._Name + "的控件信息!");
                }

                return;
            }

            //控件类型
            string ctrlType = ctrl._ControlType.ToLower().Trim();
            if (ctrlType == "textbox" || ctrlType == "datagridview")
            {
                Control frmCtrl = ctrl._FrmControl;
                ControlClass ctrlClass = ctrl as ControlClass;

                switch (ctrlType)
                {
                    case "textbox":
                        AttrTextBox attr = ctrlClass._Attr as AttrTextBox;
                        CheckType type = (CheckType)Enum.Parse(typeof(CheckType), attr.Attr.DataType);
                        EventType etype = (EventType)Enum.Parse(typeof(EventType), ctrlClass._EventType);
                        BindDataType(frmCtrl, type, etype);
                        break;
                    case "datagridview":
                        //对DataGridView需区分(是对整体,还是对每列的数据验证)

                        DataGridView grid = frmCtrl as DataGridView;

                        //是否具有列数据限制
                        bool flag = false;

                        //存储DataGridView各列数据信息
                        flag = DataModels.Store(ctrlClass);

                        if (flag)
                        {
                            grid.EditingControlShowing -= new DataGridViewEditingControlShowingEventHandler(DataCheck.DataGridView_EditControlShowing);
                            grid.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(DataCheck.DataGridView_EditControlShowing);
                        }

                        AttrDataGridView a = ctrlClass._Attr as AttrDataGridView;
                        ////如果含有一致性检测信息
                        //var querylist = from p in a.Attr
                        //                where p.Index == -1 || p.DataType.Equals("CONSISTENCY")
                        //                select p;
                        //if (querylist != null && querylist.Count() > 0)
                        //{
                        //    BindDataType(frmCtrl, CheckType.CONSISTENCY);
                        //}

                        break;
                    default:

                        break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 判断控件节点是否存在
        /// </summary>
        /// <param name="_xmlpath">Xml路径</param>
        /// <param name="ctrl">控件</param>
        /// <returns></returns>
        private static bool IsNodeExist(string _xmlpath, BaseCtrl ctrl)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("//parameters");
            builder.Append("//" + ctrl._NameSpace);
            builder.Append("//" + ctrl._Class);
            builder.Append("//" + ctrl._Name);

            return xmlHelper.IsNodeExist(_xmlpath, builder.ToString());
        }