public static SerialPortConfigItem GetConfigItem(SerialPortConfigItemName itemName) { SerialPortConfigItem spci = null; string name = Enum.GetName(typeof(SerialPortConfigItemName) , itemName); spci = new SerialPortConfigItem(name); //ConfigManager.SetSerialPortConfigurnation(ref spci); return(spci); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeViewAction action = e.Action; if (action == TreeViewAction.ByMouse) { //需要首先清楚之前添加的控件 if (this.settingItem != null) { this.settingItem.removeControls(); } this.btnOk.Enabled = false; TreeNode node = e.Node; if (node.Name == "超高频RFID") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.超高频RFID串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "超高频RFID串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "高频RFID") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.高频RFID串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "高频RFID串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "GPS模块") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.GPS串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "GPS模块串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "GSM模块") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.GSM模块串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "GSM模块串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "Zigbee模块") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.Zigbee模块串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "Zigbee模块串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "条码模块") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.条码模块); this.settingItem = new sysSettingSerialPortBase(this.Controls, "条码模块串口参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "常用设置") { ISerialPortConfigItem ispci = SerialPortConfigItem.GetConfigItem(SerialPortConfigItemName.常用串口设置); this.settingItem = new sysSettingSerialPortBase(this.Controls, "常用参数设置", ispci, frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "网络参数") { this.settingItem = new UdpConfig(this.Controls, "常用参数设置", frmSysSettings_Click); this.settingItem.addControls(); return; } if (node.Name == "系统参数") { this.settingItem = new sysParaConfig(this.Controls, "系统参数", frmSysSettings_Click); this.settingItem.addControls(); return; } } }