PageMatrixAll.xaml.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using NEIntelligentControl2.Models.Matrix;
  2. using NEIntelligentControl2.Models.Station;
  3. using NEIntelligentControl2.Service.Windturbine;
  4. using NEIntelligentControl2.Views.Matrix;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace NEIntelligentControl2.Pages.Matrix
  20. {
  21. /// <summary>
  22. /// 全部矩阵页面
  23. /// </summary>
  24. public partial class PageMatrixAll : Page, IStationInfo
  25. {
  26. private bool _IsWindturbine;
  27. private bool _IsLoaged;
  28. public StationInfo StationInfo { get; set; }
  29. private CacheManager _CacheManager;
  30. public PageMatrixAll(CacheManager cm)
  31. {
  32. InitializeComponent();
  33. _CacheManager = cm;
  34. }
  35. public void UpdateData(object data)
  36. {
  37. Dispatcher.Invoke(() =>
  38. {
  39. foreach (var v in _SPMain.Children)
  40. {
  41. var si = v as IStationInfo;
  42. if (si == null) continue;
  43. si.UpdateData(data);
  44. }
  45. });
  46. }
  47. private void Page_Loaded(object sender, RoutedEventArgs e)
  48. {
  49. if (_IsLoaged || StationInfo == null) return;
  50. List<StationInfo> infos = StationInfo.Tag as List<StationInfo>;
  51. if (infos == null) return;
  52. _SPMain.Children.Clear();
  53. _IsWindturbine = StationInfo.Id == "WIND_ALL";
  54. if (_IsWindturbine)
  55. {
  56. infos = infos.Where(i => i.Type == StationType.Wind).ToList();
  57. foreach (var v in infos)
  58. {
  59. _SPMain.Children.Add(new WindStationBlock(_CacheManager) { StationInfo = v });
  60. }
  61. }
  62. else
  63. {
  64. infos = infos.Where(i => i.Type == StationType.PV).ToList();
  65. foreach(var v in infos)
  66. {
  67. _SPMain.Children.Add(new PVStationBlock() { StationInfo = v });
  68. }
  69. }
  70. _IsLoaged = true;
  71. }
  72. }
  73. }