示例#1
0
 /// <summary>
 /// 根据模板名称加载模板控件列表
 /// </summary>
 /// <param name="editname">模板名称</param>
 private DataTable LoadCustomControlList(string editname)
 {
     if (editname != string.Empty)
     {
         XmlDocument document = EditTemplateInfo.GetEditXmlDocument(EditName.Substring(0, EditName.IndexOf(".")) + ".xml");//获取编辑模板XML
         XmlElement  parent   = document.DocumentElement;
         //模板中文说明|也就是模板所代表的纸面意思
         Lb_cname.Text = parent.ChildNodes[2].InnerText;
         //遍历所有的控件项节点|并添加到数据集中
         DataTable controltb = GetControlDB(EditName);
         foreach (XmlElement item in parent.ChildNodes[4])
         {
             DataRow controlrow = controltb.NewRow();
             controlrow["TAB_INDEX"]   = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("TAB_INDEX"));
             controlrow["ITEM_CNAME"]  = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_CNAME"));
             controlrow["ITEM_ENAME"]  = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_ENAME"));
             controlrow["ITEM_WIDTH"]  = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_WIDTH"));
             controlrow["ITEM_HEIGHT"] = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_HEIGHT"));
             controlrow["POS_X"]       = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("POS_X"));
             controlrow["POS_Y"]       = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("POS_Y"));
             controlrow["MULTILINE"]   = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("MULTILINE")) == "1" ? "是" : "否";
             controlrow["WORD_WRAP"]   = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("WORD_WRAP")) == "1" ? "是" : "否";
             controlrow["ITEM_TYPE"]   = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_TYPE"));
             controltb.Rows.Add(controlrow);
         }
         Lb_controlcount.Text             = controltb.Rows.Count.ToString();//控件总数
         DGV_CustomControlList.DataSource = controltb;
         return(controltb);
     }
     return(null);
 }
示例#2
0
 private void Bt_enter_Click(object sender, EventArgs e)
 {
     try
     {
         if (Tb_ename.Text.Length > 0 && Tb_cname.Text.Length > 0 && Tb_bmppath.Text.Length > 0)
         {
             //拷贝底图
             File.Copy(Tb_bmppath.Text, Application.StartupPath + "\\Themplate\\" + Tb_cname.Text + ".bmp");
             //建立DOM文档
             XmlDocument    document = new XmlDocument();
             XmlDeclaration decl     = document.CreateXmlDeclaration("1.0", "UTF-8", null);           //XML申明
             document.AppendChild(decl);
             XmlElement Custom_Root = document.CreateElement("Custom_Root");                          //根节点
             EditTemplateMethod.AppendChildElement(document, Custom_Root, "CODE", Tb_code.Text);      //模板代码
             EditTemplateMethod.AppendChildElement(document, Custom_Root, "BACK_IMG", Tb_ename.Text); //模板底图
             EditTemplateMethod.AppendChildElement(document, Custom_Root, "CNAME", Tb_code.Text);     //模板中文名称
             EditTemplateMethod.AppendChildElement(document, Custom_Root, "ENAME", Tb_ename.Text);    //模板英文名称
             EditTemplateMethod.AppendChildElement(document, Custom_Root, "ITEMS", "");               //模板控件列表|默认为空
             document.AppendChild(Custom_Root);
             document.Save(Application.StartupPath + "\\Themplate\\" + Tb_cname.Text + ".xml");       //保存模板
             MessageBox.Show("添加成功!", "信息提示");
         }
     }
     catch (Exception err) { MessageBox.Show("不能指定同名模板", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
 }
示例#3
0
 /// <summary>
 /// 保存模板中的全局节点
 /// </summary>
 /// <param name="document">XmlDocument</param>
 /// <param name="root">根节点</param>
 private void SaveGlobalXmlNode(XmlDocument document, XmlElement root)
 {
     //模板代码
     EditTemplateMethod.AppendChildElement(document, root, "CODE", EditTemplateInfo.GetEditXmlDocument((EditName.Substring(0, EditName.IndexOf(".")) + ".xml")).DocumentElement.ChildNodes[0].InnerText);
     //模板底图
     EditTemplateMethod.AppendChildElement(document, root, "BACK_IMG", EditTemplateInfo.GetEditXmlDocument((EditName.Substring(0, EditName.IndexOf(".")) + ".xml")).DocumentElement.ChildNodes[1].InnerText);
     //模板中文名称
     EditTemplateMethod.AppendChildElement(document, root, "CNAME", EditTemplateInfo.GetEditXmlDocument((EditName.Substring(0, EditName.IndexOf(".")) + ".xml")).DocumentElement.ChildNodes[2].InnerText);
     //模板英文名称
     EditTemplateMethod.AppendChildElement(document, root, "ENAME", EditTemplateInfo.GetEditXmlDocument((EditName.Substring(0, EditName.IndexOf(".")) + ".xml")).DocumentElement.ChildNodes[3].InnerText);
 }
示例#4
0
 /// <summary>
 /// 保存模板中的项节点
 /// </summary>
 /// <param name="document">XmlDocument</param>
 /// <param name="root">根节点</param>
 private void SaveItemXmlNode(XmlDocument document, XmlElement root)
 {
     try
     {
         XmlElement items = EditTemplateMethod.AppendChildElement(document, root, "ITEMS", null);
         foreach (DataGridViewRow row in DGV_CustomControlList.Rows)
         {
             XmlElement item = EditTemplateMethod.AppendChildElement(document, items, "ITEM", null);
             //TAB索引,如果索引在转换成数值时没有错误说明是正确的|否则错误
             Convert.ToInt32(row.Cells["tbindex"].Value.ToString());
             EditTemplateMethod.AppendChildElement(document, item, "TAB_INDEX", row.Cells["tbindex"].Value.ToString());
             //节点中文名称
             EditTemplateMethod.AppendChildElement(document, item, "ITEM_CNAME", row.Cells["cname"].Value.ToString());
             //节点英文名称
             EditTemplateMethod.AppendChildElement(document, item, "ITEM_ENAME", row.Cells["ename"].Value.ToString());
             //控件的宽度
             Convert.ToInt32(row.Cells["width"].Value.ToString());
             EditTemplateMethod.AppendChildElement(document, item, "ITEM_WIDTH", row.Cells["width"].Value.ToString());
             //控件的高度
             Convert.ToInt32(row.Cells["height"].Value.ToString());
             EditTemplateMethod.AppendChildElement(document, item, "ITEM_HEIGHT", row.Cells["height"].Value.ToString());
             //X坐标
             Convert.ToInt32(row.Cells["pointx"].Value.ToString());
             EditTemplateMethod.AppendChildElement(document, item, "POS_X", row.Cells["pointx"].Value.ToString());
             //Y坐标
             Convert.ToInt32(row.Cells["pointy"].Value.ToString());
             EditTemplateMethod.AppendChildElement(document, item, "POS_Y", row.Cells["pointy"].Value.ToString());
             //是否多行文本
             int muiline = row.Cells["ismuiline"].Value.ToString() == "是" ? 1 : 0;
             EditTemplateMethod.AppendChildElement(document, item, "MULTILINE", muiline.ToString());
             //是否换行
             int warp = row.Cells["iswarp"].Value.ToString() == "是" ? 1 : 0;
             EditTemplateMethod.AppendChildElement(document, item, "WORD_WRAP", warp.ToString());
             //控件类型
             EditTemplateMethod.AppendChildElement(document, item, "ITEM_TYPE", row.Cells["controltype"].Value.ToString());
         }
     }
     catch { MessageBox.Show("属性列表中有错误的数值", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
示例#5
0
 /// <summary>
 /// TextBox输入验证|只能输入数字
 /// </summary>
 void CustomControlNumber_KeyPress(object sender, KeyPressEventArgs e)
 {
     EditTemplateMethod.KeyPressFloat(sender, e);
 }
示例#6
0
 /// <summary>
 /// TextBox输入验证|只能输入普通字符
 /// </summary>
 void CustomControl_KeyPress(object sender, KeyPressEventArgs e)
 {
     EditTemplateMethod.KeyPressStandardInput(sender, e);
 }
示例#7
0
        /// <summary>
        /// 生成模板
        /// </summary>
        /// <param name="editdoc">XML模板</param>
        private void InitCustomConfig(XmlDocument editdoc)
        {
            //模板底图
            Image img = EditTemplateInfo.GetEditImg(Editname);

            P_bgimg.Size            = new Size(img.Width, img.Height);
            P_bgimg.BackgroundImage = img;
            //模板中的控件
            P_bgimg.Controls.Clear();//清空模板控件
            //项模板
            foreach (XmlNode item in editdoc.DocumentElement.ChildNodes[4])
            {
                //属性项目|TabIndex索引
                int tabindex = Convert.ToInt32(EditTemplateMethod.GetXmlNodeTextInt(item.SelectSingleNode("TAB_INDEX"), "0"));
                //中文名
                string cname = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_CNAME"));
                //英文名
                string ename = EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_ENAME"));
                //控件大小
                Size size = new Size(Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_WIDTH"))), Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_HEIGHT"))));
                //停靠在模板中的位置
                Point location = new Point(Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("POS_X"))), Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("POS_Y"))));
                //是否多行文本
                EditControlIsOrMultiline multiline = EditControlIsOrMultiline.FalseMultiline;
                if ((Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("MULTILINE"))) == 1))
                {
                    multiline = EditControlIsOrMultiline.TrueMultiline;
                }
                //是否自动换行
                EditControlIsOrWrap wrap = EditControlIsOrWrap.FalseWrap;
                if ((Convert.ToInt32(EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("WORD_WRAP"))) == 1))
                {
                    wrap = EditControlIsOrWrap.TrueWrap;
                }
                //默认控件类型为TextBoxText
                EditControlTypeInfo edittype = EditControlTypeInfo.TextBoxText;
                switch (EditTemplateMethod.GetXmlNodeText(item.SelectSingleNode("ITEM_TYPE")))
                {
                case "RichTextBox": edittype = EditControlTypeInfo.RichTextBox;
                    break;

                case "TextBoxText": edittype = EditControlTypeInfo.TextBoxText;
                    break;

                case "TextBoxNumber": edittype = EditControlTypeInfo.TextBoxNumber;
                    break;

                case "DateTimePicker": edittype = EditControlTypeInfo.DateTimePicker;
                    break;

                case "PictureBox": edittype = EditControlTypeInfo.PictureBox;
                    break;

                case "CheckBox": edittype = EditControlTypeInfo.CheckBox;
                    break;

                case "TextBoxLong": edittype = EditControlTypeInfo.TextBoxLong;
                    break;
                }
                CreateCustomControl(tabindex, cname, ename, size, location, multiline, wrap, edittype, BorderStyle.FixedSingle, true, ScrollBars.Both, RichTextBoxScrollBars.Both);
            }
        }