ContentWindow.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using GalaSoft.MvvmLight.Messaging;
  2. using Muchinfo.MTPClient.Data.Enums;
  3. using Muchinfo.MTPClient.Infrastructure.Interfaces;
  4. using Muchinfo.MTPClient.Infrastructure.MessengerArgs;
  5. using System.Windows.Controls;
  6. using Muchinfo.MTPClient.Infrastructure.Helpers;
  7. namespace Muchinfo.MTPClient.Infrastructure.Windows
  8. {
  9. /// <summary>
  10. /// ContentWindow类
  11. /// </summary>
  12. public abstract class ContentWindow : UserControl, IWindow
  13. {
  14. #region Properties
  15. #region Public Properties
  16. /// <summary>
  17. /// 窗口所属工具栏类型
  18. /// </summary>
  19. public virtual ToolbarButtonType ToolbarType
  20. {
  21. get
  22. {
  23. return ToolbarButtonType.Default;
  24. }
  25. }
  26. public WindowItem WindowItem
  27. {
  28. get;
  29. set;
  30. }
  31. #endregion Public Properties
  32. #endregion Properties
  33. /// <summary>
  34. /// Initializes a new instance of the <see cref="ContentWindow"/> class.
  35. /// </summary>
  36. /// <param name="item">The item.</param>
  37. protected ContentWindow(WindowItem item)
  38. {
  39. WindowItem = item;
  40. this.Unloaded += ContentWindow_Unloaded;
  41. }
  42. #region Methods
  43. #region Public Methods
  44. /// <summary>
  45. /// 显示窗口
  46. /// </summary>
  47. public virtual void ShowWindow()
  48. {
  49. MessengerHelper.DefaultSend(new AddContentPageArgs(WindowItem, this), MessengerTokens.AddContentPage);
  50. }
  51. /// <summary>
  52. /// 刷新窗体
  53. /// </summary>
  54. public abstract void Refresh();
  55. /// <summary>
  56. /// 刷新窗体
  57. /// </summary>
  58. /// <param name="item"></param>
  59. public virtual void Refresh(WindowItem item) { }
  60. #endregion Public Methods
  61. /// <summary>
  62. /// 窗口Unload事件
  63. /// </summary>
  64. /// <param name="sender">The source of the event.</param>
  65. /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
  66. protected virtual void ContentWindow_Unloaded(object sender, System.Windows.RoutedEventArgs e)
  67. {
  68. //取消本窗口注册的消息
  69. MessengerHelper.DefaultUnregister(this);
  70. }
  71. #endregion Methods
  72. }
  73. }