TDMSFileExtension.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using TDMS.Common;
  3. using TDMS.Default;
  4. using TDMS.Externals;
  5. namespace TDMS
  6. {
  7. public static class TDMSFileExtension
  8. {
  9. public static void SetLevelName(this ITDMSLevel level, string name)
  10. {
  11. level.CreateOrUpdateProperty(Constants.DDC_FILE_NAME, name);
  12. }
  13. public static void SetLevelDescription(this ITDMSLevel level, string name)
  14. {
  15. level.CreateOrUpdateProperty(Constants.DDC_FILE_DESCRIPTION, name);
  16. }
  17. public static void SetFileTitle(this ITDMSFile file, string name)
  18. {
  19. file.CreateOrUpdateProperty(Constants.DDC_FILE_TITLE, name);
  20. }
  21. public static void SetFileAuthor(this ITDMSFile file, string name)
  22. {
  23. file.CreateOrUpdateProperty(Constants.DDC_FILE_AUTHOR, name);
  24. }
  25. public static void SetFileDateTime(this ITDMSFile file, DateTime dateTime)
  26. {
  27. var tdms = (TDMSFile)file;
  28. var ptr = tdms.GetPtr();
  29. var dt = new TDMSDateTime(dateTime);
  30. DDC.SetFilePropertyTimestampComponents(ptr, Constants.DDC_FILE_DATETIME, dt.Year, dt.Month, dt.Day, dt.Hour,
  31. dt.Second, dt.Minute, dt.MilliSecond);
  32. }
  33. }
  34. }