using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using TeamAAS.Core; namespace Plugins.Standard.Core { public class SerialDeviceConverter : StringConverter { public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true; public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { var names = new List(); try { var comm = CoreManager.Communication; if (comm != null) { names = comm.GetSerials().Select(d => d.Name).Where(n => !string.IsNullOrEmpty(n)).ToList(); } } catch { } return new StandardValuesCollection(names); } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false; } }