public static DrawingBrush Get(CardViewModel card) { try { if (card?.Id == null || card.Name == null || Cache == null) { return(new DrawingBrush()); } var cardImageObj = new CardImageObject(card); var key = $"{card.Id}_{cardImageObj.GetHashCode()}"; if (!Refresh.Contains(card.Id) && Cache.TryGet(key, out var cached)) { return(cached.Image); } Refresh.Remove(card.Id); DrawingBrush image = null; Application.Current.Dispatcher.Invoke(() => image = ThemeManager.GetBarImageBuilder(card).Build()); if (image.CanFreeze) { image.Freeze(); } cardImageObj = new CardImageObject(image, card); Cache.Cache(key, cardImageObj); return(cardImageObj.Image); } catch (Exception ex) { Log.Error($"Image builder failed: {ex.Message}"); return(new DrawingBrush()); } }
protected bool Equals(CardImageObject other) => Count == other.Count && Jousted == other.Jousted && ColoredFrame == other.ColoredFrame && ColoredGem == other.ColoredGem && Name == other.Name && string.Equals(Theme, other.Theme) && TextColorHash == other.TextColorHash && Created == other.Created;