1
0

ButtonHelpers.cs 985 B

12345678910111213141516171819202122232425262728293031
  1. using Robust.Client.UserInterface;
  2. using Robust.Client.UserInterface.Controls;
  3. namespace Content.Client.UserInterface
  4. {
  5. public static class ButtonHelpers
  6. {
  7. /// <summary>
  8. /// This searches recursively through all the children of "parent"
  9. /// and sets the Disabled value of any buttons found to "val"
  10. /// </summary>
  11. /// <param name="parent">The control which childrens get searched</param>
  12. /// <param name="val">The value to which disabled gets set</param>
  13. public static void SetButtonDisabledRecursive(Control parent, bool val)
  14. {
  15. foreach (var child in parent.Children)
  16. {
  17. if (child is Button but)
  18. {
  19. but.Disabled = val;
  20. continue;
  21. }
  22. if (child.ChildCount > 0)
  23. {
  24. SetButtonDisabledRecursive(child, val);
  25. }
  26. }
  27. }
  28. }
  29. }