SequenceNameConverter.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 SequenceNameConverter : 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. foreach (var feeder in mgr.GetAll())
  20. {
  21. foreach (var seq in feeder.Sequences)
  22. {
  23. if (!string.IsNullOrEmpty(seq.Name))
  24. names.Add($"{feeder.FeederName}/{seq.Name}");
  25. }
  26. }
  27. names = names.Distinct().OrderBy(n => n).ToList();
  28. }
  29. }
  30. catch { }
  31. return new StandardValuesCollection(names);
  32. }
  33. public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false;
  34. }
  35. }