private void btnSetting_Click(object sender, EventArgs e)
        {
            if (cbOprationType.Text == "TCP" || cbOprationType.Text == "UDP")
            {
                IpSetting settingForm = new IpSetting();
                if (Setting != null && (Setting as NetworkSetting) != null)
                {
                    NetworkSetting ns = (NetworkSetting)Setting;
                    settingForm.Ip   = ns.Ip;
                    settingForm.Port = ns.Port;
                }

                if (settingForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    NetworkSetting ns = new NetworkSetting();
                    ns.Ip   = settingForm.Ip;
                    ns.Port = settingForm.Port;

                    Setting = ns;
                }
            }
            else if (cbOprationType.Text == "串口")
            {
                SerialPortSetting settingForm = new SerialPortSetting();
                if (Setting != null && (Setting as ComSetting) != null)
                {
                    ComSetting cs = (ComSetting)Setting;
                    settingForm.ComNumber = cs.ComNumber;
                    settingForm.BaudRate  = cs.BaudRate;
                    settingForm.Databit   = cs.DataBits;
                    settingForm.StopBit   = cs.StopBits;
                    settingForm.Parity    = cs.Parity;
                }

                if (settingForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ComSetting cs = new ComSetting();
                    cs.ComNumber = settingForm.ComNumber;
                    cs.BaudRate  = settingForm.BaudRate;
                    cs.StopBits  = settingForm.StopBit;
                    cs.DataBits  = settingForm.Databit;
                    cs.Parity    = settingForm.Parity;

                    Setting = cs;
                }
            }
        }
예제 #2
0
        private void btnSet_Click(object sender, EventArgs e)
        {
            SerialPortSetting settingForm = new SerialPortSetting();

            if (_relayCom != null)
            {
                // settingForm.ComNumber = _relayCom.ComNumber;
                settingForm.BaudRate = _relayCom.BaudRate;
                settingForm.Databit  = _relayCom.DataBits;
                settingForm.Parity   = _relayCom.Parity;
            }
            if (settingForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _relayCom.ComNumber = settingForm.ComNumber;
                _relayCom.BaudRate  = settingForm.BaudRate;
                _relayCom.DataBits  = settingForm.Databit;
                _relayCom.StopBits  = settingForm.StopBit;
                _relayCom.Parity    = settingForm.Parity;
            }
        }