ImageConverter.cs 826 B

1234567891011121314151617181920212223242526
  1. using Avalonia.Data.Converters;
  2. using Avalonia.Media.Imaging;
  3. using Avalonia.Platform;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Globalization;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Users_Roles.Converters
  12. {
  13. internal class ImageConverter : IValueConverter
  14. {
  15. public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
  16. {
  17. return value == null ? new Bitmap(AssetLoader.Open(new Uri("avares://Users_Roles/Assets/ProfileFirstImage.png"))) : new Bitmap(new MemoryStream((byte[])value));
  18. }
  19. public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
  20. {
  21. throw new NotImplementedException();
  22. }
  23. }
  24. }