LogoffViewModel.cs 2.3 KB

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