protected override UIElement CreateFieldElement(PlayerDisplay playerDisplay) { FontAwesome.WPF.ImageAwesome image = new FontAwesome.WPF.ImageAwesome() { Width = 16, Height = 16, Icon = FontAwesome.WPF.FontAwesomeIcon.StickyNoteOutline }; playerDisplay.Data.PropertyChanged += (o, a) => { if (a.PropertyName == Path) { image.Dispatcher.Invoke(() => { image.Foreground = new SolidColorBrush(PlayerNotes.Instance[playerDisplay.Data.ID].Colour); }); } }; image.MouseDown += (o, a) => { if (!string.IsNullOrEmpty(playerDisplay.Data.ID)) { NotesWindow window = new NotesWindow(playerDisplay.Data.ID, image); window.ShowDialog(); } }; return(image); }
private void ToggleTextVisibility(FontAwesome.WPF.ImageAwesome icon) { if (icon.Parent is Grid grid) { var helpBlock = grid.Children.OfType <TextBlock>().FirstOrDefault(x => x.Name == "UsageHelp"); if (helpBlock != null) { helpBlock.Visibility = (helpBlock.Visibility == Visibility.Visible) ? Visibility.Hidden : Visibility.Visible; } } }
protected override UIElement CreateFieldElement(PlayerDisplay playerDisplay) { FontAwesome.WPF.ImageAwesome image = new FontAwesome.WPF.ImageAwesome() { Width = 16, Height = 16, Icon = FontAwesome.WPF.FontAwesomeIcon.ExternalLink }; image.MouseDown += (o, a) => { playerDisplay.OpenProfile(); }; return(image); }
public static Paragraph BuildParagraph( ActionInfo action, int index, double baseFontSize, string style) { // 是否显示 transfer (in) 条目。注意,即便 false, 也要显示 transfer (out) 条目的 bool display_transfer = StringUtil.IsInList("transfer", style); if (action.Action.StartsWith("transfer") && action.TransferDirection == "in" && display_transfer == false) { return(null); } var p = new Paragraph(); p.FontFamily = new FontFamily("微软雅黑"); p.FontSize = baseFontSize; // p.FontStyle = FontStyles.Italic; p.TextAlignment = TextAlignment.Left; p.Foreground = Brushes.Gray; // p.LineHeight = 18; p.TextIndent = -20; p.Margin = new Thickness(10, 0, 0, 8); // 10,0,0,8 p.Tag = new ParagraphInfo { Action = action, Index = index }; // 记忆下来后面刷新事项的时候可以用到 // 序号 p.Inlines.Add(new Run($"{(index + 1).ToString()}) ")); Brush back = Brushes.Transparent; // 状态 { // 等待动画 if (string.IsNullOrEmpty(action.State)) { var image = new FontAwesome.WPF.ImageAwesome(); image.Icon = FontAwesome.WPF.FontAwesomeIcon.Spinner; image.Spin = true; image.SpinDuration = 5; image.Height = baseFontSize * 2.0; image.Foreground = Brushes.DarkGray; var container = new InlineUIContainer(image); container.Name = "image_id"; p.Inlines.Add(container); } else if (action.SyncErrorCode == "overflow") { back = Brushes.DarkRed; p.Inlines.Add(new Run { Text = " 超额 ", Background = back, Foreground = Brushes.White }); } else if (action.State == "sync") { back = Brushes.DarkGreen; p.Inlines.Add(new Run { Text = " 成功 ", Background = back, Foreground = Brushes.White }); } else if (action.SyncErrorCode == "skipped") { back = Brushes.DeepSkyBlue; p.Inlines.Add(new Run { Text = $" 暂时跳过同步 ", Background = back, Foreground = Brushes.White }); } else if (action.State == "commerror" || action.State == "normalerror") { if (ShelfData.LibraryNetworkCondition == "Bad") { back = Brushes.DeepSkyBlue; } else { back = Brushes.DarkRed; } p.Inlines.Add(new Run { Text = $" 同步失败({action.State}) ", Background = back, Foreground = Brushes.White }); } else if (action.State == "dontsync") { back = Brushes.DarkBlue; p.Inlines.Add(new Run { Text = $" 不再同步 ", Background = back, Foreground = Brushes.White }); } else { back = Brushes.DarkRed; p.Inlines.Add(new Run { Text = $" {action.State} ", Background = back, Foreground = Brushes.White }); } } // 转移方向 if (action.Action.StartsWith("transfer") /*&& string.IsNullOrEmpty(action.TransferDirection) == false*/) { p.Inlines.Add(new Run { Text = GetTransferDirCaption(action.TransferDirection, action.Location) + " ", Foreground = Brushes.White }); } else { // 操作名称 p.Inlines.Add(new Run { Text = GetOperationCaption(action.Action) + " ", Foreground = Brushes.White }); } string title = ""; if (action.Entity != null) { title = MessageDocument.ShortTitle(action.Entity.Title); // 2020/5/6 // 尝试从本地缓存中获取书目摘要 if (string.IsNullOrEmpty(title)) { title = LibraryChannelUtil.GetBiblioSummaryFromLocal(action.Entity.GetOiPii(true)); } if (string.IsNullOrEmpty(title)) { title = ShelfData.GetPiiString(action.Entity); } else { // 2020/7/22 title = $"[{ShelfData.GetPiiString(action.Entity)}] {title}"; } } else { title = "(action.Entity 为空)"; } // 书目摘要 if (string.IsNullOrEmpty(title) == false) { Run run = new Run(title); /* * run.FontSize = 14; * run.FontStyle = FontStyles.Normal; * run.Background = Brushes.DarkRed; * run.Foreground = Brushes.White; */ p.Inlines.Add(run); } // 对于上架/下架来说,还要补充显示一些细节信息:location 去向;和 currentLocation 去向 if (action.Action.StartsWith("transfer")) { List <string> details = new List <string>(); if (string.IsNullOrEmpty(action.Location) == false) { details.Add($"调拨到:{action.Location}"); } if (string.IsNullOrEmpty(action.CurrentShelfNo) == false) { details.Add($"新架位:{action.CurrentShelfNo}"); } p.Inlines.Add(new Run { Text = " " + StringUtil.MakePathList(details, " ") + " ", Foreground = Brushes.Green }); } // 错误码和错误信息 if (string.IsNullOrEmpty(action.SyncErrorInfo) == false && (action.State != "sync" || action.SyncErrorCode == "overflow")) { p.Inlines.Add(new Run { Text = "\r\n" + action.SyncErrorInfo, Background = back, Foreground = Brushes.White }); } return(p); }