123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using S7.Net;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace xicheji
- {
- public partial class SettingForm : Form
- {
- public SettingForm()
- {
- InitializeComponent();
- }
- private void SettingForm_Load(object sender, EventArgs e)
- {
- try
- {
- var names = Enum.GetNames<CpuType>();
- cboPLCType.Items.Clear();
- cboPLCType.Items.AddRange(names);
- var config = ConfigHelper.GetConfig();
- txtServer.Text = config.Server;
- txtPLCIP.Text = config.PLCIP;
- txtPLCPort.Text = config.PLCPort;
- cboPLCType.SelectedItem = Enum.GetName<CpuType>(config.PLCType);
- nudInterval.Value = config.PLCReceiveInterval;
- txtCameraIP.Text = config.CameraIP;
- txtCameraPort.Text = config.CameraPort;
- txtUserName.Text = config.CameraUserName;
- txtPassword.Text = config.CameraPassword;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message + ex.StackTrace);
- }
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- var config = ConfigHelper.GetConfig();
- config.Server = txtServer.Text;
- config.PLCIP = txtPLCIP.Text;
- config.PLCPort = txtPLCPort.Text;
- config.PLCType = Enum.Parse<CpuType>(cboPLCType.Text);
- config.PLCReceiveInterval = int.Parse(nudInterval.Value.ToString());
- config.CameraIP = txtCameraIP.Text;
- config.CameraPort = txtCameraPort.Text;
- config.CameraUserName = txtUserName.Text;
- config.CameraPassword = txtPassword.Text;
- ConfigHelper.SaveConfig(config);
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message + ex.StackTrace);
- }
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
|