数据存储,读取控件在Panel中的位置,将控件的位置保存到xml文件中。

/// <summary>
/// 将当前格式写入xml
/// </summary>
/// <param name="font"></param>
private void xmlWrite(Font font)
{
try
{
//H:\Users\bindot\Documents\Visual Studio 2010\Projects\Print\Print\Resources
string path = Application.StartupPath + @"fomate.xml";
XmlDocument doc = new XmlDocument(); // 创建dom对象
XmlElement root = doc.CreateElement("Lable");// 创建根节点Page
doc.AppendChild(root); // 加入到xml document
foreach (Control c in panel1.Controls)
{
XmlElement rfont = doc.CreateElement("font");
rfont.SetAttribute("Key", c.Name.ToString());
rfont.SetAttribute("X", c.Location.X.ToString());
rfont.SetAttribute("Y", c.Location.Y.ToString());
rfont.SetAttribute("FontSize", font.Size.ToString());
rfont.SetAttribute("FontName", font.Name);
root.AppendChild(rfont);
}
doc.Save(AppDomain.CurrentDomain.BaseDirectory + @"fomate.xml");
MessageBox.Show("默认格式保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

写入到xml

这个地方貌似还不是很严谨,对于文件不存在的情况没有进行判断,您可参考以下代码

FileInfo newFile = new FileInfo(filename);
if (newFile.Exists)
{
newFile.Delete();
newFile = new FileInfo(filename);
}

判断文件是否存在

调整某个控件的大小与位置

  private void ChangeOne(FontDialog f, string lblname)
{
try
{
//H:\Users\bindot\Documents\Visual Studio 2010\Projects\Print\Print\Resources
string path = Application.StartupPath + @"/fomate.xml";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(path);
XmlNodeList topM = xmldoc.DocumentElement.ChildNodes;
foreach (XmlElement el in topM)
{
if (el.Name.ToLower() == "font" && el.Attributes["Key"].Value == lblname)
{
el.Attributes["FontName"].Value = f.Font.FontFamily.Name.ToString();
el.Attributes["FontSize"].Value = f.Font.Size.ToString();
xmldoc.Save(AppDomain.CurrentDomain.BaseDirectory + @"fomate.xml");
MessageBox.Show("默认格式保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
initFomate();
}
} }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

ChangeOne

C# 毕业证书打印《四》的更多相关文章

  1. C# 毕业证书打印《一》

    最近一直在做证书打印的项目,好久都没写日志了.今天将代码整理了一下,希望将自己做证书打印的一些心得写出来,也希望能和大家一起交流. 首先,证书打印必须实现打印的功能.了解打印功能是怎么实现的,打印关键 ...

  2. C# 毕业证书打印《六》

    整理思路,从新出发. 加载模版 public void loadtemplate(Label lable) { string p_tempateFile = @"fomate.xml&quo ...

  3. C# 毕业证书打印《三》

    打印很关键的方法,打印方法DataPrint(),将你要打印的数据信息发送到打印机就可以了,打印机将自动处理. public void DataPrint() { try { PrintDocumen ...

  4. C# 毕业证书打印《二》

    当证书的打印功能得以实现,最关键的功能便是数据. 通过对打印的了解,打印中最关键的功能便是打印事件中的方法. private void pd_PrintPage(object sender, Prin ...

  5. C# 毕业证书打印《五》

    对鼠标操作Label的方法 #region //定义一个枚举类型,描述光标状态 private enum EnumMousePointPosition { #region MouseSizeNone ...

  6. 【爆料】-《布莱顿大学毕业证书》Brighton一模一样原件

    布莱顿大学毕业证[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归&am ...

  7. 毕业样本=[威尔士大学毕业证书]UWIC原件一模一样证书

    威尔士大学毕业证[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归&am ...

  8. 毕业样本=[华威大学毕业证书]Warwick原件一模一样证书

    华威大学毕业证[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归& ...

  9. 毕业原版=[约克大学毕业证书]York原件一模一样证书

    约克大学毕业证[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归& ...

随机推荐

  1. aufomaper Queryable Extensions ProjectTo

    When using an ORM such as NHibernate or Entity Framework with AutoMapper's standard Mapper.Map funct ...

  2. [Unity] Unity3D研究院编辑器之独立Inspector属性

    本文转自: http://www.xuanyusong.com/archives/3680雨松MOMO Unity提供了强大的Editor功能, 我们可以很轻易的在EditorGUI中绘制任意的属性. ...

  3. centos 7.0 查看根目录下所有文件夹

    centos 7.0最小化安装 第一行是登录 [root@localhost ~]# [root@localhost ~]# cd ../ [root@localhost /]# ls bin dev ...

  4. yii2 widget示例

    <?php namespace app\components; use yii\base\Widget; use yii\helpers\Html; class RctReplyWidget e ...

  5. 单选框的回显c:if

    <input type="radio" name="sex" value="boy" <c:if test="${te ...

  6. C#实现Excel模板导出和从Excel导入数据

    午休时间写了一个Demo关于Excel导入导出的简单练习 1.窗体 2.引用office命名空间 添加引用-程序集-扩展-Microsoft.Office.Interop.Excel 3.封装的Exc ...

  7. 史上最全的maven pom.xml文件教程详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. oracle 特殊符号

    http://hi.baidu.com/wind_stay/blog/item/85113a6f6553a5d680cb4a0e.html oracle通配符,运算符的使用 用于where比较条件的有 ...

  9. Eclipse常用开发插件

    以下是我整理的自己开发过程中的常用Eclipse插件,按字母排序: (1)    AmaterasUML         介绍:Eclipse的UML插件,支持UML活动图,class图,sequen ...

  10. 如何运行python

    如何运行Python程序 不少新手朋友遇到的第一个问题,不是Python的数据结构,不是Python的类库使用,更不是第三方模块.框架的应用,而是简单的“如何运行”!Python可用以下三种方式运行, ...