BaseWindow.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. namespace FWindSoft.Wpf
  8. {
  9. /// <summary>
  10. /// 基础窗体
  11. /// </summary>
  12. public class BaseWindow:System.Windows.Window
  13. {
  14. private bool m_IsLoadData = false;
  15. public BaseWindow()
  16. {
  17. this.ShowInTaskbar = false;
  18. this.EveryTimeLoad = true;
  19. this.Loaded += BaseWindow_Loaded;
  20. }
  21. private void BaseWindow_Loaded(object sender, RoutedEventArgs e)
  22. {
  23. OnLoad(e);
  24. }
  25. public void ResetLoadData()
  26. {
  27. this.m_IsLoadData = false;
  28. }
  29. /// <summary>
  30. /// 每次都加载
  31. /// </summary>
  32. public bool EveryTimeLoad { get; protected set; }
  33. protected virtual void OnLoad(RoutedEventArgs e)
  34. {
  35. if (EveryTimeLoad || !m_IsLoadData)
  36. {
  37. LoadData(StartParameter);
  38. m_IsLoadData = true;
  39. }
  40. }
  41. internal LoadParameter StartParameter { get; set; }
  42. protected virtual void LoadData(LoadParameter parameter)
  43. {
  44. }
  45. }
  46. }