添加项目文件。
This commit is contained in:
105
C-Windows-1/Config.cs
Normal file
105
C-Windows-1/Config.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace C_Windows_1
|
||||
{
|
||||
public partial class Config : Form
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Config_Load(object sender, EventArgs e)
|
||||
{
|
||||
Read();
|
||||
}
|
||||
|
||||
private void Use_Set_Click(object sender, EventArgs e)
|
||||
{
|
||||
Set();
|
||||
Form1.f1.Station.Text = Station.Text;
|
||||
// Form1.f1.Code_Head.Text = Code_Head.Text;
|
||||
Form1.f1.codecheck.Text = CodeLength.Text;
|
||||
Form1.f1.CodeLength.Text = CodeLength.Text;
|
||||
|
||||
Form1.f1.checkBox1.Checked= codelengthcheck.Checked;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
//写入端口参数
|
||||
private void Set()
|
||||
{
|
||||
|
||||
RegistryKey regName;
|
||||
|
||||
regName = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set", true);
|
||||
|
||||
if (regName is null)
|
||||
{
|
||||
regName = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set");
|
||||
}
|
||||
|
||||
regName.SetValue("station", Station.Text);
|
||||
// regName.SetValue("codehead", Code_Head.Text);
|
||||
regName.SetValue("codelength", CodeLength.Text);
|
||||
regName.SetValue("codelengthcheck", codelengthcheck.Checked);
|
||||
|
||||
|
||||
|
||||
|
||||
regName.Close();
|
||||
}
|
||||
|
||||
|
||||
//读出站号、条码长度、通道数等参数
|
||||
private void Read()
|
||||
{
|
||||
|
||||
RegistryKey regName;
|
||||
|
||||
regName = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set", true);
|
||||
|
||||
if (regName is null)
|
||||
{
|
||||
regName = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set");
|
||||
}
|
||||
|
||||
regName.OpenSubKey("User");
|
||||
if (regName.GetValue("station") is null)
|
||||
{
|
||||
Station.Text = "01";
|
||||
}
|
||||
else
|
||||
{
|
||||
Station.Text = regName.GetValue("station").ToString();
|
||||
|
||||
}
|
||||
|
||||
if (regName.GetValue("codelength") is null)
|
||||
{
|
||||
CodeLength.Text = "13";
|
||||
}
|
||||
else
|
||||
{
|
||||
CodeLength.Text = regName.GetValue("codelength").ToString();
|
||||
|
||||
}
|
||||
if (regName.GetValue("codelengthcheck") is null)
|
||||
{
|
||||
codelengthcheck.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
codelengthcheck.Checked = Convert.ToBoolean(regName.GetValue("codelengthcheck").ToString());
|
||||
|
||||
}
|
||||
|
||||
regName.Close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user