BoxToHexConverter.cs 1004 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Markup;
  6. using System.Windows.Data;
  7. using MatrixIO.IO.Bmff;
  8. namespace BmffViewer
  9. {
  10. public class BoxToHexConverter : MarkupExtension, IValueConverter
  11. {
  12. public BoxToHexConverter() : base() { }
  13. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  14. {
  15. Box box = value as Box;
  16. if(box!=null && box.HasContent)
  17. return new VirtualizedBinaryReader(box.GetContentStream(), (long)box.ContentOffset.Value, (long)box.ContentSize.Value);
  18. return null;
  19. }
  20. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  21. {
  22. return null;
  23. }
  24. public override object ProvideValue(IServiceProvider serviceProvider)
  25. {
  26. return this;
  27. }
  28. }
  29. }