BaseModel.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Caliburn.Micro.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace OpenSEMI.ClientBase
  8. {
  9. public class BaseModel : Screen
  10. {
  11. public BaseModel()
  12. {
  13. PageStateList = new List<string>();
  14. }
  15. public PageID Page { get; set; }
  16. public List<string> PageStateList { get; set; }
  17. private int permission = 0;
  18. private int token = 0;
  19. public int Permission
  20. {
  21. get { return this.permission; }
  22. set
  23. {
  24. if (this.permission != value)
  25. {
  26. this.permission = value;
  27. this.NotifyOfPropertyChange("Permission");
  28. }
  29. }
  30. }
  31. public bool HasToken { get { return this.token > 0 ? true : false; } }
  32. public int Token
  33. {
  34. get { return this.token; }
  35. set
  36. {
  37. if (this.token != value)
  38. {
  39. this.token = value;
  40. OnTokenChanged(this.token);
  41. this.NotifyOfPropertyChange("Token");
  42. }
  43. }
  44. }
  45. protected virtual void OnTokenChanged(int nNewToken) { }
  46. protected override void OnActivate()
  47. {
  48. base.OnActivate();
  49. BaseApp.Instance.StatesManager.Register(PageStateList);
  50. }
  51. protected override void OnDeactivate(bool close)
  52. {
  53. base.OnDeactivate(close);
  54. BaseApp.Instance.StatesManager.UnRegister(PageStateList);
  55. }
  56. }
  57. }