MainWindow.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using log4net;
  2. using NEIntelligentControl2.Models.Messages;
  3. using NEIntelligentControl2.Models.Pages;
  4. using NEIntelligentControl2.Models.Station;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Configuration;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace NEIntelligentControl2
  21. {
  22. /// <summary>
  23. /// 主界面
  24. /// </summary>
  25. public partial class MainWindow : Window
  26. {
  27. private IPageAction _IPageAction; // 页面动作
  28. private Page _CurrentPage; // 当前页面
  29. public MainWindow(IPageAction action)
  30. {
  31. InitializeComponent();
  32. _IPageAction = action;
  33. SwitchPage("Home.PageWindturbineAGC");
  34. }
  35. private void StatusBar_ItemClick(object sender, RoutedEventArgs e)
  36. {
  37. var ee = e as Views.MainWindow.MenuItemRoutedEventArgs;
  38. if (ee == null) return;
  39. _SBMain.IsMenuOpen = false;
  40. SwitchPage(ee.Tag);
  41. }
  42. /// <summary>
  43. /// 切换页面
  44. /// </summary>
  45. private void SwitchPage(string tag)
  46. {
  47. var page = _IPageAction[tag];
  48. if (page == _CurrentPage) return;
  49. _CurrentPage = page;
  50. _FrameMain.Navigate(page);
  51. if (!_FrameMain.NavigationService.CanGoBack) return;
  52. var en = _FrameMain.NavigationService.RemoveBackEntry();
  53. while (en != null)
  54. {
  55. en = _FrameMain.NavigationService.RemoveBackEntry();
  56. }
  57. }
  58. }
  59. }