using GalaSoft.MvvmLight.Messaging; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Infrastructure.Interfaces; using Muchinfo.MTPClient.Infrastructure.MessengerArgs; using System.Windows.Controls; using Muchinfo.MTPClient.Infrastructure.Helpers; namespace Muchinfo.MTPClient.Infrastructure.Windows { /// /// ContentWindow类 /// public abstract class ContentWindow : UserControl, IWindow { #region Properties #region Public Properties /// /// 窗口所属工具栏类型 /// public virtual ToolbarButtonType ToolbarType { get { return ToolbarButtonType.Default; } } public WindowItem WindowItem { get; set; } #endregion Public Properties #endregion Properties /// /// Initializes a new instance of the class. /// /// The item. protected ContentWindow(WindowItem item) { WindowItem = item; this.Unloaded += ContentWindow_Unloaded; } #region Methods #region Public Methods /// /// 显示窗口 /// public virtual void ShowWindow() { MessengerHelper.DefaultSend(new AddContentPageArgs(WindowItem, this), MessengerTokens.AddContentPage); } /// /// 刷新窗体 /// public abstract void Refresh(); /// /// 刷新窗体 /// /// public virtual void Refresh(WindowItem item) { } #endregion Public Methods /// /// 窗口Unload事件 /// /// The source of the event. /// The instance containing the event data. protected virtual void ContentWindow_Unloaded(object sender, System.Windows.RoutedEventArgs e) { //取消本窗口注册的消息 MessengerHelper.DefaultUnregister(this); } #endregion Methods } }