Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 重载构造函数|实现鹰眼的地图效果
        /// </summary>
        /// <param name="name">当前面板的底图名称</param>
        public FrmEagleLook(string name)
        {
            InitializeComponent();
            Image  imgzoom   = EditTemplateInfo.GetEditImg(name);
            int    imgwidth  = imgzoom.Width / 4;
            int    imgheight = imgzoom.Height / 4;
            Bitmap bmp       = new Bitmap(imgzoom, imgwidth, imgheight);

            PB_img.Width  = imgwidth;
            PB_img.Height = imgheight;
            PB_img.Image  = bmp;
        }
Ejemplo n.º 4
0
 private void FrmEditInfoBox_Load(object sender, EventArgs e)
 {
     try
     {
         string filepath = EditTemplateInfo.GetEditXmlPathName((EditPath.Substring(0, EditPath.IndexOf(".")) + ".xml"));
         Lb_editname.Text       = EditTemplateInfo.GetEditXmlDocument((EditPath.Substring(0, EditPath.IndexOf(".")) + ".xml")).DocumentElement.ChildNodes[2].InnerText;
         Lb_createtime.Text     = File.GetCreationTime(filepath).ToString();
         Lb_lastwritetime.Text  = File.GetLastAccessTime(filepath).ToString();
         Lb_lastaccesstime.Text = File.GetLastWriteTime(filepath).ToString();
     }
     catch { }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 初始化模板列表
 /// </summary>
 private void FrmEditLeftList_Load(object sender, EventArgs e)
 {
     //获取模板名称集合
     foreach (object i in EditTemplateInfo.ReturnEditItemName())
     {
         //实例化模板集合中的子列表对象
         CustomEditList editlistchild = new CustomEditList(EditTemplateInfo.GetEditImg((i as string)));
         editlistchild.Tag  = (i as string);//存储当前子对象所对应的模板名称
         editlistchild.Dock = DockStyle.Top;
         P_editlist.Controls.Add(editlistchild);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 窗体加载时|加载一些模板信息列表
 /// </summary>
 private void FrmPanel_Load(object sender, EventArgs e)
 {
     //设置选择模板下拉列表项
     for (int i = 0; i < EditTemplateInfo.ReturnEditItemName().Count; i++)
     {
         EditItem.Items.Add(EditTemplateInfo.ReturnEditItemName()[i].ToString());
     }
     EditItem.SelectedIndex = 0;
     //设置控件列表面板
     Controllist_Click(null, null);
     DockLeft();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 窗体加载时
 /// </summary>
 private void FrmEditfrom_Load(object sender, EventArgs e)
 {
     try
     {
         //模板的英文名称
         EditEname = EditTemplateInfo.GetEditXmlDocument(Editname.Substring(0, Editname.IndexOf(".")) + ".xml").DocumentElement.ChildNodes[3].InnerText;
         //生成模板
         InitCustomConfig(EditTemplateInfo.GetEditXmlDocument(Editname.Substring(0, Editname.IndexOf(".")) + ".xml"));
         //填充模板
         FillCustomControl();
     }
     catch { }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 保存模板属性
 /// </summary>
 private void SaveEditProperty()
 {
     try
     {
         XmlDocument    document = new XmlDocument();
         XmlDeclaration decl     = document.CreateXmlDeclaration("1.0", "UTF-8", null); //XML申明
         document.AppendChild(decl);
         XmlElement Custom_Root = document.CreateElement("Custom_Root");                //根节点
         //保存全局节点信息
         SaveGlobalXmlNode(document, Custom_Root);
         //保存项节点信息
         SaveItemXmlNode(document, Custom_Root);
         document.AppendChild(Custom_Root);
         document.Save(EditTemplateInfo.GetEditXmlPathName(EditName.Substring(0, EditName.IndexOf(".")) + ".xml"));
     }
     catch (Exception err) { }
 }
Ejemplo n.º 9
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);
            }
        }