Settings.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Diagnostics;
  3. using Windows.Foundation.Collections;
  4. using Windows.Storage;
  5. using YJMPD_UWP.Model.Object;
  6. namespace YJMPD_UWP.Helpers
  7. {
  8. static class Settings
  9. {
  10. public static IPropertySet Values = ApplicationData.Current.LocalSettings.Values;
  11. static Settings()
  12. {
  13. //Define default settings here
  14. Values["hostname"] = "imegumii.space";
  15. Values["port"] = "3333";
  16. if (Values["username"] == null)
  17. Values["username"] = "Anon_" + Util.Random(5, Util.RandomType.ALPHANUMERIC);
  18. if (Values["statistics"] == null)
  19. Values["statistics"] = Util.Serialize(new Statistics());
  20. st = Util.Deserialize<Statistics>(Values["statistics"] as string);
  21. }
  22. private static Statistics st;
  23. public static Statistics Statistics
  24. {
  25. get
  26. {
  27. return st;
  28. }
  29. }
  30. public static string Username
  31. {
  32. get
  33. {
  34. return Values["username"] as string;
  35. }
  36. set
  37. {
  38. Values["username"] = value;
  39. }
  40. }
  41. }
  42. }