VinnoMode.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System.IO;
  2. namespace fis.Vid.Visuals
  3. {
  4. public enum VinnoModeType
  5. {
  6. Undefined =0,
  7. Tissue,
  8. Flow,
  9. Doppler,
  10. TissueTM,
  11. Tissue3D,
  12. FlowM,
  13. };
  14. public class VinnoMode
  15. {
  16. public string Name { get; }
  17. public string DisplayName { get; }
  18. public VinnoModeType Type { get; }
  19. public VinnoMode(string name, string displayName, VinnoModeType type)
  20. {
  21. Name = name;
  22. DisplayName = displayName;
  23. Type = type;
  24. }
  25. public byte[] ToBytes()
  26. {
  27. byte[] result;
  28. using (var stream = new MemoryStream())
  29. {
  30. var writer = new VinnoStreamWriter(stream);
  31. writer.WriteString(Name);
  32. writer.WriteString(DisplayName);
  33. writer.WriteByte((byte) Type);
  34. result = stream.ToArray();
  35. }
  36. return result;
  37. }
  38. public static VinnoMode FromBytes(byte[] bytes)
  39. {
  40. VinnoMode result;
  41. using (var stream = new MemoryStream(bytes))
  42. {
  43. stream.Position = 0;
  44. var reader = new VinnoStreamReader(stream);
  45. var name = reader.ReadString();
  46. var displayName = reader.ReadString();
  47. var type = (VinnoModeType)reader.ReadByte();
  48. result = new VinnoMode(name,displayName,type);
  49. }
  50. return result;
  51. }
  52. }
  53. }