zoukankan      html  css  js  c++  java
  • C# 证书打印《六》

    整理思路,从新出发。

    加载模版

     1 public void loadtemplate(Label lable)
     2         {
     3             string p_tempateFile = @"fomate.xml";
     4             OnePrintPoint opp = new OnePrintPoint();
     5             XmlDocument xmlDoc = new XmlDocument();
     6             xmlDoc.Load(p_tempateFile);
     7             XmlElement xmlNodePoints = xmlDoc["Lable"];
     8             XmlNodeList nodelist = xmlNodePoints.ChildNodes;
     9 
    10             foreach (XmlElement el in nodelist)//读元素值 
    11             {
    12                 try
    13                 {
    14                     string keystr = el.Attributes["Key"].InnerText;
    15                     if (keystr == lable.Name)
    16                     {
    17                         lable.Location = new Point(Convert.ToInt32(el.Attributes["X"].InnerText), Convert.ToInt32(el.Attributes["Y"].InnerText));
    18                         lable.Font = new Font(el.Attributes["FontName"].InnerText, float.Parse(el.Attributes["FontSize"].InnerText));
    19                     }
    20                 }
    21                 catch 
    22                 {
    23                     MessageBox.Show("xml文件读取错误,请和管理员联系", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
    24                 }
    25             }
    26         }
    加载模版

    在搞定鼠标对控件的控制后,下面接着就是读取数据,将数据和相应的控件对应起来。

     1 /// <summary>
     2         /// 设置打印值的属性
     3         /// </summary>
     4         /// <param name="key">xml文件中key的值</param>
     5         /// <param name="value">表格中取到的值</param>
     6         /// <returns></returns>
     7         public OnePrintPoint SetValue(string key, string value)
     8         {
     9             // string p_tempateFile = @"....infomate.xml";
    10             string p_tempateFile = @"fomate.xml";
    11             OnePrintPoint opp = new OnePrintPoint();
    12             XmlDocument xmlDoc = new XmlDocument();
    13             xmlDoc.Load(p_tempateFile);
    14             XmlElement xmlNodePoints = xmlDoc["Lable"];
    15             XmlNodeList nodelist = xmlNodePoints.ChildNodes;
    16 
    17             foreach (XmlElement el in nodelist)//读元素值 
    18             {
    19                 string keystr = el.Attributes["Key"].InnerText;
    20                 if (keystr == key)
    21                 {
    22                     //op.Key = el.Attributes["Key"].InnerText;
    23                     //设置打印值的属性
    24                     opp.FontName = el.Attributes["FontName"].InnerText;
    25                     opp.FontSize = float.Parse(el.Attributes["FontSize"].InnerText);
    26                     opp.X = float.Parse(el.Attributes["X"].InnerText);
    27                     opp.Y = float.Parse(el.Attributes["Y"].InnerText);
    28                     opp.Value = value;
    29                     break;
    30                 }
    31                 else
    32                 {
    33 
    34                 }
    35             }
    36             return opp;
    37         }
    赋值

       到此为止,关于打印的基本功能就这样实现了,如果有什么问题,欢迎大家和我交流,欢迎转载!

                                                    博客园bindot

  • 相关阅读:
    June 26th 2017 Week 26th Monday
    June 25th 2017 Week 26th Sunday
    June 24th 2017 Week 25th Saturday
    June 23rd 2017 Week 25th Friday
    June 22nd 2017 Week 25th Thursday
    2018最佳网页设计:就是要你灵感爆棚!!!
    图片素材类Web原型制作分享-Pexels
    想要打动HR的心,UX设计师求职信究竟应该怎么写?
    【UXPA大赛企业专访】Mockplus:“设计替代开发”将成为现实
    2018年最好的医疗网站设计及配色赏析
  • 原文地址:https://www.cnblogs.com/bindot/p/zsdy6.html
Copyright © 2011-2022 走看看