using Interact; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; namespace StormChatWPF.UI { /// /// 聊天气泡 /// class ChatBubble:Label { TextBlock text = new TextBlock() { MaxWidth = 400, MinWidth = 10, MinHeight = 20, TextWrapping = TextWrapping.Wrap, FontFamily = new FontFamily("Comic Sans MS"), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom }; /// /// 生成聊天气泡 /// /// 传入消息体 /// 设置水平对齐方式,参数为HorizontalAlignment枚举类型 public ChatBubble(Message msg,HorizontalAlignment alignment) { Background = new ImageBrush() { ImageSource=new BitmapImage(new Uri("pack://application:,,,/UI/Resources/聊天气泡.png")) }; HorizontalAlignment = alignment; text.Text = msg.Text; Content = text; } } }