| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.StlMes.Client.LgResMgt.Mcms.entity;
- using CoreFS.CA06;
- namespace Core.StlMes.Client.LgResMgt.Mcms
- {
- public partial class CommunicationDetailSetting : FrmBase
- {
- public CommunicationDetailSetting(iCommunication data)
- {
- InitializeComponent();
- if (data != null)
- {
- if (data is SerialPortEntity)
- {
- rbt1.Checked = true;
- cmbCom.Text = ((SerialPortEntity) data).PortName;
- baudRate.Text = ((SerialPortEntity)data).StrBaudRate;
- }
- else if (data is SocketClient)
- {
- rbt2.Checked = true;
- txtIp.Text = ((SocketClient)data).Ip;
- txtPort.Text = ((SocketClient)data).Port;
- }
- }
- }
- private iCommunication _entity;
- public iCommunication Entity
- {
- get { return _entity; }
- }
- private void utmMain_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Save": // ButtonTool
- // Place code here
- if (rbt1.Checked)
- {
- if (cmbCom.SelectedIndex < 0)
- {
- MessageBox.Show("清选择串口号!");
- return;
- }
- if (baudRate.SelectedIndex < 0)
- {
- MessageBox.Show("清选择波特率!");
- return;
- }
- SerialPortEntity tempSerialPortEntity = new SerialPortEntity
- {
- PortName = cmbCom.Text,
- StrBaudRate = baudRate.Text,
- StrDataBits = "8",
- StrParity = "NONE",
- StrStopBits = "ONE"
- };
- _entity = tempSerialPortEntity;
- }
- else if (rbt2.Checked)
- {
- if (string.IsNullOrWhiteSpace(txtIp.Text))
- {
- MessageBox.Show("请输入远程服务的IP地址!");
- return;
- }
- else if (string.IsNullOrWhiteSpace(txtPort.Text))
- {
- MessageBox.Show("请输入远程服务的端口!");
- return;
- }
- SocketClient tempSocketClient = new SocketClient
- {
- Ip = txtIp.Text,
- Port = txtPort.Text
- };
- _entity = tempSocketClient;
- }
- else
- {
- MessageBox.Show("清选择通信类型!");
- return;
- }
- this.DialogResult = DialogResult.OK;
- break;
- case "Close": // ButtonTool
- this.DialogResult = DialogResult.Cancel;
-
- break;
- }
- }
- private void rbt1_CheckedChanged(object sender, EventArgs e)
- {
- panel4.Visible = rbt1.Checked;
- panel5.Visible = rbt2.Checked;
- }
- }
- }
|