ChatBubble.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Windows;
  3. using HandyControl.Data;
  4. namespace HandyControl.Controls;
  5. public class ChatBubble : SelectableItem
  6. {
  7. public static readonly DependencyProperty RoleProperty = DependencyProperty.Register(
  8. nameof(Role), typeof(ChatRoleType), typeof(ChatBubble), new PropertyMetadata(default(ChatRoleType)));
  9. public ChatRoleType Role
  10. {
  11. get => (ChatRoleType) GetValue(RoleProperty);
  12. set => SetValue(RoleProperty, value);
  13. }
  14. public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
  15. nameof(Type), typeof(ChatMessageType), typeof(ChatBubble), new PropertyMetadata(default(ChatMessageType)));
  16. public ChatMessageType Type
  17. {
  18. get => (ChatMessageType) GetValue(TypeProperty);
  19. set => SetValue(TypeProperty, value);
  20. }
  21. public static readonly DependencyProperty IsReadProperty = DependencyProperty.Register(
  22. nameof(IsRead), typeof(bool), typeof(ChatBubble), new PropertyMetadata(ValueBoxes.FalseBox));
  23. public bool IsRead
  24. {
  25. get => (bool) GetValue(IsReadProperty);
  26. set => SetValue(IsReadProperty, ValueBoxes.BooleanBox(value));
  27. }
  28. public Action<object> ReadAction { get; set; }
  29. protected override void OnSelected(RoutedEventArgs e)
  30. {
  31. base.OnSelected(e);
  32. IsRead = true;
  33. ReadAction?.Invoke(Content);
  34. }
  35. }