BanListControl.xaml.cs 898 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.Bans;
  7. [GenerateTypedNameReferences]
  8. public sealed partial class BanListControl : Control
  9. {
  10. public event Action<BanListLine>? LineIdsClicked;
  11. public BanListControl()
  12. {
  13. RobustXamlLoader.Load(this);
  14. }
  15. public void SetBans(List<SharedServerBan> bans)
  16. {
  17. for (var i = Bans.ChildCount - 1; i >= 1; i--)
  18. {
  19. Bans.GetChild(i).Dispose();
  20. }
  21. foreach (var ban in bans)
  22. {
  23. Bans.AddChild(new HSeparator());
  24. var line = new BanListLine(ban);
  25. line.IdsClicked += LineIdsClicked;
  26. Bans.AddChild(line);
  27. }
  28. }
  29. }