CommandTriggerGroup.cs 766 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections.Generic;
  2. using System.Windows;
  3. namespace OpenSEMI.ClientBase.Command
  4. {
  5. public sealed class CommandTriggerGroup : FreezableCollection<CommandTrigger>, ICommandTrigger
  6. {
  7. private readonly HashSet<ICommandTrigger> _initList = new HashSet<ICommandTrigger>();
  8. void ICommandTrigger.Initialize(FrameworkElement source)
  9. {
  10. using (Enumerator enumerator = GetEnumerator())
  11. {
  12. while (enumerator.MoveNext())
  13. {
  14. ICommandTrigger current = enumerator.Current;
  15. if (!_initList.Contains(current))
  16. {
  17. InitializeCommandSource(source, current);
  18. }
  19. }
  20. }
  21. }
  22. private void InitializeCommandSource(FrameworkElement source, ICommandTrigger child)
  23. {
  24. child.Initialize(source);
  25. _initList.Add(child);
  26. }
  27. }
  28. }