📄 ucconfig.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace PrintSystem
{
public partial class UCConfig : UserControl
{
public UCConfig()
{
InitializeComponent();
}
private void UCConfig_Load(object sender, EventArgs e)
{
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(Config.strXmlPath);
//姓名字段
System.Xml.XmlNode xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Name']");
if (xNode != null)
{
this .txbNameTop.Text = xNode.Attributes["Top"].Value;
this.txbNameLeft.Text = xNode.Attributes["Left"].Value;
}
//证号字段
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Code']");
if (xNode != null)
{
this.txbCodeTop.Text = xNode.Attributes["Top"].Value;
this.txbCodeLeft.Text = xNode.Attributes["Left"].Value;
}
//字体,大小
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Font']");
if (xNode != null)
{
this.cmbFont .SelectedItem = xNode.Attributes["Value"].Value;
this.cmbSize.SelectedItem = xNode.Attributes["Size"].Value;
}
//纸张
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Paper']");
if (xNode != null)
{
this.chxPaper .Checked = xNode.Attributes["Checked"].Value =="1" ? true :false;
this.txbPaperHeight.Text = xNode.Attributes["Height"].Value;
this.txbPaperWith.Text = xNode.Attributes["With"].Value;
}
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Order']");
if (xNode != null)
{
RadioButton[] tdb = { this.rdbTime, this.rdbTimeDesc, this.rdbCode, this.rdbCodeDesc };
int nChecked = Convert.ToInt32(xNode.Attributes["Checked"].Value);
tdb[nChecked].Checked = true;
}
xmlDoc = null;
}
private void btnSave_Click(object sender, EventArgs e)
{
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(Config.strXmlPath);
//姓名字段
System.Xml.XmlNode xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Name']");
if (xNode != null)
{
xNode.Attributes["Top"].Value = this.txbNameTop.Text .Trim ();
xNode.Attributes["Left"].Value = this.txbNameLeft.Text.Trim ();
}
//证号字段
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Code']");
if (xNode != null)
{
xNode.Attributes["Top"].Value = this.txbCodeTop.Text.Trim ();
xNode.Attributes["Left"].Value = this.txbCodeLeft.Text.Trim ();
}
//字体,大小
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Font']");
if (xNode != null)
{
xNode.Attributes["Value"].Value = this.cmbFont.SelectedItem.ToString ();
xNode.Attributes["Size"].Value = this.cmbSize.SelectedItem.ToString ();
}
//纸张
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Paper']");
if (xNode != null)
{
xNode.Attributes["Checked"].Value = this.chxPaper.Checked == true?"1":"0";
xNode.Attributes["Height"].Value = this.txbPaperHeight.Text;
xNode.Attributes["With"].Value = this.txbPaperWith.Text;
}
xNode = xmlDoc.DocumentElement.SelectSingleNode("Item[@Name='Order']");
if (xNode != null)
{
RadioButton[] tdb = { this.rdbTime, this.rdbTimeDesc, this.rdbCode, this.rdbCodeDesc };
for (int i = 0; i < tdb.Length; i++)
{
if (tdb[i].Checked == true)
{
xNode.Attributes["Checked"].Value = i.ToString();
break;
}
}
}
xmlDoc.Save(Config.strXmlPath);
xmlDoc = null;
this.Visible = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -