An advanced sprite packing tool. Currently a work in progress.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3KB

  1. using System;
  2. using System.Dynamic;
  3. using System.Reflection;
  4. using System.IO;
  5. namespace SpritePacker
  6. {
  7. public class Utilities
  8. {
  9. public static string[] GetEmbeddedResourceList()
  10. {
  11. return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
  12. }
  13. public static void PrintEnbeddedResourceList()
  14. {
  15. string[] resFiles = GetEmbeddedResourceList();
  16. foreach (string str in resFiles)
  17. Console.WriteLine("[{0}]", str);
  18. }
  19. public static string GetEmbeddedResourceContent(string resourceName)
  20. {
  21. Assembly asm = Assembly.GetCallingAssembly();
  22. Stream stream = asm.GetManifestResourceStream(resourceName);
  23. if(stream == null)
  24. throw new FileNotFoundException($"Error: The embedded resource with the name {resourceName} does not appear to exist.");
  25. StreamReader source = new StreamReader(stream);
  26. string fileContent = source.ReadToEnd();
  27. source.Dispose();
  28. stream.Dispose();
  29. return fileContent;
  30. }
  31. public static DateTime GetProgramBuildDate()
  32. {
  33. Version asmVersion = GetProgramVersion();
  34. return new DateTime(2000, 1, 1).Add(new TimeSpan(
  35. TimeSpan.TicksPerDay * asmVersion.Build +
  36. TimeSpan.TicksPerSecond * asmVersion.Revision * 2
  37. ));
  38. }
  39. public static Version GetProgramVersion()
  40. {
  41. return Assembly.GetEntryAssembly().GetName().Version;
  42. }
  43. }
  44. }