CameraDeviceConverter.cs 963 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using TeamAAS.Camera;
  6. using TeamAAS.Core;
  7. namespace Plugins.Standard.Core
  8. {
  9. public class CameraDeviceConverter : StringConverter
  10. {
  11. public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
  12. public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
  13. {
  14. var names = new List<string>();
  15. try
  16. {
  17. var devices = CoreManager.Camera.Devices;
  18. if (devices != null)
  19. {
  20. names = devices.Select(d => d.Name).Where(n => !string.IsNullOrEmpty(n)).ToList();
  21. }
  22. }
  23. catch { }
  24. return new StandardValuesCollection(names);
  25. }
  26. public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false;
  27. }
  28. }