CommandTriggerGroup.cs 803 B

12345678910111213141516171819202122232425262728
  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. foreach (ICommandTrigger child in this)
  11. {
  12. if (!_initList.Contains(child))
  13. {
  14. InitializeCommandSource(source, child);
  15. }
  16. }
  17. }
  18. private void InitializeCommandSource(FrameworkElement source, ICommandTrigger child)
  19. {
  20. child.Initialize(source);
  21. _initList.Add(child);
  22. }
  23. }
  24. }