MainWindow.xaml.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Dm.filter;
  2. using ProximaAnalizer.PublicEvent;
  3. using System.Text;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Data;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Imaging;
  11. using System.Windows.Navigation;
  12. using System.Windows.Shapes;
  13. namespace ProximaAnalizer.Views;
  14. /// <summary>
  15. /// Interaction logic for MainWindow.xaml
  16. /// </summary>
  17. public partial class MainWindow : Window
  18. {
  19. public MainWindow(IEventAggregator eventAggregator, IRegionManager regionManager)
  20. {
  21. InitializeComponent();
  22. this._eventAggregator = eventAggregator;
  23. this._eventAggregator.GetEvent<WindowSwitch>().Subscribe(SwitchWindow);
  24. this.Loaded += MainWindow_Loaded;
  25. this._regionManager = regionManager;
  26. }
  27. private readonly IRegionManager _regionManager;
  28. private readonly IEventAggregator _eventAggregator;
  29. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  30. {
  31. this.WindowStyle = WindowStyle.None;
  32. this.ResizeMode = ResizeMode.NoResize;
  33. this.Content = new Loading();
  34. }
  35. private object? Summary;
  36. private object? RecipeNavi;
  37. private void SwitchWindow()
  38. {
  39. switch (this._eventAggregator.GetEvent<WindowSwitch>().Page)
  40. {
  41. case Pages.Loading:
  42. Width = 800;
  43. Height = 160;
  44. break;
  45. case Pages.RecipeStepNavi:
  46. Width = 1280;
  47. Height = 800;
  48. this.WindowStyle = WindowStyle.ThreeDBorderWindow;
  49. this.ResizeMode = ResizeMode.CanResize;
  50. this.WindowState = WindowState.Maximized;
  51. this.RecipeNavi ??= new RecipeStepNavi();
  52. this.Content = this.RecipeNavi;
  53. break;
  54. case Pages.MainWindow:
  55. Width = 1280;
  56. Height = 800;
  57. this.WindowStyle = WindowStyle.ThreeDBorderWindow;
  58. this.ResizeMode = ResizeMode.CanResize;
  59. this.WindowState = WindowState.Maximized;
  60. this.Summary ??= new Summary();
  61. this.Content = this.Summary;
  62. _regionManager.RequestNavigate("MainRegion", "DBInfoTrace");
  63. break;
  64. case Pages.HistoryData:
  65. Width = 1280;
  66. Height = 800;
  67. this.WindowStyle = WindowStyle.ThreeDBorderWindow;
  68. this.ResizeMode = ResizeMode.CanResize;
  69. this.WindowState = WindowState.Maximized;
  70. this.Summary ??= new Summary();
  71. this.Content = this.Summary;
  72. _regionManager.RequestNavigate("MainRegion", "DBInfoAlarm");
  73. break;
  74. default:
  75. break;
  76. }
  77. }
  78. }