Пример #1
0
        private void 设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_currentOperation != null)
            {
                TimeOperationSetting os = new TimeOperationSetting();
                os.OprationName      = _currentOperation.Name;
                os.CommunicationType = GetOperationTypeString(_currentOperation.OpreationType);
                os.DataType          = GetDataTypeString(_currentOperation.DataType);
                os.Data      = _currentOperation.Data;
                os.DelayTime = _currentOperation.DelayTime / 1000;
                os.Setting   = _currentOperation.Setting;

                if (os.ShowDialog() == DialogResult.OK)
                {
                    CommunicationType opType = CommunicationType.Com;
                    if (os.CommunicationType.ToLower() == "tcp")
                    {
                        opType = CommunicationType.TCP;
                    }
                    else if (os.CommunicationType.ToLower() == "udp")
                    {
                        opType = CommunicationType.UDP;
                    }
                    else if (os.CommunicationType.ToLower() == "串口")
                    {
                        opType = CommunicationType.Com;
                    }

                    DataType dType = DataType.Character;
                    if (os.DataType.ToLower() == "十六进制")
                    {
                        dType = DataType.Hex;
                    }
                    else if (os.DataType.ToLower() == "字符串")
                    {
                        dType = DataType.Character;
                    }

                    _currentOperation.Name          = os.OprationName;
                    _currentOperation.OpreationType = opType;
                    _currentOperation.DataType      = dType;
                    _currentOperation.Setting       = os.Setting;
                    _currentOperation.Data          = os.Data;
                    _currentOperation.DelayTime     = os.DelayTime;

                    RefreshOprations();
                }
            }
        }
Пример #2
0
        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_opreations == null)
            {
                Helper.ShowMessageBox("提示", "请选择对应操作项或时间点!");
                return;
            }

            TimeOperationSetting os = new TimeOperationSetting();

            if (os.ShowDialog() == DialogResult.OK)
            {
                CommunicationType opType = CommunicationType.Com;
                if (os.CommunicationType.ToLower() == "tcp")
                {
                    opType = CommunicationType.TCP;
                }
                else if (os.CommunicationType.ToLower() == "udp")
                {
                    opType = CommunicationType.UDP;
                }
                else if (os.CommunicationType.ToLower() == "串口")
                {
                    opType = CommunicationType.Com;
                }

                DataType dType = DataType.Character;
                if (os.DataType.ToLower() == "十六进制")
                {
                    dType = DataType.Hex;
                }
                else if (os.DataType.ToLower() == "字符串")
                {
                    dType = DataType.Character;
                }

                UserOperation opration = new UserOperation(os.OprationName, opType, dType, os.Setting, os.Data, os.DelayTime);
                AddOpration(opration);
            }
        }