private Paragraph GeneratePreview(LinkedList <object> list) { // 富文本预览 Paragraph paragraph = new Paragraph(); foreach (var a in list) { if (a is TextColor textColor) { paragraph.Inlines.Add(new Run() { Text = textColor.Text.Replace("\\n", "\n"), Foreground = new SolidColorBrush(GetKeyColor(textColor.Key)) }); } else if (a is TextIcon textIcon) { var image = GetKeyImage(textIcon.Key); if (image != null) { paragraph.Inlines.Add(new InlineUIContainer(new Image { Source = BitmapUtil.BitmapToBitmapImage(image, 20, 20), Width = 20, Height = 20 })); } } } return(paragraph); }
private void ChangeBackgroundImage(Bitmap bitmap) { var value = true; dispatcher.Invoke(new Action(() => { value = IsVisible; }), DispatcherPriority.Normal); if (!value) { return; } dispatcher.BeginInvoke(new Action(() => { Background = new ImageBrush(BitmapUtil.BitmapToBitmapImage(bitmap, 800, 450)); }), DispatcherPriority.Normal); Thread.Sleep(5000); }