GuidToImageSourceConverter.cs 465 B

123456789101112131415161718
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Media;
  4. namespace InABox.WPF;
  5. public class GuidToImageSourceConverter : AbstractConverter<Guid,ImageSource?>
  6. {
  7. public Dictionary<Guid, byte[]>? Images { get; init; }
  8. public override ImageSource? Convert(Guid value)
  9. {
  10. if (Images?.TryGetValue(value, out byte[]? result) == true)
  11. return ImageUtils.BitmapImageFromBytes(result);
  12. return null;
  13. }
  14. }