NewsArticleCard.xaml.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Robust.Client.AutoGenerated;
  2. using Robust.Client.UserInterface;
  3. using Robust.Client.UserInterface.XAML;
  4. namespace Content.Client.MassMedia.Ui;
  5. [GenerateTypedNameReferences]
  6. public sealed partial class NewsArticleCard : Control
  7. {
  8. private string? _authorMarkup;
  9. private TimeSpan? _publicationTime;
  10. public Action? OnDeletePressed;
  11. public int ArtcileNumber;
  12. public string? Title
  13. {
  14. get => TitleLabel.Text;
  15. set => TitleLabel.Text = value?.Length <= 30 ? value : $"{value?[..30]}...";
  16. }
  17. public string? Author
  18. {
  19. get => _authorMarkup;
  20. set
  21. {
  22. _authorMarkup = value;
  23. AuthorLabel.Text = _authorMarkup ?? "";
  24. }
  25. }
  26. public TimeSpan? PublicationTime
  27. {
  28. get => _publicationTime;
  29. set
  30. {
  31. _publicationTime = value;
  32. PublishTimeLabel.Text = value?.ToString(@"hh\:mm\:ss") ?? "";
  33. }
  34. }
  35. public NewsArticleCard()
  36. {
  37. RobustXamlLoader.Load(this);
  38. DeleteButton.OnPressed += _ => OnDeletePressed?.Invoke();
  39. }
  40. }