private void FillContent(Paragraph pa, MessageModel msg) { switch (msg.MsgType) { case MessageType.txt: case MessageType.bigtxt: Helper.MessageHelper.ContentInlines = null; var inlines = CSClient.Helper.MessageHelper.GetRichContent(msg.Content, false); foreach (Inline inl in inlines) { inl.BaselineAlignment = BaselineAlignment.Bottom; inl.FontSize = 14; inl.FontFamily = _FontFamily; pa.Inlines.Add(inl); if (inl is InlineUIContainer uic) { uic.Child.Uid = ViewModels.AppData.FlagEmoje + uic.Child.Uid; } } break; case MessageType.img: InlineUIContainer imgC = new InlineUIContainer(); ChatImage chatImg = new ChatImage(msg.Content, new Size(240, 135)) { DataContext = msg, HasContexMenu = false }; imgC.Child = chatImg; Binding bind = new Binding("Content") { Mode = BindingMode.OneWay }; chatImg.SetBinding(ChatImage.ImagePathProperty, bind); bind = new Binding("MessageState") { Mode = BindingMode.OneWay }; chatImg.SetBinding(ChatImage.StateProperty, bind); CSClient.Helper.MessageHelper.LoadImgContent(msg); pa.Inlines.Add(imgC); imgC.PreviewMouseLeftButtonDown += ImgC_MouseLeftButtonUp; break; case MessageType.file: case MessageType.onlinefile: InlineUIContainer uicFile = new InlineUIContainer(); FileChatItem chatFile = new FileChatItem() { DataContext = msg, IsMainView = false }; chatFile.IsInDocument = true; //msg.ResourceModel.FileState = FileStates.Completed; uicFile.Child = chatFile; Binding bindF = new Binding("Content") { Mode = BindingMode.OneWay }; chatFile.SetBinding(FileChatItem.FullNameProperty, bindF); Binding bindState = new Binding("ResourceModel.FileState") { Mode = BindingMode.TwoWay }; chatFile.SetBinding(FileChatItem.FileStateProperty, bindState); //CSClient.Helper.MessageHelper.LoadFileContent(msg); pa.Inlines.Add(uicFile); break; default: //pa.Inlines.Clear(); //pa.Inlines.Add(new Run(msg.Content) //{ // FontSize = 14, // Background = Brushes.Gray, // Foreground = Brushes.LightGray, // FontFamily = _FontFamily, //}); //pa.TextAlignment = TextAlignment.Center; pa.Inlines.Add(new Run(msg.Content) { FontSize = 14, FontFamily = _FontFamily, }); break; } pa.Inlines.Add("\r\n"); }
private void FillContent(Paragraph pa, MessageModel msg) { switch (msg.MsgType) { case MessageType.txt: case MessageType.bigtxt: IMClient.Helper.MessageHelper.ContentInlines = null; var inlines = IMClient.Helper.MessageHelper.GetRichContent(msg.Content, false); foreach (Inline inl in inlines) { inl.BaselineAlignment = BaselineAlignment.Bottom; inl.FontSize = 14; inl.FontFamily = _FontFamily; pa.Inlines.Add(inl); if (inl is InlineUIContainer uic) { uic.Child.Uid = ViewModels.AppData.FlagEmoje + uic.Child.Uid; } } break; case MessageType.img: InlineUIContainer imgC = new InlineUIContainer(); ChatImage chatImg = new ChatImage(msg.Content) { DataContext = msg, HasContexMenu = false }; chatImg.Tag = msg.ResourceModel.Key; imgC.Child = chatImg; Binding bind = new Binding("Content") { Mode = BindingMode.OneWay }; chatImg.SetBinding(ChatImage.ImagePathProperty, bind); bind = new Binding("MessageState") { Mode = BindingMode.OneWay }; chatImg.SetBinding(ChatImage.StateProperty, bind); if (msg.MessageState != MessageStates.Success) { IMClient.Helper.MessageHelper.LoadImgContent(msg); } pa.Inlines.Add(imgC); imgC.PreviewMouseLeftButtonDown += ImgC_MouseLeftButtonUp; break; case MessageType.smallvideo: case MessageType.video: InlineUIContainer videoC = new InlineUIContainer(); SmallVideo smallVideo = new SmallVideo(msg.Content, 142, 220, msg) { HasContexMenu = false }; videoC.Child = smallVideo; Binding bindV = new Binding("Content") { Mode = BindingMode.OneWay }; smallVideo.SetBinding(SmallVideo.VideoPathProperty, bindV); bindV = new Binding("ResourceModel.FileState") { Mode = BindingMode.TwoWay }; smallVideo.SetBinding(SmallVideo.FileStateProperty, bindV); bindV = new Binding("ResourceModel.RecordTime") { Mode = BindingMode.TwoWay }; smallVideo.SetBinding(SmallVideo.RecordTimeProperty, bindV); bindV = new Binding("ResourceModel.PreviewImagePath") { Mode = BindingMode.TwoWay }; smallVideo.SetBinding(SmallVideo.VideoPreviewImageProperty, bindV); pa.Inlines.Add(videoC); videoC.PreviewMouseLeftButtonDown += ImgC_MouseLeftButtonUp; break; case MessageType.file: case MessageType.onlinefile: InlineUIContainer uicFile = new InlineUIContainer(); FileChatItem chatFile = new FileChatItem() { DataContext = msg, IsMainView = false }; chatFile.IsInDocument = true; //msg.ResourceModel.FileState = FileStates.Completed; uicFile.Child = chatFile; Binding bindF = new Binding("Content") { Mode = BindingMode.OneWay }; chatFile.SetBinding(FileChatItem.FullNameProperty, bindF); Binding bindState = new Binding("ResourceModel.FileState") { Mode = BindingMode.TwoWay }; chatFile.SetBinding(FileChatItem.FileStateProperty, bindState); //IMClient.Helper.MessageHelper.LoadFileContent(msg); pa.Inlines.Add(uicFile); break; case MessageType.addgroupnotice: InlineUIContainer noticeContainer = new InlineUIContainer(); GroupNoticeCard groupCard = new GroupNoticeCard() { DataContext = msg }; groupCard.tb_tiTle.FontSize = 14; groupCard.tb_content.FontSize = 14; groupCard.tbInfo.FontSize = 12; groupCard.FontFamily = new FontFamily("微软雅黑"); noticeContainer.Child = groupCard; pa.Inlines.Add(noticeContainer); //noticeContainer.PreviewMouseLeftButtonDown += GroupCard_PreviewMouseLeftButtonDown; break; case MessageType.usercard: IMClient.Helper.MessageHelper.ContentInlines = null; //var content = msg.Content; var content = "个人名片"; var usercardinlines = IMClient.Helper.MessageHelper.GetRichContent(content, false); foreach (Inline inl in usercardinlines) { inl.BaselineAlignment = BaselineAlignment.Bottom; inl.FontSize = 14; inl.FontFamily = _FontFamily; pa.Inlines.Add(inl); if (inl is InlineUIContainer uic) { uic.Child.Uid = ViewModels.AppData.FlagEmoje + uic.Child.Uid; } } //InlineUIContainer personCard = new InlineUIContainer(); //PersonalCard card = new PersonalCard() { DataContext = msg, HasContexMenu = false }; //card.tb_PhoneNumber.FontSize = 10; //card.tb_DisplayName.FontSize = 12; //card.tbInfo.FontSize = 12; //card.FontFamily = new FontFamily("微软雅黑"); //personCard.Child = card; //pa.Inlines.Add(personCard); break; case MessageType.foreigndyn: InlineUIContainer foreigndynControl = new InlineUIContainer(); var msgCard = new HyperlinkMessageCard() { DataContext = msg, HasContexMenu = false }; // msgCard.tb_PhoneNumber.FontSize = 10; //card.tb_DisplayName.FontSize = 12; //card.tbInfo.FontSize = 12; msgCard.Width = 230; msgCard.FontSize = 12; msgCard.FontFamily = new FontFamily("微软雅黑"); foreigndynControl.Child = msgCard; pa.Inlines.Add(foreigndynControl); break; default: //pa.Inlines.Clear(); //pa.Inlines.Add(new Run(msg.Content) //{ // FontSize = 14, // Background = Brushes.Gray, // Foreground = Brushes.LightGray, // FontFamily = _FontFamily, //}); //pa.TextAlignment = TextAlignment.Center; pa.Inlines.Add(new Run(msg.Content) { FontSize = 14, FontFamily = _FontFamily, }); break; } pa.Inlines.Add("\r\n"); }