LogoffViewModel.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using OpenSEMI.ClientBase;
  8. namespace VirgoUI.Client
  9. {
  10. public class LogoffViewModel : DialogViewModel<UserMode>
  11. {
  12. public override string DisplayName { get; set; } = "Virgo";
  13. public LogoffViewModel()
  14. {
  15. this.DialogResult = UserMode.None;
  16. this.LoginName = BaseApp.Instance.UserContext.LoginName;
  17. this.RoleName = BaseApp.Instance.UserContext.RoleName;
  18. this.LoginTime = BaseApp.Instance.UserContext.LoginTime;
  19. }
  20. protected override void OnInitialize()
  21. {
  22. //check some condition to set property AllowShowDown, system manual and PM busy
  23. this.Token = BaseApp.Instance.UserContext.Token;
  24. }
  25. public void Exit()
  26. {
  27. //this message can keep in resource file
  28. if (DialogBox.Confirm(string.Format("Are you sure that you want to {0}?", "exit")))
  29. {
  30. this.DialogResult = UserMode.Exit;
  31. this.TryClose();
  32. }
  33. }
  34. public void ShutDown()
  35. {
  36. if (DialogBox.Confirm(string.Format("Are you sure that you want to {0}?", "shutdown")))
  37. {
  38. this.DialogResult = UserMode.Shutdown;
  39. this.TryClose();
  40. }
  41. }
  42. public void Logoff()
  43. {
  44. this.DialogResult = UserMode.Logoff;
  45. this.TryClose();
  46. }
  47. public void Cancel()
  48. {
  49. this.DialogResult = UserMode.None;
  50. this.TryClose();
  51. }
  52. private bool _AllowShowDown = false;
  53. public bool AllowShowDown
  54. {
  55. get { return _AllowShowDown; }
  56. set
  57. {
  58. _AllowShowDown = value;
  59. NotifyOfPropertyChange("AllowShowDown");
  60. }
  61. }
  62. public string LoginName { get; private set; }
  63. public string RoleName { get; private set; }
  64. public DateTime LoginTime { get; private set; }
  65. }
  66. }