FeederNameConverter.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using TeamAAS.Core;
  6. namespace Plugins.Feeder.Core
  7. {
  8. public class FeederNameConverter : StringConverter
  9. {
  10. public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
  11. public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
  12. {
  13. var names = new List<string>();
  14. try
  15. {
  16. var mgr = CoreManager.Feeder;
  17. if (mgr != null)
  18. {
  19. names = mgr.GetAll()
  20. .Select(f => f.FeederName)
  21. .Where(n => !string.IsNullOrEmpty(n))
  22. .Distinct()
  23. .OrderBy(n => n)
  24. .ToList();
  25. }
  26. }
  27. catch { }
  28. return new StandardValuesCollection(names);
  29. }
  30. public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false;
  31. }
  32. }