| | |
| | | IOperationConfig backOpConfig = new OperationConfigBase(); |
| | | List<IDevice> deviceList = null; |
| | | IDevice currentDevice = null; |
| | | public FrmDeviceOpConfigEditor(DeviceOpBind bind) |
| | | public FrmDeviceOpConfigEditor(DeviceOpBind bind, bool isEnableSelectDevice = true) |
| | | { |
| | | InitializeComponent(); |
| | | |
| | |
| | | cboDevice.SelectedIndex = 0; |
| | | } |
| | | |
| | | cboDevice.SelectedIndexChanged += CboDevice_SelectedIndexChanged; |
| | | if (isEnableSelectDevice) |
| | | { |
| | | cboDevice.Enabled = true; |
| | | cboDevice.SelectedIndexChanged += CboDevice_SelectedIndexChanged; |
| | | } |
| | | else |
| | | { |
| | | cboDevice.Enabled = false; |
| | | } |
| | | |
| | | if (bind.OpConfig == null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | bind.OpConfig.DeviceId = bind.Device; |
| | | |
| | | backOpConfig.DataFrom(bind.OpConfig); |
| | | |
| | | propGrid.SelectedObject = bind.OpConfig; |
| | | |
| | | } |
| | | |
| | | private void CboDevice_SelectedIndexChanged(object sender, EventArgs e) |
| | |
| | | var attr = device.GetType().GetCustomAttribute<DeviceAttribute>(); |
| | | if (attr != null) |
| | | { |
| | | propGrid.SelectedObject = ConfigFactory.GetOperationConfig(attr.TypeCode); |
| | | var opConfig = ConfigFactory.GetOperationConfig(attr.TypeCode); |
| | | opConfig.DeviceId = device.Id; |
| | | propGrid.SelectedObject = opConfig; |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | Bind.Device = cboDevice.SelectedValue.ToString(); |
| | | Bind.OpConfig = propGrid.SelectedObject as IOperationConfig; |
| | | Bind.OpConfig.DeviceId = Bind.Device; |
| | | this.DialogResult = DialogResult.OK; |
| | | } |
| | | |