DicomFileToDumpConverter.cs 865 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) 2012-2018 fo-dicom contributors.
  2. // Licensed under the Microsoft Public License (MS-PL).
  3. using Dicom;
  4. using Dicom.Log;
  5. using System;
  6. using Windows.UI.Xaml.Data;
  7. namespace SimpleViewer.Universal.Converters
  8. {
  9. public class DicomFileToDumpConverter : IValueConverter
  10. {
  11. public object Convert(object value, Type targetType, object parameter, string language)
  12. {
  13. if (value == null)
  14. {
  15. return null;
  16. }
  17. if (!(value is DicomFile dicomFile))
  18. {
  19. throw new InvalidOperationException("Only DICOM files supported.");
  20. }
  21. var dump = dicomFile.WriteToString();
  22. return dump;
  23. }
  24. public object ConvertBack(object value, Type targetType, object parameter, string language)
  25. {
  26. throw new NotSupportedException();
  27. }
  28. }
  29. }