private void cbDevice_SelectedIndexChanged(object sender, EventArgs e) { // create user interface of selected device CnlPrototypes = null; if (cbDevice.SelectedItem is Device device) { if (deviceItems.TryGetValue(device.DeviceNum, out DeviceItem deviceItem) && deviceItem.Instance != null) { try { if (deviceItem.DeviceView == null) { if (ExtensionUtils.GetDeviceView(adminContext, deviceItem.Instance.CommApp, deviceItem.DeviceConfig, out DeviceView deviceView, out string errMsg)) { deviceItem.DeviceView = deviceView; } else { throw new ScadaException(errMsg); } } deviceItem.CnlPrototypes = deviceItem.DeviceView.GetCnlPrototypes(); int cnlCnt = deviceItem.CnlPrototypes?.Count ?? 0; txtInfo.Text = string.Format(ExtensionPhrases.DeviceInfo, deviceItem.DeviceConfig.Driver, deviceItem.Instance.Name, cnlCnt); pbStatus.Image = cnlCnt > 0 ? Properties.Resources.success : Properties.Resources.warning; }
/// <summary> /// Gets a new instance of the device user interface. /// </summary> private DeviceView GetDeviceView(DeviceConfig deviceConfig) { ValidateInit(); return(ExtensionUtils.GetDeviceView(adminContext, commApp, deviceConfig)); }