| 123456789101112131415161718192021222324252627282930 |
- 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<string>();
- 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;
- }
- }
|