RoleBanListControl.xaml.cs 942 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Content.Client.Administration.UI.CustomControls;
  2. using Content.Shared.Administration.BanList;
  3. using Robust.Client.AutoGenerated;
  4. using Robust.Client.UserInterface;
  5. using Robust.Client.UserInterface.XAML;
  6. namespace Content.Client.Administration.UI.BanList.RoleBans;
  7. [GenerateTypedNameReferences]
  8. public sealed partial class RoleBanListControl : Control
  9. {
  10. public event Action<RoleBanListLine>? LineIdsClicked;
  11. public RoleBanListControl()
  12. {
  13. RobustXamlLoader.Load(this);
  14. }
  15. public void SetRoleBans(List<SharedServerRoleBan> bans)
  16. {
  17. for (var i = RoleBans.ChildCount - 1; i >= 1; i--)
  18. {
  19. RoleBans.GetChild(i).Dispose();
  20. }
  21. foreach (var ban in bans)
  22. {
  23. RoleBans.AddChild(new HSeparator());
  24. var line = new RoleBanListLine(ban);
  25. line.IdsClicked += LineIdsClicked;
  26. RoleBans.AddChild(line);
  27. }
  28. }
  29. }