Пример #1
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); }
 }
Пример #2
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);
 }
Пример #3
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); }
 }