1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 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.ServicePort = txtServicePort.Text;
- config.Server = txtServer.Text;
- //config.UploadInterval = int.Parse(nudUploadInterval.Value.ToString());
- 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;
- }
- }
- }
|